- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2021 03:32 AM
Hello,
I'm trying to set a workflow to get the value of a requested item variable.
I tried to get these information using the GlideRecord sc_item_option_mtom
but the request sys_id never match the the request_item .
Do you have an idea why ?
Thanks in advance,
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2021 06:06 AM
I am using this exact script in a Run Script activity on the workflow that runs on the sc_request table when I submit a Catalog Item. The result is my REQ Description is populated with the string variable that I am populating on the request form. Without this Run Script activity, this doesn't happen. You can add some workflow.info lines to find out why it's not working in your case. Add one right at the beginning to confirm the script is running, then inside the while loop to confirm that an RITM was found. This log inside the while loop should also contain the variable you're trying to get the value of, so in my example I would add these logs to see what the script is doing
workflow.info('GR script running');
var ritm = new GlideRecord("sc_req_item");
ritm.addQuery("request", current.sys_id);
ritm.query();
while(ritm.next()){
workflow.info('RITM found: ' + ritm.number + ' Description variable contains: ' + ritm.variables.v_description);
current.description = ritm.variables.v_description;
}
After I submit a new Catalog Item, I can click the Workflow Context link on the Request to view the log tab. In my example, there could be more than one RITM for this REQ, so the resulting REQ Description will be that of the last record returned. You also need to ensure the variable name is correct, of course, then your variable type will determine the value that is stored. If this doesn't lead you to the resolution of your issue, post your script and let me know the variable type you are trying to get the value of, and what you want to do with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2021 04:26 AM
You can reference RITM variables in any workflow script simply using the syntax
current.variables.variable_name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2021 04:45 AM
Thanks for you message Brad but I'm running the workflow on the request table , i don't get any value with your reference variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2021 05:04 AM
Ah, sorry, I just assumed you were referring to a workflow running on the sc_req_item table. So the script is a bit longer. The example here is populating the REQ Description field from a variable on the RITM named v_description.
var ritm = new GlideRecord("sc_req_item");
ritm.addQuery("request", current.sys_id);
ritm.query();
while(ritm.next()){
current.description = ritm.variables.v_description;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2021 05:46 AM
don't work needer... base on this link
https://docs.servicenow.com/bundle/paris-application-development/page/script/server-scripting/concept/c_UsingGlideRecordToQueryTables.html
it seams that we can't directly use the GlidRecord sc_req_item