Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

External Signal

Avatar

Level 5

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.

 
 
 
 
 
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

View solution in original post

6 Replies

Avatar

Community Advisor

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.

 

 

Avatar

Level 5

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.

Avatar

Community Advisor

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 

Avatar

Level 5

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")

 

 

rvnth_1-1714651208653.png

 

Please let me know if this is fine.

 

Avatar

Level 7

Hello, here is this code, that restarts the workflow if it isn't receiving signals. If it's receiving it makes the PostEvent.

Heku__0-1714651896996.png

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.

Avatar

Correct answer by
Community Advisor

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.