Workflow getting stuck at "Wait for condition"

Dom Davidson
Giga Contributor

Hello ServiceNow Gurus,

I am facing a challenge pertaining to workflows more specifically the "Wait for Condition" utility.

Screen Shot 2017-02-21 at 9.40.51 AM.png

Screen Shot 2017-02-21 at 10.35.09 AM.png

In this case, the workflow needs to wait until the underlying PtO(Permit to Operate) record has been approved.   I have created a "Ptb Approval Flag(u_pto_approved)" True or False field on the underlying table, that checks if the associated PtB record is approved or not.   If the associated PtB record is approved a BR is triggered to update the Approval Flag field to True.

My intention of using "Wait for Condition" is to wait until once the flag has been checked, and then proceed forward with the workflow. As it stands, the once the PtB record is approved, the Approval flag updates to True but the workflow stops there and doesn't proceed forward.   However, I did notice if I update any other random fields on the form, and hit save, the workflow then only proceeds forward.

Is there a way I can automate this? Such that once the PtB Approval Flag is checked by the BR, the workflow proceeds forward without any hinderance? Would I need to add in additional script to my BR such that once Approval Flag is true -> trigger back the workflow? If so, how would that additional piece of script look like?

Much thanks for your insight on this matter.

-Dominic

1 ACCEPTED SOLUTION

Ohh, are you setting the PtB Approval flag from a display business rule?



That makes sense, as the value is just shown on the form and not really saved at the server side. In fact, since the server side value is still "false" for this field, even if we trigger the workflow from display business rule, it won't work.



What I'd suggest is to write a business rule on PtB Approval records. And as soon as it is approved, update the parent rm_release record. That would trigger the workflow.



-Mandar


View solution in original post

15 REPLIES 15

Hi Dominic,



When the Pto Approved field is updated, did you find the gs.log() statement being logged?   And could you add a statement outside of the if/else structure to see if the wait for condition check is being done or not. Ideally, it should be checked twice, once when the workflow control moves to this activity with u_pto_approved set to false and one more time when the u_pto_approved is set to true through a business rule.



Also, rfedoruk, do we really need the "SNC - Run Parent Workflows" BR in this case? As, the u_pto_approved field is on the same table on which this workflow runs. I believe, that BR is used to nudge parent record's workflows.



-Mandar


*should*, yes.   I remember at least one version where I had to build my own because the Task version wasn't taking care of business.


hmmm, that is strange..


Hi Mandar/Robert,



I want to clarify a few things


- The Workflow is defined on the Release(rm_table) table, which has a custom reference field pointing to the PtB(Permit to Build) table.


- The user can associate any PtB record to this custom field.


- A BR runs on the backend checking the PtB table with the associated PtB record and updates the "PtB Approval Flag" if the underlying PtB record has been approved.



newuser: As per your suggestion I added a log statement before the if/else condition.


Screen Shot 2017-02-21 at 12.06.25 PM.png



-When a unapproved PtB record is associated with the Release, the "PtB Approval Flag" remains unchecked. Both the Precheck and PtO Not approved logs appear three times.


Screen Shot 2017-02-21 at 12.17.32 PM.png



-However once the associated PtB record is approved, the "PtB Approval Flag(PtO Approved)" is checked to True. There are no additional logs statements are created.


Screen Shot 2017-02-21 at 12.21.30 PM.png


Screen Shot 2017-02-21 at 12.21.56 PM.png



-However, if I update and save any another random field on the Release record(eg- Priority), the workflow progress forward logging the approved PtB statement.



Screen Shot 2017-02-21 at 12.25.26 PM.png


Screen Shot 2017-02-21 at 12.26.17 PM.png



-Dominic


Which table is the workflow running on?



Does the u_ptb_approved field exist on the Release or the PtB?



Its sounding like the update is happening on a table that's a child of the one the workflow is running on.