Selecting an option from a choice field on a Parent form sets a field visible on a child form

Jeff Wentworth
ServiceNow Employee
ServiceNow Employee

I am attempting to show a checkbox field on a child form based off of a selection made via a choice field on a parent form.

  • This is a new configuration to me.
  • I'm sure that setting a value on a parent form will make a field visible on a child form.
  • I have attached two screenshots to hopefully provide clarity of my ask.

Thanks in advance for any direction provided in this post.

7 REPLIES 7

Tony Chatfield1
Kilo Patron

Hi, if the parent record exists\has been submitted then you should be able to map to the field in an onLoad() client script. You would need to use either
g_form.getReference(parentrecord) to return the parent object, then check the parent.field, but this would not be the best solution as you could not use the callback function.
or use GlideAjax to check the field server side and return a suitable result to the client.

However this sort of configuration could cause discrepancies if the parent.field can be modified by another user after submission, as OOB the child form would not be refreshed based on new values, so some controls around parent.field edit would need to be considered.

If the 2 records are being created at same time via some sort of multiple form\page\record producer solution and the parent has not been committed to the DB, you would need to pass the value between the 2 records via a url sys parameter, or widget (if one is being used).

Also should point out that g_form.getReference() is no longer recommended as best practice due to performance. GlideAjax would be preferable with that approach. 

Thank you very much for your reply, Tony.

 

Between your reply and Max's below, I believe I should be able develop a viable solution. I will definitely update this post once I have.

Max Selwyn
ServiceNow Employee
ServiceNow Employee

Do you need to show the "show section 5" checkbox? If not, you can make it a hidden field and do something like this as a before insert business rule. 

 

BR script:

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

    // Add your code here
var parentChoice = current.parent.facialHair; // where current.parent = your parent reference field name. 

if(parentChoice == "gray"){ //where gray is the value of your selection
current.showSectionFive = true;
}

})(current, previous);