- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 02:54 AM
Hello,
Currently, in the CMDB table, the "Display Name" field is set to Display = true, and it shows the value in the format (name - company name). However, in table X, I want to use only the name field (not the full display name) in a reference field. As far as i know whatever field is marked with Display=True it will show that value once reference value is selected Without touching the Display=True at dictionary I can't control what's seen there
I'm trying to find an alternative solution for this.
I created a new string field and I'm attempting to use a Client Script to populate it with only the part of the reference field's display value up to the dash (-).
After that, I plan to hide the reference field.
I wrote the following script, but it's not working yet.
function onLoad() {
g_form.getReference('u_business_product_or_service_name', function(ref) {
if (ref) {
var displayValue = ref.getDisplayValue();
if (displayValue) {
var shortValue = displayValue.split('-')[0].trim();
g_form.setValue('u_short', shortValue); // Show only the part before dash
}
}
});
}
Could I get your opinion or suggestions on this?
Thank you
Beyza
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 02:58 AM
Hi @beycos ,
ref.getDisplayValue() is not available in client-side scripts. That method is server-side only. Instead, you should use g_form.getDisplayBox() or g_form.getDisplayValue() depending on your UI context.
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Mohammad Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2025 02:11 AM
Hi @beycos ,
I hope you are doing well !
Did my response help resolving your issue ?
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards,
Mohammad Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 02:58 AM
Hi @beycos ,
ref.getDisplayValue() is not available in client-side scripts. That method is server-side only. Instead, you should use g_form.getDisplayBox() or g_form.getDisplayValue() depending on your UI context.
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Mohammad Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2025 08:05 AM
Thank Mohammad . It worked now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 03:01 AM
Hi @beycos
The issue is here
var displayValue = ref.getDisplayValue();
Try some like this and let me know if work
function onLoad() {
g_form.getReference('u_business_product_or_service_name', function(ref) {
if (ref) {
var nameOnly = ref.name; // Directly get the "name" field
g_form.setValue('u_short', nameOnly);
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2025 02:11 AM
Hi @beycos ,
I hope you are doing well !
Did my response help resolving your issue ?
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards,
Mohammad Danish