Hide Fields in the section based on the field value on the record producer form

KC9138345891171
Tera Contributor

we have record producer which will create a record in target table upon submission and now my requirement is to hide particular fields in the section on the form based on the other filed value on the form for the new records which will be creating from now.

For that I have written a onload catalog client script as below but still is not hiding the field as expected, your help with your expertise would be helpful.

Thanks in advance!!

function onLoad() {
    //Type appropriate comment here, and begin script below

    if (g_form.isNewRecord() && g_form.getValue('u_approval_type') == 'Process Exception Request') {
        g_form.setDisplay('u_standard_azl_solution_arch', false);
    }


}
16 REPLIES 16

@KC9138345891171 

it's not working because of g_form.isNewRecord()

when new form is opened it won't have the variable value in it as this record was not generated from record producer

try this

function onLoad() {

    //Type appropriate comment here, and begin script below



    if (!g_form.isNewRecord() && g_form.getValue('variables.u_approval_type') == 'Process Exception Request') {

        g_form.setDisplay('u_standard_azl_solution_arch', false);

    }

}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Ankur, I might miss to say this earlier the record is getting created from the record producer only

@KC9138345891171 

so what's your exact question

Example: INC001 is created via record producer so when INC001 is opened and that variable has your matching value then hide that field

If that's what you require then the script should work fine

If that's not your requirement then what's your exact use-case?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@KC9138345891171 

any update to above?

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

Exactly Ankur, but am not sure why this is breaking and not able to work Q