- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:04 PM
Hello,
I am having an issue with a catalog client script. I am trying to pull in the department name of requested for variable and it is showing the sys id of the variable instead of the department name. I'm not sure what I am doing wrong.... I changed setValue to getDisplayValue and still not getting the results I need.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:19 PM - edited 11-09-2023 01:21 PM
Hi Rhonda,
With getReference, you only have access to the field values on the referenced table (sys_user in this case) not fields on another referenced table (cmn_department.name). So you can't dot-walk to get to it or anything else. It looks like you could change the 'Requesting Department Name' variable to a reference on cmn_department, then all would be fine as it would show the name whilst storing the sys_id. If that's not what you're looking for then you'll have to change your approach to a GlideAjax calling a Script Include. Here's a guide on how to make that work, so you can return the department Name instead of the sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:19 PM - edited 11-09-2023 01:21 PM
Hi Rhonda,
With getReference, you only have access to the field values on the referenced table (sys_user in this case) not fields on another referenced table (cmn_department.name). So you can't dot-walk to get to it or anything else. It looks like you could change the 'Requesting Department Name' variable to a reference on cmn_department, then all would be fine as it would show the name whilst storing the sys_id. If that's not what you're looking for then you'll have to change your approach to a GlideAjax calling a Script Include. Here's a guide on how to make that work, so you can return the department Name instead of the sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:25 PM
It is working now. Thank you so much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:49 PM
You are welcome!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:36 PM
Hi, getReference() returns the 'requested_for' record/object, and the department field of any reference field within a record is the referenced record sys_id, so I think this is correct\expected behavior.
If you require the 'name' of the department client side, I think that you would need to return the department record;
However, I believe that getReference() is not recommended best practice and for this type of requirement I would use GlideAjax and a server side script-include to return the department name.