Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Copy Request short_description to Requested Item short_description via workflow script

Cat
Mega Guru

Hi All,

 

I've created a script that is run via the workflow to set the Request short_description to what has been entered in the summary variable.

I'd like to now copy what is in the Request short_description to the Requested Item short_description (done this way so I don't have to customise both scripts for different catalog items.

This is what I currently have which works to update the request - how can I change it to work to update the request item from what is on the request?

 

var desc = current.cat_item.name;
var num = current.number;
var gr = new GlideRecord('sc_request');
if (gr.get(current.request)){
    gr.short_description = current.variables.summary;
    gr.requested_for = current.variables.request_for;
    current.requested_for = current.variables.request_for;
    gr.update();
   
}
 
Thanks is advance
1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Hi Cat,

In a workflow that's running on the sc_req_item table, 'current' refers to the Requested Item record, so you just need one line to set the value of current.short_description to the same thing you're setting gr.short_description to:

var desc = current.cat_item.name;
var num = current.number;
var gr = new GlideRecord('sc_request');
if (gr.get(current.request)){
    gr.short_description = current.variables.summary;
    gr.requested_for = current.variables.request_for;
    current.requested_for = current.variables.request_for;
    gr.update();
    current.short_description = current.variables.summary; 
}

Or if you really want to set it to the value from the request field,

var desc = current.cat_item.name;
var num = current.number;
var gr = new GlideRecord('sc_request');
if (gr.get(current.request)){
    gr.short_description = current.variables.summary;
    gr.requested_for = current.variables.request_for;
    current.requested_for = current.variables.request_for;
    gr.update();
    current.short_description = current.request.short_description;   
}

 

View solution in original post

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

Hi Cat,

In a workflow that's running on the sc_req_item table, 'current' refers to the Requested Item record, so you just need one line to set the value of current.short_description to the same thing you're setting gr.short_description to:

var desc = current.cat_item.name;
var num = current.number;
var gr = new GlideRecord('sc_request');
if (gr.get(current.request)){
    gr.short_description = current.variables.summary;
    gr.requested_for = current.variables.request_for;
    current.requested_for = current.variables.request_for;
    gr.update();
    current.short_description = current.variables.summary; 
}

Or if you really want to set it to the value from the request field,

var desc = current.cat_item.name;
var num = current.number;
var gr = new GlideRecord('sc_request');
if (gr.get(current.request)){
    gr.short_description = current.variables.summary;
    gr.requested_for = current.variables.request_for;
    current.requested_for = current.variables.request_for;
    gr.update();
    current.short_description = current.request.short_description;   
}

 

Thank you! This was what I was needing!

You are welcome!

 

 

Connect with me https://www.linkedin.com/in/brad-bowman-321b1567/