Script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 11:35 PM
Hi All,
I have a requirement to populate a set of value in a lookup select field 'Department' which is getting values from Department table based on the lookup select field 'Business Unit' which is getting values from Business Unit table.
My solution:
1. I wrote an onchange client script to get the Business unit value (getting sys id of the value).
2. Wrote a script include to first get the name of the Business unit from business_unit table (as I'm getting the sysId from client script) and then try to glide Department table to get the set of values associated with business unit selected by the user.
Script Include:
Client script:
Issue: I'm unable to get the array of values from the department table. Need help to correct the code.
Thanks,
Nipan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 12:07 AM
Hi @Nipan1 ,
Please try to change the syntax of your script like
alert("String = " + value )
gs.addInfoMessage("String = " + value )
In both client script and script include
Please mark my answer correct and helpful if this works for you
THanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 12:20 AM
Hi @OlaN,
Thanks for the reply!
Previously: I was not getting the Business unit name, with which the second part of the script include will work and I can get the list of Department values associated with the selected Business unit.
After edits: I'm now getting the Department values but those are wrong (Getting values which are not having any business unit in the department table for each selection of Business unit field in the form)
-Nipan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 11:52 PM
Hi @Nipan1 ,
Please try to push the name in department array like below code
departValue.push(gDept.getValue('name').toString());
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 11:59 PM
@dgarad I see following issues in your script.
1. Client script:
(i) on line number 5, insted of using g_form.getUniqueValue() use g_form.getValue()
var bu = g_form.getValue('business_unit');
(ii) Update the line number 14 as follows.
alert('res1 '+response);
Script Include
(i)Line number 27
gs.addInfoMessage('nipan1'+ BUValue);
(ii)Line number 40
gs.addInfoMessage('business: '+ business);
Line number 53
gs.addInfoMessage('nipan2 '+ departValue);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 12:11 AM
Hi @Sandeep Rajput ,
Thanks for the reply!
I have done the changes you mentioned above. But I am getting the getting the same department values for every business unit selected (The department values are having empty Business in the table).
Above are the values I'm getting in the gs.log
-Nipan