Auto Populate the RITM record field in the related task table record

tanz
Tera Expert

Hi,

 

I have a RITM record which has a TASK record in related field. Whenever i change the field in the parent the parent RITM record the same change should be reflected in the child task record. 

I have created two custom fields in the ritm tabe:

1. my additional comments - this is string field

2. my status - this is choice field with value - completed and cancelled

The corresponding field in the task table

1. my task additional comments - this is string field

2. my task status - this is choice field with value - completed and cancelled

 

Whenever these fields get change in parent RITM these should change in child task and reflect the same value. Could you please help with this

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@tanz 

Is this a business requirement?

I could see you have created a new choice field but you could already use OOB state field

You also created comments field whereas you can easily use OOB comments field.

Your requirement is easy. what script did you start with and where are you stuck?

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

Hi @Ankur Bawiskar ,

Yes, this is a business requirement.

Could you please help with the script, i have tried after update BR but it is not working

@tanz 

please share script you started with and what debugging have you done so far?

it should be an easy script

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

Jack Littlewort
Giga Guru

Without knowing your specifics you could do something like the below

 

In the condition you would put your additional comments changes or your tasks status changes (I have used state in my example)

JackLittlewort_0-1700484405095.png

 

And then you would script something like this.

 

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

	var taskGR = new GlideRecord('task');
	taskGR.get(current.task);

	taskGR.comments = current.comments;
	taskGR.state = current.state;
	taskGR.update();

})(current, previous);