- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 08:18 AM
Hey guys!
As the title implies, I need help with copying the short_description of the parent (cmdb_ci_service) business service and fill in the same information in the child service offering (service_offering) field called short_description.
This is my Business Rule which is not working:
(function executeRule(current, previous /*null when async*/) {
// Skapa en GlideRecord för att hämta värdet från huvudärendet
var parentRecord = new GlideRecord('cmdb_ci_service');
if (parentRecord.get(current.parent)) {
// Kopiera värdet från huvudärendets short_description till barnets short_description
current.short_description = parentRecord.short_description;
}
})(current, previous);
What am I doing wrong?
Thanks in advance guys!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 07:37 PM
That's correct a business rule will only work when you update the form
If you want to see the field with real-time data being fetched then you can use onLoad client script + GlideAjax
OR Another way
you can use display business rule on service_offering table
Script:
current.short_description = current.parent.short_description;
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
04-28-2025 08:31 AM
script looks fine
is it going inside the IF?
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
04-28-2025 12:26 PM - edited 04-28-2025 02:15 PM
@Ankur Bawiskar This is what the whole script looks like. It's just not working. Keep in mind that the short_description field in the parent is not the same as the short_description field in the child, even though they have the same name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 03:06 PM
@Ankur Bawiskar never mind! It works after updating/saving the form. I think a client script with glideAjax might be a better solution for direct copying, right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2025 07:37 PM
That's correct a business rule will only work when you update the form
If you want to see the field with real-time data being fetched then you can use onLoad client script + GlideAjax
OR Another way
you can use display business rule on service_offering table
Script:
current.short_description = current.parent.short_description;
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