How can we glide into same table?

NAIDILE S
Tera Contributor

Hi 

I have a requirement , where I have a table (Control Objective)- parent, and this table (Control Objective) has a related list in which there is same table Control objective - child...
so when i create a record from the related list (child record) , the fields  should be auto filled for the child record..
How can i do it .
can anyone help me on this 

Thank you

NAIDILES_0-1699437633378.png

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@NAIDILE S 

you can use display business rule on the child table and use the parent field to auto-populate fields

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

	// Add your code here
	if(current.parent){
		current.fieldNameOnChild1 = current.parent.fieldName1;
		current.fieldNameOnChild2 = current.parent.fieldName2;
	}

})(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

14 REPLIES 14

@Ankur Bawiskar 
Say if i update the existing record with the new parent, in this case 

@NAIDILE S 

in that case you will require before insert/update and same script

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

HI @Ankur Bawiskar 
Can we use OnChange client script for the same ? If yes how can we achieve it . 
I'm little stuck with this 

@NAIDILE S 

onChange will work when you change the field. you can then use GlideAjax

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

@Ankur Bawiskar 
Ill try with GlideAjax then 
thank you