Workflow stage issue

mitzaka
Mega Guru

Hi SNC,

 

I am stuck with a workflow here. What I have is a workflow over sc_req_item table. I have my own stage set and I am using custom stages - submitted, assigned, under investigation, etc. The first couple of steps of my workflow are to set the Stage to Submitted once someone creates a catalog request. Then the second activity is to create a catalog task which is in the related lists of the RITM records.

 

The beginning of it looks like this:

find_real_file.png

 

What I want to do next it to check if this catalog task is assigned to anyone, and if so then set the stage of the workflow to Assigned. So my two issues here are:

 

1. when I submit a request, the stage default first state still shows 'Approved', and then Submitted (my custom). I believe this is based on the fact that the default dictionary value is 'waiting_for_approval' and maybe something picks this up and sets the Approved stage. So how do I make the default to Submitted.

 

2. In my workflow activity which checks for the task assignee, I am using a WAIT FOR CONDITION activity with the condition 'delivery task.assigned to' is not empty

find_real_file.png

 

But it's not working. Even when I assign the task, the stage of the RITM still says Submitted. So is Delivery Task the right thing to use for this condition?

1 ACCEPTED SOLUTION

randrews
Tera Guru

ok your issue is that the stage setter isn't going to be hit till AFTER the catalog task is set because they are linear... try this...



put a branch before the catalog task and a join after.. set the branchs stage to the same as the task.. and set the join's stage to "Assigned" so that when the join is hit the stage will change to assigned.



now put the wait for you have to the same stage as the catalog task and coming out of the branch going to the join....



hopefully the wait for and task will kick off at the same time.. when the task is assigned the wait for will stop waiting go to the join and trigger the stage change... you may have to put a small <1 minute> timer in front of the wait for to allow the task to be created.


View solution in original post

7 REPLIES 7

Kalaiarasan Pus
Giga Sage

for issue 1 , i suspect this BR on request item table , 'Items Added After Request Approved'... debug this



and for the second issue, the simplest solution i can think right now is like below...



have a business rule on catalog task and have condition something like below



current.assigned_to.changes() && !(current.assigned_to .nil()) && current.request_item.cat_item == 'sys_id of your catalog'



in script have this ,



var requestItem = current.request_item.getRefRecord();


requestItem.stage = 'stage needed';


requestItem.update();



let me tell you , there are multiple ways of doing this ... this is the first thing that struck my mind


That's a good path for thinking. About issue 1, I found that the dictionary entry of RITM's field Stage is by default 'waiting_for_approval'.


find_real_file.png


And the business rule you mentioned has the script, which triggers when the stage is waiting_for_approval and sets the stage to request_approved:


find_real_file.png




About issue 2, your suggestion could do the trick. I was hoping however to get it in the workflow, just makes future maintenance easier. If you have any thoughts on that, plase share.


as i said earlier , first thing that struck my mind you could also try using wait for WF activity ...


check if this helps you



https://community.servicenow.com/people/ctomasi/blog/2012/03/29/2191


you would need to trigger the event somewhere, may be UI action or a business rule