Workflow().broadcastEventToCurrentsContexts(gr, 'update', null) is not starting the Workflow

Gowtham Kodali
Tera Contributor

I have a custom choice in the sc_task if that choice is selected the workflow is stopping if the task state is change to closed cancelled(custom choice)

I have created a BR on sc_task to start the work flow again

i have used 

Workflow().broadcastEventToCurrentsContexts(gr, 'update', null) 

 

to start the workflow again but the workflow is not starting again any ideas how to stat the workflow again

 

Thank you,

Gowtham

1 ACCEPTED SOLUTION

@Gowtham Kodali 

Please use this workaround and this should work fine.

Business rul

Table: sc_task
When: after update
Condition: State changes to Close Cancelled

(function executeRule(current, previous /*null when async*/) {

var wf = new Workflow();
var ri = new GlideRecord("sc_req_item");
if (ri.get(current.request_item)) {
wf.runFlows(ri, 'update');

}
})(current, previous);

Reference:

activity.result = '10' not working for custom state values

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

25 REPLIES 25

Yes I have checked for closed cancelled it is 10

Can you try this

activity.result == 10

check this link as well; I doubt you can add extra condition for your state value as per docs

How is the activity conditions value set for catalog task activities?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I checked that Still not working 

I tried this as well but no luck

@Gowtham Kodali 

I doubt if this can be achieved.

one thing you can try is keep the catalog task activity in OOB i.e. Always condition;

then use wait for condition script which would check for the task state is close cancelled

The BR would then trigger the workflow from that point.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader