How to Change the Display Value Based on the View in a ServiceNow Portal Form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 01:41 AM
In a ServiceNow portal form, I am displaying a form with a specific view. I would like to change the Display Value dynamically based on the view.
I tried using an onLoad Client Script I was able to get the view from the URL, but I couldn't set the Display Value.
function onLoad() {
var url = top.location.href;
var value = new URLSearchParams (url) .get ("view");
if (value === "a_userportallist") {
var username= g_form.getValue('u_username');
g_form.setValue('display_value_field', username);
}
}
Is it possible to change the Display Value depending on the view? If so, what would be the best approach?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 02:12 AM
are you referring to setting display value of reference field/variable?
if yes then it's not possible as it comes from Dictionary and is shown for the field which is marked as Display=true on that table
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 06:24 PM
Thank you for the reply.
It is a String Value, not a Reference. In the current Default View, A (String Type) is the Display Value, but I would like to set the other B (String Type) to Display Value in the newly created Custom View.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 07:08 PM
Didn't get this sentence -> In the current Default View, A (String Type) is the Display Value, but I would like to set the other B (String Type) to Display Value in the newly created Custom View
Please explain with screenshots.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader