Copy RITM Variable to Task short description

dev_K
Tera Contributor

Hi All,

 

 

Im trying to create a solution where task's short description copies the value of a variable passed in the RITM.

 

what is the best way of solving this?

 

 

dev_K_0-1724336440912.png

 

3 REPLIES 3

SAI VENKATESH
Tera Sage
Tera Sage

Hi @dev_K 

 

You can write business rule on sc_task table (before -insert)

 

(function executeRule(current, previous /*null when async*/) {
    var ritm = new GlideRecord('sc_req_item');
    if (ritm.get(current.request_item)) {
        var variableValue = ritm.variables.your_variable_name; 
        
        current.description = variableValue;
    }
})(current, previous);

 

Thanks and Regards

Sai Venkatesh

Brad Bowman
Kilo Patron
Kilo Patron

If you are using a workflow to create the Catalog Task, in the Advanced script, use a line like this:

task.description = current.variables.var_name;

You could also do something similar with a Business Rule on the sc_task table before insert with Filter Conditions for the Catalog Item and Short Description to narrow it down to this task.  The script on the BR would look like this:

(function executeRule(current, previous /*null when async*/) {
	current.description = current.variables.var_name;	
})(current, previous);

 

Mani A
Tera Guru

Before insert BR on Ctask table

 

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

if (current.request_item) {
var ritmId = current.request_item.sys_id;
var grRitm = new GlideRecord('sc_req_item');
if (grRitm.get(ritmId)) {

current.short_description =grRitm.variables.variableName;
}
}
})(current, previous);