- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 10:33 AM
I created custom app off the Task table. For short description, I want to set the field to the value of 'Service', 'Category', and 'Subcategory'. I have created client script to capture that, but it is getting the sys_id of the reference field. Here is my script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 11:33 AM
Alternative to getting display value instead of sys_id for a reference field in core UI could be to use getDisplayBox() function like so.
var category = g_form.getDispayBox('category').value
But as @Chaitanya ILCR mentioned, the better approach is to go with Before Business Rule if you want the change in Short Description to reflect on all 3 field's change of value.
Regards,
Sangeetha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 07:47 PM
Hi @athavichith
You can make use of g_form.getDisplayBox('your_field_name').value method to get reference field value. Refer below example where I tried getting the value of the Caller field and pushing it to the Description Field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var caller = g_form.getDisplayBox('caller_id').value;
g_form.setValue('description', caller);
}
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 11:18 AM
Hi @athavichith ,
better convert this to a before update BR as you would have to create 3 onchange client script each one for service,category and subcategory for this to work
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var service = current.service.getDisplayValue();
var category = current.category.getDisplayValue();
var subcategory = current.subcategory.getDisplayValue();
if (service || category || subcategory) {
var shortDescription = '';
if (service) {
shortDescription += 'Service: ' + service;
}
if (category) {
shortDescription += (shortDescription ? ' / ' : '') + 'Category: ' + category;
}
if (subcategory) {
shortDescription += (shortDescription ? ' / ' : '') + 'Subcategory: ' + subcategory;
}
current.setValue('short_description', shortDescription);
}
})(current, previous);
if you want this in client side
create a client callable client script include with client scripts
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 11:24 AM
Yes, I was thinking of the same. But may be he can make use of OnLoad client script, script remains the same. Just that it won't show the update immediately.
however yes before update BR would also work, but it is incidents and it will trigger tooo many times and may not be best for performance impact reasons.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 11:33 AM
Alternative to getting display value instead of sys_id for a reference field in core UI could be to use getDisplayBox() function like so.
var category = g_form.getDispayBox('category').value
But as @Chaitanya ILCR mentioned, the better approach is to go with Before Business Rule if you want the change in Short Description to reflect on all 3 field's change of value.
Regards,
Sangeetha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 07:47 PM
Hi @athavichith
You can make use of g_form.getDisplayBox('your_field_name').value method to get reference field value. Refer below example where I tried getting the value of the Caller field and pushing it to the Description Field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var caller = g_form.getDisplayBox('caller_id').value;
g_form.setValue('description', caller);
}
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.