How to copy Region field from incident to REQ & RITM & SC Task.

jugantanaya
Tera Contributor

Hi,

If a request created from an Incident how i can copy region field to REQ & then RITM & then SC Task?

 

 

jugantanaya_0-1776362926548.png

Thanks in advance.

 

Regards,

Juganta

6 REPLIES 6

AlpUtkuM
Mega Sage

If I would be you, I would only create one more additional region field on RITM or SCTASK form. It would not make sense to create same field for every form.  I would create an after Business Rule on Incident table. Business rule should run on Insert. Try below code on BR

 

// Example code to copy region field from Incident to SCTASK

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

    var task = new GlideRecord('sc_task');

    task.addQuery('parent', current.sys_id);

    task.query();

    while (task.next()) {

        task.region = current.region;

        task.update();
    }

})(current, previous);

 

 

jugantanaya
Tera Contributor

Hi @AlpUtkuM ,

 

Thanks for your email.

 

Above BR is not working.
Any other solution do you have?

 

Regard,

Juganta

Did you pay attention to the exact field names? Alternatively, you could try using flow designer to replicate the field value from Incident to the form you want.

lauri457
Tera Sage

When you order from the catalog via that ui action, the originating incident will be added as a parent to the request [sc_request] record. Consider if you really do need to duplicate the same data in multiple places when you have a clear hierarchy from the sc_task to the incident where the information is stored. 

 

If you really can't live without it then you can just put something like this in a before br on sc_req_item and sc_task

//ritm/sctask
current.setValue("u_region, " current.request.parent.u_region.getValue());
//req
current.setValue("u_region, " current.parent.u_region.getValue());