The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Triggering workflow wait for condition

Jared Wason
Tera Guru

Hello,

I have a workflow for a RITM that has a wait-for condition. The wait for condition is waiting for the user who the RITM is requested for to have their user record updated. If I manually update the user record and then go to the RITM and make any change the wait for condition works properly. I created a business rule that when the user record gets updated go to the RITM and make a change so that the wait for the condition will trigger without anyone needing to manually update the RITM. However, after adding the business rule and updating the user record I am getting a workflow terminated error message. Does anyone know how I can resolve this issue?

find_real_file.png

1 ACCEPTED SOLUTION

Hi Jared,

Since the workflow is on RITM table, it will only move forward in case there a manual change on the RITM, instead of updating the RITM with a business rule. Write an after business rule on the user table with the below logic.

 runWorkflow_task();

    function runWorkflow_task() {
        var parentGr = new GlideRecord(sc_req_item);
        parentGr.addQuery("requested_for", current.sys_id);
        parentGr.query();
        if (parentGr.next()) {
            new Workflow().broadcastEventToCurrentsContexts(parentGr, 'update', null);
        }
     }

Hence whenever the user record is updated, the wait for condition will again trigger and check for the condition.

Let me know in case of any further queries.

Regards,

Deepankar Mathur

View solution in original post

7 REPLIES 7

Hi Jared,

I would suggest to open the script include and you can go through the function being written by Servicenow, which can provide you with more details and OOB functions that can be utilized.

Regards,

Deepankar Mathur

Muhammad Khan
Mega Sage
Mega Sage

Hi Jared,

 

I would suggest you to use Set Values activity of Workflow after Wait for condition activity.

 

Hopefully this will give you a direction.

 

Regards,

Muhammad Khan

Do you mean I should use Set Value activity to update the RITM on the workflow after the Wait For Condition? If so, the reason I am updating the RITM with a Buisness Rule is because the Wait For Condition does not check to see if its condition is met until the RITM gets updated. At least, that is my understanding of the Wait For Condition.