Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Had another question on the community where they have a record producer which is linked to from more than one ESS page. And depending on values on the user, the record producer should show different fields.

To show how this can be done, I have decided that I want to see which department the current user has, and if it is the Finance department, I want to hide the impact field.

Do do this I need to do 2 things. I will put the code in a catalog client script that runs only on my record producer "Something Broken" and it needs to do a GlideAjax call to get the department since I can't get that info from the g_user API. Then depending on the result, I will use the g_form API to hide/show the field.

        1. Create the Script include:

Here comes the code for the script include, from the start it ain't much, but it does the job. Don't forget the check the "client callable" when you create it, otherwise the client script can't call for it.

find_real_file.png

        2. Create the Catalog client script:

Now, if the department of the logged in user is "Finance", we want to hide the Impact field. I want to make it a onLoad script, so it's hidden from the start.

find_real_file.png

That's all that is needed. Now the Impact field below will be hidden if the department is Finance 😃

find_real_file.png