onChange Catalog Client Script to display a value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 09:40 AM
I have a catalog item that references the cmn_location table. When the user selects a location, I do not want it to display the location name, but the site code [u_site_code] on the form. How can this be achieved?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 10:11 AM
You can write the below onChange catalog client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ref = g_form.getReference("location", callback); // Replace location with your variable name
function callback(loc){
g_form.setValue("location",loc.sys_id,loc.u_site_code); // Replace location with your variable name
}
}
Normally, if we want change the display value of a reference field, we have to set Display=true in the field at the table level. But this change is global. So choose the solution as per your need.
Regards,
Vasu Ch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 10:11 AM
Hello @Julia Howells
You can use select box as a type of variable then there you can choose the field value which you want to show in the dropdown.
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 10:23 AM - edited 11-18-2023 02:42 PM
Be aware the lookup select box are very heavy on performance. It is not recommended to use select box unless there is a query ensuring it returns very few records. Even though it is much slower than a reference type variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2023 05:12 AM
Hi, I recommend to use 'lookup select box' field type to achieve it.
Suresh.