How can I set the short_description field from the value of a single line text variable?

MC2006
Kilo Contributor

I am attempting to set the value of the short_description of a sc_req_item from the user input when the RITM is submitted. The value I want to use from the RITM is a single variable and will be used in an email notification.

 

I have tried to use a BR to set the short_description and have tried a client script as well. I'm still pretty new to ServiceNow and am not familiar with all of the intricacies yet. 

 

Any guidance or pointers would be appreciated.

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@MC2006 

what are you using flow or workflow?

please share screenshots and what did you try?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

 

I haven't tried to use any flows as we are trying to keep all of our notification/actions tied to the configuration of the catalog item. I have tried the below BRs

(function executeRule(current, previous) {
    current.short_description = current.variables.title.toString();
})(current, previous);
 
---
(function executeRule(current, previous /*null when async*/) {
    var title = 'title';
    var shortDesc = current.variables.getValue(title);
   
    if (shortDesc) {
        current.short_description = shortDesc;
    }

    gs.info('set ritm short desc ' + current.number + 'title(' + title + ')=' + title + '.');

})(current, previous);

If you use a flow for the specific RITM, you can access the Catalog Variables in a task creation action. There you can set the value of any of the catalog Variables you created and map it to short_description.

 

@MC2006 

you should use after insert BR on sc_req_item table

Condition: current.cat_item.name == 'Your Item Name Here'

Script:

(function executeRule(current, previous /*null when async*/ ) {

    var shortDesc = current.variables.variableName;
    if (shortDesc) {
        current.short_description = shortDesc;
        current.setWorkflow(false);
        current.update();
    }

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader