How to modify a workflow to add an approver which is entered on a reference variable

yonathanperez
Kilo Contributor

I have an item on the service catalog that contains a reference variable called "Line Manager". I need to modify the workflow, so an activity can be included to create a task for the "Line manager" to approve the request.

1 ACCEPTED SOLUTION

I see it now. You are running that workflow on the request table and not the Request Item as I thought. That is why the activity is being skiped. Please add the following script on the approval activity and let me know if it works (Might need to work further):



//Begin Script


answer = [];


var item = new GlideRecord('sc_req_item');


item.addQuery('request', current.sys_id);


item.query();


while (item.next()) {


if( (item.variables.line_manager   !=   '') {


    answer.push(item.variables.line_manager.sys_id);


}


}


//End Script


Note: If it did not work with "answer.push(item.variables.line_manager.sys_id);" please try again with "answer.push(item.variables.line_manager);"


View solution in original post

25 REPLIES 25

Yes, It is pointing to sys_user



find_real_file.png


pratulagarwal
Mega Expert

Hi,



How are you checking if the approval task is getting generated or not.



Go to sysapproval_approver.LIST   and check if the approval record is created or not.



Regards


Pratul Agarwal


To check if the approval task is being created, I am creating a request that uses that workflow and it does not create the approval task. In my workflow, I have another Approval activity that is set to a user and it is being created but not the approval activity that is being set with the advance script, it is being sklpped for some reason.



Where can I check the sysapproval_approver.LIST?


pratulagarwal
Mega Expert

Type sysapproval_approver.LIST in the left navigation pane, it will take you to the approval table and from there you can verify if the approval record is created or not. Depending upon that we can further investigate.



Regards


Pratul Agarwal


Thanks for clarifying. I checked and it is not actually creating a log nor approval in there.