Inherited Field value

Steve A
Kilo Expert

I have Parent to Child Relationships for some of the Records in the Locations table. How do I fill in (and make read only) the values on the Children based on the parent Record. eg. All children locations have the same company as the parent location and only the Parent can be changed

1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

Hi Stephen,



Please add a onAfter - Update Businessrule with below script



Condition - Parent is Empty



var loc = new GlideRecord('cmn_location');


loc.addQuery('parent',current.sys_id);


loc.query();



while (loc.next())


{


        loc.company = current.company;


        loc.update();


}



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

3 REPLIES 3

kristenankeny
Tera Guru

I'd add a Business rule to your location table - when a field you want inherited is updated, do a glide record query to find all children of the parent and update that field. Then add a UI Policy to your location table that when the parent field is not empty, make the inherited fields read only.


SanjivMeher
Kilo Patron
Kilo Patron

Hi Stephen,



Please add a onAfter - Update Businessrule with below script



Condition - Parent is Empty



var loc = new GlideRecord('cmn_location');


loc.addQuery('parent',current.sys_id);


loc.query();



while (loc.next())


{


        loc.company = current.company;


        loc.update();


}



Please mark this response as correct or helpful if it assisted you with your question.

SanjivMeher
Kilo Patron
Kilo Patron

Hi Stephen,



Please mark answer correct, if it resolved your issue.



Thanks,


Sanjiv



Please mark this response as correct or helpful if it assisted you with your question.