Hiding fields on portal using Client Script

AndriaLynG
Tera Contributor

Good day!
I created a catalog client script that hide fields if the requested for is member of a group and selected specific request type. It works on the portal, but an issue encountered while changing the requested for field. Can someone know how to configure or fix the script for this? Thanks!

1 ACCEPTED SOLUTION

Amitlokre
Tera Expert
  1. You’re using an onChange client script on the request_type variable.

     
    function onChange() { var deptId = g_form.getValue('requested_for_entity'); var requestType = g_form.getDisplayValue('request_type'); ... }

     This script only runs when request_type changes.
    But when you change Requested for, the script doesn’t automatically re-run, so the visibility rules for your fields don’t update.

    Fix : 

  2. Create another onChange Client Script for the variable requested for.

     

  3. Inside that script, call the same logic you already have (e.g., put your hide/show logic into a reusable

View solution in original post

15 REPLIES 15

@AndriaLynG 

where is Requested for Entity variable on form?

any client script is running on that?

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

Amitlokre
Tera Expert
  1. You’re using an onChange client script on the request_type variable.

     
    function onChange() { var deptId = g_form.getValue('requested_for_entity'); var requestType = g_form.getDisplayValue('request_type'); ... }

     This script only runs when request_type changes.
    But when you change Requested for, the script doesn’t automatically re-run, so the visibility rules for your fields don’t update.

    Fix : 

  2. Create another onChange Client Script for the variable requested for.

     

  3. Inside that script, call the same logic you already have (e.g., put your hide/show logic into a reusable

Hi @Amitlokre , I already created another onChange client script for another variable as you proposed but the result is still the same.

Hi @Amitlokre , it works now. Thank you so much!

Last question, how can it be possible to also run for French language!

SunilKumar_P
Giga Sage

@AndriaLynG - As you mentioned "but an issue encountered while changing the requested for field", do you have any client scripts related to 'reqeuested for' variable? If yes, could you please share?