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

AnubhavRitolia
Mega Sage
Mega Sage

Hi @NAIDILE S 

 

As this is OOTB Child Parent relationship, when you try to create new Control Objective record using "New" button on related list, it should automatically take your current record as parent and after creating new record, it gets mapped as the Child record of the Current Control Objective record.

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Hi @AnubhavRitolia 
Thats crt,
But is there a way to populate the field value to child one?

AnubhavRitolia
Mega Sage
Mega Sage

Hi @NAIDILE S 

 

I guess you want to Auto-populate the Child Field values from Parent Field values, so you can use onLoad Client script on Control Objective table.

 

Condition: Parent field is not empty and parent.sys_class_name='<control_objective_table_name>'.

 

Now you have to use GlideAjax in your script where you have to pass your Parent field value which is Parent Control Objective record. In your Script Include you can get the respective parent Control Objective record and return all desired field values in the form of JSON. 

In your Client Script you can part JSON and populate your field values respectively.

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

@AnubhavRitolia 
Thank you for this approach, do u have any reference document? It will be helpful