@@ -587,15 +587,15 @@ export class assign_workflow_node {
587587 }
588588 }
589589 if ( _id !== null && _id !== undefined && _id !== "" ) {
590- const res = await NoderedUtil . Query ( { collectionname : "workflow_instances" , query : { "_id" : _id } , projection : { parentid : 1 } , top : 1 , jwt : data . jwt , priority } ) ;
590+ const res = await NoderedUtil . Query ( { collectionname : "workflow_instances" , query : { "_id" : _id } , projection : { "_parentid" : 1 } , top : 1 , jwt : data . jwt , priority } ) ;
591591 if ( res . length == 0 ) {
592592 NoderedUtil . HandleError ( this , "Unknown workflow_instances id " + _id , msg ) ;
593593 if ( ack !== null && ack !== undefined ) ack ( ) ;
594594 return ;
595595 }
596596 const currentinstance = res [ 0 ] ;
597597 const state = res [ 0 ] . state ;
598- const _parentid = res [ 0 ] . parentid ;
598+ const _parentid = res [ 0 ] . _parentid ;
599599 if ( _parentid !== null && _parentid !== undefined && _parentid !== "" ) {
600600 const res2 = await NoderedUtil . Query ( { collectionname : "workflow_instances" , query : { "_id" : _parentid } , top : 1 , priority } ) ;
601601 if ( res2 . length == 0 ) {
@@ -612,8 +612,14 @@ export class assign_workflow_node {
612612 result . user = data . user ;
613613 this . node . send ( [ null , result ] ) ;
614614 if ( ack !== null && ack !== undefined ) ack ( ) ;
615- // await NoderedUtil.UpdateOne("workflow_instances", null, res[0], 1, false, null);
615+ await NoderedUtil . UpdateOne ( { collectionname : "workflow_instances" , query : { _id : _parentid } , item : { "$set" : { "state" : "completed" } } } )
616616 return ;
617+ } else {
618+ const res = await NoderedUtil . Query ( { collectionname : "workflow_instances" , query : { "_id" : _id } , projection : { msg : 1 } , top : 1 , jwt : data . jwt , priority } ) ;
619+ if ( res . length > 0 && res [ 0 ] . msg ) {
620+ result = res [ 0 ] . msg ;
621+ result . state = data . state ;
622+ }
617623 }
618624 }
619625 result . payload = data . payload ;
@@ -697,6 +703,7 @@ export class assign_workflow_node {
697703
698704 const res3 = await NoderedUtil . InsertOne ( { collectionname : "workflow_instances" , item : runnerinstance , jwt, priority } ) ;
699705 msg . _parentid = res3 . _id ;
706+ msg . payload . _parentid = res3 . _id ;
700707
701708 // parentid: res3._id,
702709 msg . newinstanceid = await NoderedUtil . CreateWorkflowInstance ( { targetid, workflowid, resultqueue : this . localqueue , data : msg . payload , initialrun, jwt, priority } ) ;
0 commit comments