Splitting up a large workflow using External Signal | Community
Skip to main content
Level 3
March 16, 2017
Solved

Splitting up a large workflow using External Signal

  • March 16, 2017
  • 22 replies
  • 11644 views

Hi,

I have a large complicated workflow which runs at the end of each campaign which summarises findings and then emails this to stakeholders.

Ideally I want to split this into two parts, the simply delivery part and the complicated summarisation part. The simple part will allow the operators to select their data and delivery templates and send the email. The complicated part does a ton of analysis work and delivers some files. The operators should never touch any of the complicated part.

I was thinking to put a signal at the end of the simple part which after X amount of time will trigger the complicated part, passing through the required variables to enable it to determine the campaign it needs to analyse and deliver the automated reports for.

How best to do this? I looked at signals and I think this is the best way, however I'm unsure of exactly how to trigger a signal from a workflow. 

 

Appreciate your input!

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 vraghav

Hi Alistair,

Signal seems to best suit your requirement. 

Each signal activity has an internal name and this is something which helps trigger the signal.

So at the end of simple part you can put a JS code activity.

Use the following code

xtk.workflow.PostEvent('Identifier or internal name of the workflow which contains signal activity', 'The name of the activity from which the event starts', 'The name of the transition to activate. If this name is empty, the event will be issued on the first valid transition', 'The parameters of the event in the form of an XML element. The name of the element must be variables.', 0)

Hope this helps.

Regards,

Vipul

22 replies

vraghav
Adobe Employee
vraghavAdobe EmployeeAccepted solution
Adobe Employee
March 16, 2017

Hi Alistair,

Signal seems to best suit your requirement. 

Each signal activity has an internal name and this is something which helps trigger the signal.

So at the end of simple part you can put a JS code activity.

Use the following code

xtk.workflow.PostEvent('Identifier or internal name of the workflow which contains signal activity', 'The name of the activity from which the event starts', 'The name of the transition to activate. If this name is empty, the event will be issued on the first valid transition', 'The parameters of the event in the form of an XML element. The name of the element must be variables.', 0)

Hope this helps.

Regards,

Vipul

Level 3
March 16, 2017

Hi Vipul,

Would you be so kind as to show an actual example where a variable (such as a delivery Id) is being passed through?

 

Thanks!

vraghav
Adobe Employee
Adobe Employee
March 17, 2017

alistairk16183831 wrote...

Hi Vipul,

Would you be so kind as to show an actual example where a variable (such as a delivery Id) is being passed through?

 

Thanks!

 

Hi Alistair,

Hope this helps.

xtk.workflow.PostEvent('calledWorkflow','signal','', <variables varName= {vars.myName} />,false)

Regards,

Vipul

vraghav
Adobe Employee
Adobe Employee
March 17, 2017

alistairk16183831 wrote...

That looks really good Vipul, I'll test that today. One final question from my head before I am able to test - lets say this was the variable I was creating;

  1. vars.myVar = instance.vars.deliveryId

and there were three records each with a different delivery ID in the data at that point, would all three be passed through to the signal?

 

Hi Alistair,

I'm not sure if I understood it correctly. If the requirement is to pass three deliveryIds in one go through signal you can do something like this.

vars.deliveryid1 = instance.vars.deliveryId1; vars.deliveryid2 = instance.vars.deliveryId2; vars.deliveryid3 = instance.vars.deliveryId3; xtk.workflow.PostEvent('calledWorkflow','signal','', <variables varName1= {vars.deliveryid1} varName2= {vars.deliveryid2} varName3= {vars.deliveryid3} />,false)

Hope this helps.

Regards,

Vipul

Level 3
March 17, 2017

This is working for a single delivery so thank you for those details!

My final requirement is for a multi delivery campaign such as an AB Test.

This is the code;

// Define Delivery Variable vars.myVar = vars.deliveryId; //Pass through Variable xtk.workflow.PostEvent('WKF129','signal','', <variables varName= {vars.myVar} />,false)

And this is the delivery scenario (code is in the END icon);

The above code only brings through a single delivery ID whereas I would need it to bring through all three. Furthermore I would want to devise a way to scale this up - so if an operator decides to do an ABCD test they can just add in the extra deliveries and not have to worry about additional variables.

vraghav
Adobe Employee
Adobe Employee
March 17, 2017

Hi Alistair, why not use queryDef inside end activity. Get all deliveries associated with current workflow by querying on nms:delivery where [workflow-id] = instance.id

Level 3
March 17, 2017

Something along these lines (although my where clause is currently failing);

// Define Delivery Variable var query = xtk.queryDef.create( <queryDef schema="nms:delivery" operation="select"> <select> <node expr="@id"/> </select> <where> <condition expr=[workflow-id] = instance.id/> </where> </queryDef>); var resultSet = query.ExecuteQuery(); for each (var row in resultSet) { vars.myVar = row.@id; logInfo(vars.myVar); } //Pass through Variable xtk.workflow.PostEvent('WKF129','signal','', <variables varName= {vars.myVar} />,false)
vraghav
Adobe Employee
Adobe Employee
March 17, 2017

Yes you are close. Just that the loop will generate multiple deliveryids you can create a comma separated  string and pass that in PostEvent. In the called workflow perform a JS split function to regenerate the deliveryids from passed variable.

The where clause will be expr={"[workflow-id]=" + instance.id}

Hope this helps 

Level 3
March 17, 2017

That is helpful.

I haven't come across a JS split function in Campaign yet. Is there an example I can reference?

That where clause still seems to be failing

vraghav
Adobe Employee
Adobe Employee
March 17, 2017

Split is a function part of JavaScript language. You will find a lot of examples on the internet.

As I don't have my laptop, can check the expression next week.