Automatically update short description in RITM ,SCTASK, Request item

poco
Tera Contributor

i want to update short description  i use run script . Request item short description was update. but reimaging RITM and Sctask not updated i used below script  could please help me this 

variable type is : select box

 

var temp = current.variables.application_being_requested.getDisplayValue();
var requested_by = current.variables.requested_by.getDisplayValue();
var request = new GlideRecord('sc_request');
request.get(current.request);
request.query();
if (request.next()) {
if (temp == "version1")
{
request.short_description = "version1"+requested_by;
request.update();
}
else if(temp == "version2")
{
request.short_description = "version2"+requested_by;
request.update();
}
else
{
request.short_description = "version3"+requested_by;
request.update();
}
}

3 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@poco 

where are you writing the script?

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

View solution in original post

palanikumar
Mega Sage

Hi,

 

Hope you are creating catalog task from the Workflow. Open the Catalog Task activity inside the workflow and perform the following action:

1) Check Advanced Checkbox

2) Add below script inside Advances script:

var temp = current.variables.application_being_requested.getDisplayValue();
var requested_by = current.variables.requested_by.getDisplayValue();
if (temp == "version1")
{
     task.short_description = "version1"+requested_by;
}
else if(temp == "version2")
{
     task.short_description = "version2"+requested_by;
}
else
{
     task.short_description = "version3"+requested_by;
}

 

Thank you,
Palani

View solution in original post

@poco 

in case you are writing the script in workflow catalog task activity to set task short description then script shared by @palanikumar  should work fine.

Please try that.

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

View solution in original post

10 REPLIES 10

Peter Bodelier
Giga Sage

Hi @poco,

 

Assuming current is your requested item, and this is an onAfter BR, Try this:

 

 

var temp = current.variables.application_being_requested.getDisplayValue();
var requested_by = current.variables.requested_by.getDisplayValue();
var request = new GlideRecord('sc_request');
request.get(current.request);
var tasks = new GlideRecord('sc_task');
tasks.addQuery('request_item', current.getUniqueValue());
tasks.query();

if (temp == "version1")
{
request.short_description = "version1"+requested_by;
current.short_description =  "version1"+requested_by;
tasks.short_description =  "version1"+requested_by;
}
else if(temp == "version2")
{
request.short_description = "version2"+requested_by;
current.short_description = "version2"+requested_by;
tasks.short_description = "version2"+requested_by;
}
else
{
request.short_description = "version3"+requested_by;
current.short_description = "version3"+requested_by;
tasks.short_description = "version3"+requested_by;
}
request.update();
tasks.updateMultiple();
current.update();

 

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Ankur Bawiskar
Tera Patron
Tera Patron

@poco 

where are you writing the script?

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

poco
Tera Contributor

iam writing that in workflow Run script

@poco 

in case you are writing the script in workflow catalog task activity to set task short description then script shared by @palanikumar  should work fine.

Please try that.

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