- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 01:42 AM
Hi, I want to change software model choice list of reference type depending on other choice list filed on change
but it didn't work
How can I resolve this problem?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 04:58 AM
To filter the results of a reference type field based on another field, choose 'Advanced' in the Use reference qualifier field, then one of the following examples for the Reference qual
javascript:'manager=' + current.u_manager
This will return records where the (manager) field on the reference table (sys_user in my example) matches the value selected in the u_manager field. The list of records will refresh when u_manager changes.
javascript: new userUtils().getUser(current.u_manager);
This example calls a Script Include named userUtils and a function within it named getUser, passing in the value selected in the u_manager field to use in the script. This will allow you to do other/ more advanced queries. The key to this working is that the return of the Script Include is similar to this:
return 'sys_idIN' + usrArr.join(',');
where usrArr is an array I was using in the GlideRecord query to push sys_ids - so it's just a comma-separated list of sys_ids that can be found on the reference table of the field this is used on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 03:28 AM
You shouldn't have GlideRecord in a Client Script, so get rid of that whole block as it's not being executed anyway, and is likely preventing the rest of the script from running. If the u_software_model field is of the Type 'Choice' (not 'Reference') clearOptions and addOption will work. If you need to look up the choice values and labels to add from the sys_choice table or wherever depending on the newly selected other field value, then use a GlideAjax to make the server call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2022 06:56 PM
Your answer is really helpful for me. Thank you. And I have one more question, How can I set choice List of reference type? If I use GlideAjax, what return type of it? Could you give me those of examples?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2022 04:58 AM
To filter the results of a reference type field based on another field, choose 'Advanced' in the Use reference qualifier field, then one of the following examples for the Reference qual
javascript:'manager=' + current.u_manager
This will return records where the (manager) field on the reference table (sys_user in my example) matches the value selected in the u_manager field. The list of records will refresh when u_manager changes.
javascript: new userUtils().getUser(current.u_manager);
This example calls a Script Include named userUtils and a function within it named getUser, passing in the value selected in the u_manager field to use in the script. This will allow you to do other/ more advanced queries. The key to this working is that the return of the Script Include is similar to this:
return 'sys_idIN' + usrArr.join(',');
where usrArr is an array I was using in the GlideRecord query to push sys_ids - so it's just a comma-separated list of sys_ids that can be found on the reference table of the field this is used on.