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
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

Hi @Ankur Bawiskar 
It worked thanks 

@NAIDILE S 

Glad to know.

Thank you for marking my response as helpful.

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

Hi @Ankur Bawiskar 
There is one more requirement, can u plz help me that

NAIDILES_0-1699442532011.png

 

 say i create this Control objective record by filling all the fields, then i update the parent filed( this parent field will have same fields- So i have to populate the same thing into new record  which i just created ), so basically the desc and short desc will have the values of the parent record. 


Requirement 

. From Table view
- The user creates a new Control Objective via new button on the table.
- Selecting existing Control Objective in the field "Parent"
Expected behavior:  short desc / desc of a parent Control Objective will be populated into the  filed 

@NAIDILE S 

Script I shared should help

what's the challenge?

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