Can i retrigger the workflow from the activity which has failed using wait for condition

ashwani_eshoppi
Kilo Expert

I have added a wait for condition in the workflow and checking a field value inside the script , this field is getting populated from another REST message call.

In wait for condition, i have made a query to the table which has this field.

Now since the field is getting populated asynch , and if the script executes in wait for condition , and it does not match , it remains at the same running stage, until the workflow is retrigerred.

Is there a way, to retrigger the same halted activity?

1 ACCEPTED SOLUTION

ashwani_eshoppi
Kilo Expert

Thanks for your responses.


I have implemented a solution which works fine.


Trigerred the event defined in wait for event activity from the scripted web services using the below code.


new Workflow.broadcastevent(context.sys_id,"event_name").



For workflow, events is identified only through broadcast events and not gs.eventqueue


Eariler i was trying to trigger an event through eventqueue, which though was showing in event logs, did not interacted with event of wait for event activity.


View solution in original post

11 REPLIES 11

ashwani_eshoppi
Kilo Expert

By global table means, the workflow is defined on the global table..


find_real_file.png



Further, there is a wait for condition activity , as one of the activity present in this workflow as below :


find_real_file.png



Now once the workflow gets triggered and reaches wait for condition , this conditional script executes, and remains in the running state.


Note: In Condition Filter, i am not able to see any result field, so had to write conditional script.



Now, i trigger a different workflow / run a background script to populate the result field of the wf_context record which is created through the above workflow, hoping that the wait for condition will execute itself and pass through. But there needs to some mehanism to retrigger this activity since it does not execute itslelf again.



Do you have any idea over here?


In your screenshot you note that the value is set from another workflow - you did not mention that in your original post. Couldn't that other workflow fire the event?


ashwani_eshoppi
Kilo Expert

Hi Julian,



In the screenshot i mentioned another workflow.. and in previous statement   I mentioned "I have added a wait for condition in the workflow and checking a field value inside the script , this field is getting populated from another REST message call."



Basically another workflow, is triggering the REST Message whose endpoint is pointing to the scripted REST API and in this API, i am updating the result field of the workflow context. This is all behind the scene which need not be of interest here.


Overall, i am just setting the "result" field in workflow context record.



In the same scripted Rest API , i did tried creating an event, after registering that event in event registry.


Then created "wait for event" in the workflow activity instead of "wait for condition"


find_real_file.png



This behaves similar to wait for condition and halts at running state.


ashwani_eshoppi
Kilo Expert

Anyone has any idea over here?


Hi Ashwani,



Just a question - do you think if there is a way to get the workflow context id when the field is updated from the REST message call?



Because, triggering an event could work if you trigger that event using proper workflow context (hint: broadcastEvent).



Will give some more thought to how to achieve this in the absence of workflow context id - if you confirm on above.