
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2024 09:14 AM
Hi all,
I have a reference filed that reference to a custom lookup table.
the Reference qual is working good, but user need to select the return value manually.
javascript:'u_active=true^u_key=TEST Fees^u_dependent='+current.u_test_name.u_value
so i think of to make it as computed field, so using the script, however the value is not returned to the computed field, it shown empty.
Is there something wrong? pls help me if any idea, or computed filed cannot be use like that?
how can do this to lookup the value automatically ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2024 10:12 AM
You can use a script like this in a calculated field. Know that if this works, the value will be selected, and the field read-only. If this is what you want, check a list view of your custom table, manually filtering by this criteria to see if the intended record is displayed. If it is, ensure that u_value is the field you want to from this lookup table, and that the field type matches the field type of the calculated field. If this is still a reference, u_value needs to be a sys_id of the lookup table, so that doesn't seem like it makes sense. Maybe you want to change this field type?
If you are just looking to populate the reference field when a u_test_name is populated, then use an onChange Client Script that calls a Script Include via GlideAjax to do this GlideRecord and return the desired value or record from the lookup table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2024 09:58 AM
Seems you're trying to use two methods to achieve your desired result. The script looks good, same logic as used in the OOB disctionary for 'definition' defined on the 'sys_generative_ai_prompt_config'. Try setting the 'Use reference qualifier' value to "Simple" (not "Advanced") and no Condition. then test.
You have access to the Script Debugger on that script, you can set a breakpoint and then test with that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2024 10:12 AM
You can use a script like this in a calculated field. Know that if this works, the value will be selected, and the field read-only. If this is what you want, check a list view of your custom table, manually filtering by this criteria to see if the intended record is displayed. If it is, ensure that u_value is the field you want to from this lookup table, and that the field type matches the field type of the calculated field. If this is still a reference, u_value needs to be a sys_id of the lookup table, so that doesn't seem like it makes sense. Maybe you want to change this field type?
If you are just looking to populate the reference field when a u_test_name is populated, then use an onChange Client Script that calls a Script Include via GlideAjax to do this GlideRecord and return the desired value or record from the lookup table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2024 10:31 AM
@Brad Bowman
Thank you very much for your advice, it is working after i change the computed field type to string.
Appreciate your help so much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2024 12:38 PM
Great to hear! I am happy to help!