How to pass a reference field from sc_cat_item table to workflow written for corresponding RITM?

sooryamohan
Tera Contributor

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.

1 ACCEPTED SOLUTION

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.

 

 

 

 

 

View solution in original post

4 REPLIES 4

Harsh Vardhan
Giga Patron

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 

}

 

 

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?

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.

 

 

 

 

 

Anil Shewale
Mega Guru

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