- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2020 11:23 PM
Is it possible to pass a field from sc-cat_item/catalog item to a workflow written for RITM .This is for checking approval,based on the value of the field(reference field) from sc_cat_item.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2020 11:21 PM
yes you can do the glide record, use if activity before approval activity on your workflow and use the glide record inside the if activity.
sample code on if activity:
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('sys_id',current.cat_item);
gr.query();
if(gr.next()){
gs.log("inside if "+ gr.model.model_category);
if (gr.model.model_category == "rack") { // make sure the rack value
gs.log("inside if condition check");
return 'yes';
}
else{
gs.log("inside else condition check");
return 'no';
}
}
now you can take yes transition to ABC approval and no transition to other approval activity. also i have added logs so you can troubleshoot it, if its not working.
If my answer helped you, kindly mark it as correct and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2020 11:30 PM
you can do glide record here to get the sc_cat_item field value on RITM,
var ab;
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('sys_id',current.cat_item);
gr.query();
if(gr.next()){
ab = gr.<fieldname>; // use ab variable in workflow
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2020 09:49 PM
Hi Harsh,
I want to check for the Model (reference field from sc_cat_item) before approval activity.Suppose sc-cat_item.model.model_category is rack it should go for a ABC approval.So where can i configure this using glide queries in workflow?Can i check this in run script?Could you please explain?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2020 11:21 PM
yes you can do the glide record, use if activity before approval activity on your workflow and use the glide record inside the if activity.
sample code on if activity:
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('sys_id',current.cat_item);
gr.query();
if(gr.next()){
gs.log("inside if "+ gr.model.model_category);
if (gr.model.model_category == "rack") { // make sure the rack value
gs.log("inside if condition check");
return 'yes';
}
else{
gs.log("inside else condition check");
return 'no';
}
}
now you can take yes transition to ABC approval and no transition to other approval activity. also i have added logs so you can troubleshoot it, if its not working.
If my answer helped you, kindly mark it as correct and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2020 01:14 AM
Hi
following the syntax for access the reference field in workflow.
it is simple to reference the variables.
current.variables.the_name_ref_variable.value;
example.
current.variables.requested_by.company;//according to your
If it help mark helpful or correct
Thanks and regards
Anil