What is the functionality of new Workflow().broadcastEventToCurrentsContexts(gr, 'update', null)

Meenal Gharat
Giga Guru

Hello All,

I have doubt on when do we use following function new Workflow().broadcastEventToCurrentsContexts(grTarget, 'update', null) ?

Thanks and Regards,

Meenal

1 ACCEPTED SOLUTION

Hi Meenal,

I believe the BR is on sc_task table and you want workflow of RITM to proceed on some update.

So the only way to make workflow of RITM proceed once task gets updated is the above script.

So I don't think any other way to handle this.

Regards
Ankur

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Meenal,

this is usually used to make the workflow trigger which is waiting for condition on another table.

Example: you have workflow on change request table and you want to wait till some field gets updated on incident table. In this case wait for condition only waits till update happens on the current record

In this case you cannot make the workflow wait on incident table as it is created on change req table

So what you will do is use BR after update on INC and use the above script to ensure any workflow waiting to move forward i.e. broadcast an update so that workflow proceeds.

check these links should help

https://community.servicenow.com/community?id=community_question&sys_id=a1b64b65db1cdbc01dcaf3231f96...

https://community.servicenow.com/community?id=community_question&sys_id=93f80ba1db5cdbc01dcaf3231f96...

https://community.servicenow.com/community?id=community_question&sys_id=089587eddbd8dbc01dcaf3231f96...

Regards
Ankur

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

Hello Ankur,

Thanks for your response !

We have below code in business rule.which has been identified has slow running script in Health Scan can you suggest if this is normal behaviour of this method or can we do something else for performance optimization?

var grTarget = current.request_item.getRefRecord();

new Workflow().broadcastEventToCurrentsContexts(grTarget, 'update', null);

 

When to run Condition :

Type : After

Update

 

RITM.ITM is XYZ item or state= Closed Skipped

 

Many Thanks,

BR,

Meenal

Hi Meenal,

I believe the BR is on sc_task table and you want workflow of RITM to proceed on some update.

So the only way to make workflow of RITM proceed once task gets updated is the above script.

So I don't think any other way to handle this.

Regards
Ankur

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