Is it possible to print out variables in workflow to the workflow low?

joshua18
Giga Expert

I'm trying to figure out in a workflow why an Approval process is being skipped. I'm assuming the variable I'm trying to use for the user doesn't have the right value but I can't seem to find away to print so I can go from there.

1 ACCEPTED SOLUTION

Might be silly question but is the user you're selecting for approval an active user?



Also, if you want to print the value of the variable, you can do this in the background script with an RITM that has already been created but not working correctly.



var gr = new GlideRecord("sc_req_item");


gr.get("SYS_ID_OF_RITM_HERE");



gs.log("Line Manager: " + gr.variables.u_manager_approval);


View solution in original post

12 REPLIES 12

You can run it as a background script and get the results immediately (see steps below). Also, can you confirm that the variable name is correct? Your variables will not have u_ like custom fields do unless you specifically named the variable that way.



Steps to run background script:


1. Elevate your privileges > Click on your name in the top header and select Elevate Roles > Check the security admin box and select OK


2. In the navigation menu, select System Definition > Scripts - Background


3. Copy and paste the code above


4. Select Run Script


5. You should see an output similar to this:



find_real_file.png


I was able to print out the user's sys_id using:



var gr = new GlideRecord("sc_request");  


gr.get("sys_id");  


 


gs.log("Line Manager: " + gr.u_manager_approval);



Note: The workflow is for Requests and not Request Items, that's why I'm using the 'sc_request' instead of 'sc_req_item'.


So I tried this and hey it worked.



var gr = new GlideRecord('sc_req_item');


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


gr.query();



answer = [];


answer.push(gr.variables.manager_approval);



But I'm making you reply about about the Background Script as correct, as that answers the original question!



Thanks for your help!