The CreatorCon Call for Content is officially open! Get started here.

Get a table field value into another table field

F_bio Santos
Kilo Sage

Im trying to get the value of a field "status" on the table "task_sla" into a custom field I created in the "task [TASK]" table (the field name in "task" is "u_status"), Im using a BR to do this but Im not really sure how to do it, can anyone help ?

BR:

F_bioSantos_0-1694430085349.png


BR Code:

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

var gr = new GlideRecord('task');
gr.addQuery('u_status');
gr.query();

gr.u_status = current.u_status;

})(current, previous);

  

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@F_bio Santos 

u_status on task table is of what type?

Out of the box task_sla doesn't have Status field.

Did you change the label of an existing field?

The logic will be something like this

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

	var gr = new GlideRecord('task');
	if(gr.get(current.task)){
		gr.u_status = current.statusField; // this is the field on task_sla table
		gr.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

View solution in original post

Hello @F_bio Santos 

 

use the same code of @Ankur Bawiskar 

 

 

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

	var gr = new GlideRecord('task');
	if(gr.get(current.task)){
		gr.u_state = current.u_status; // this is the field on task_sla table
		gr.update();
	}

})(current, previous);

 

, just do the modification which i shared.

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh

 

View solution in original post

11 REPLIES 11

Should I use this on the BR or on the code I sent before ?

This worked, I forgot that the "status" field on "task_sla" had some delay ...