Fetch field in the client script which is not available in the form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 10:20 AM
hi
I have one field which is not visible on incident form but it is there.
based on that field I need to set another field mandatory in my client script.
I am guessing I cannot fetch field value using g_form as its not available on the form.
Do I need to do Display business rule and call g_scratchpad variable at client script?
Any suggestions on this please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 10:37 AM
Hi Nikita -
You have a few options here.
- Place the field on your form and hide it with UI policy or g_form.setDisplay('fieldName', false) in onLoad client script. This method allows you to use g_form.getValue
- Create a script include to pull the value, and call the script include within your client script using GlideAjax
- You can do as you described, use a display business rule doing the g_scratchpad method to get the value to your client script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 10:40 AM
Make use of display business and g_scratchpad to handle this situation.
check the below link for an example of display business rule
-satheesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 01:39 PM
Hi,
I am not 100% sure but please try using getReference function in script.
Please refer below link:
Thanks,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 02:30 AM
Hi Nikita,
To achieve the above scenario, the following scripts needs to be written.
At first a Display business rule to store the value of the field not available on the form:
g_scratchpad.group_name= gs.getUser().isMemberOf('Testing group'); // for example taking up the member of the testing group here
Next we need to write the Client script: (making the fields visible or mandatory)
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if(g_scratchpad.group_name)
{
if(newValue == '3')
{
alert('hi');
g_form.setVisible('u_test_field', true);
g_form.setMandatory('u_test_field', true);
}
}
}
Please mark the answer as correct if it suffice your query.
Thanks
Soumita.