error: [javascript] JS-JAVASCRIPT: let instance = Completed.extract-instance-CompletedObjectives(source); -- Error running JavaScript request: ReferenceError: instance is not defined:
My Code:
declareUpdate();
const es = require('/MarkLogic/entity-services/entity-services.xqy');
const Completed = require('/es-gs/CompletedObjectiveEntity-1.0.0-conv.xqy');
for (const source of fn.collection('Objective,Accomplishments')) {
let instance = Completed.extract-instance-CompletedObjectives(source);
let uri = '/es-gs/env/'+ instance.id + '.json';
xdmp.documentInsert(uri, Completed.instanceToEnvelope(instance, "json"),{collections ['CompletedObjective-envelopes']});}
Is in the modules database:
es-gs/CompletedObjectiveEntity-1.0.0-conv.xqy
The output error is
Stack Trace At line 7 column 33: In
let instance = Completed.extract-instance-CompletedObjectives(source);
- const Completed = require('/es-gs/CompletedObjectiveEntity-1.0.0-conv.xqy');
- for (const source of fn.collection('Objective,Accomplishments')) {
- let instance = Completed.extract-instance-CompletedObjectives(source);
- let uri = '/es-gs/env/'+ instance.id + '.json';
- xdmp.documentInsert(
The name of the function is
declare function completedObjectives:extract-instance-CompletedObjectives()
I used the instance generator to create the module:
const es = require('/MarkLogic/entity-services/entity-services.xqy');
const ARTIFACT_DIR = '/data/modules/';
const desc = cts.doc('/es-gs/models/CompletedObjective.entity.json');
xdmp.save(ARTIFACT_DIR + 'CompletedObjectiveEntity-1.0.0-conv.xqy', es.instanceConverterGenerate(desc));
Can anyone point me in the right direction?
Objective,Accomplishments
, or did you intend to specify an array of two collections:fn.collection(['Objective', 'Accomplishments'])
– Mads Hansenfn.collection('Objective', 'Accomplishments')
butfn.collection(['Objective', 'Accomplishments'])
– Mads Hansen