Hi Team,
I've observed that when a postevent triggers an external signal in another workflow, it transitions to the finished state after completing all activities. Is there a method to restart this workflow again? My JavaScript activity runs daily, and if the external signal workflow is in the finished state, it never executes.
Thank you in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @rvnth ,
Not required to restart the second workflow each time.
Keep the second workflow in started state and In the 1st workflow, Make sure you have given 'false' in the xtk.workflow.PostEvent syntax
Example,
xtk.workflow.PostEvent("workflow_internalName","signal","","", false);
If the value is true, then the second workflow will go to finished state after executing all activities.
So, in your scenario, keep the value as false.
Hi @rvnth ,
Could you Please let us know when or at what scenario you require the External Signal Workflow to be triggered again?
Also, if you use the External signal activity, you have to put your 2nd workflow always in started state to check the API Post event Calls.
Regards,
Pravallika.
Views
Replies
Total Likes
Hi @LakshmiPravallika ,
The initial workflow includes a file collector that verifies the file with the current date, followed by a JavaScript activity to initiate another workflow containing the External signal. Please inform me if further details are needed from my end.
Views
Replies
Total Likes
Hi @rvnth
There are different approaches through which you can restart a workflow: -
1. You can put a scheduler in your workflow which will run on a scheduled basis.
2. You can put a restart command to restart the workflow.
Restart (String workflowId)
3. You can put a start command to start/resume the workflow.
Start (String workflowId)
Regards
Akshay
Hi @AkshayAnand @LakshmiPravallika ,
Thank you for your assistance. After reviewing the below thread link: https://experienceleaguecommunities.adobe.com/t5/adobe-campaign-classic-questions/want-to-create-a-m...
I attempted to implement something similar as follows:
var query = xtk.queryDef.create(
<queryDef schema = {vars.targetSchema} operation = "select">
<select>
<node expr="@state"/>
</select>
</queryDef>
);
var record = query.ExecuteQuery();
var status = vars.state;
if (status='Finished')
xtk.workflow.Restart("workflowInternalName")
Please let me know if this is fine.
Hello, here is this code, that restarts the workflow if it isn't receiving signals. If it's receiving it makes the PostEvent.
Just substitute var wkfname with the internal name of the workflow you want to send the event.
Code sample here:
var wkfname="internalname"
var query = xtk.queryDef.create(
<queryDef schema="xtk:workflow" operation="select">
<select>
<node expr="@status" alias="status"/>
</select>
<where>
<condition expr={"@internalName='"+wkfname+"'"}/>
</where>
</queryDef>
);
query.SelectAll(false);
result = query.ExecuteQuery();
logInfo(result[0].status)
if(result[0].status != 1){
logInfo("Workflow is not recieving signals, restarting...")
xtk.workflow.Restart(wkfname)
} else {
logInfo("Posting event")
xtk.workflow.PostEvent(wkfname,"signal","",'<variables x="x"/>',false)
}
Hope this helps.
Hi @rvnth ,
Not required to restart the second workflow each time.
Keep the second workflow in started state and In the 1st workflow, Make sure you have given 'false' in the xtk.workflow.PostEvent syntax
Example,
xtk.workflow.PostEvent("workflow_internalName","signal","","", false);
If the value is true, then the second workflow will go to finished state after executing all activities.
So, in your scenario, keep the value as false.
Views
Likes
Replies
Views
Likes
Replies