External Signal | Community
Skip to main content
Level 5
May 2, 2024
Solved

External Signal

  • May 2, 2024
  • 3 replies
  • 1487 views

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.

 
 
 
 
 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ParthaSarathy

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.

3 replies

LakshmiPravallika
Community Advisor
Community Advisor
May 2, 2024

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.

 

 

rvnthAuthor
Level 5
May 2, 2024

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.

AkshayAnand
Community Advisor
Community Advisor
May 2, 2024

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 

Heku_
Level 5
May 2, 2024

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.

ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
May 2, 2024

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.

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups