Business Rule - Help with update script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2024 01:41 AM
Hello,
The following Business Rules should update the short descript with description. Please help review the code. Thanks
Business Rule: After and Update:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2024 02:04 AM - edited 03-30-2024 02:15 AM
Hi @Lisa Goldman ,
What you are missing is > getUniqueValue();
Or simply copy this code inside your business rule ...:
var item = current.getUniqueValue();
var catalogItem = new GlideRecord('sc_cat_item');
catalogItem.addQuery('sys_id', item );
catalogItem.query();
if(catalogItem.next())
{
catalogItem.short_description = current.description;
catalogItem.update();
}
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2024 07:38 AM
Good morning @Sohail Khilji
Thank you for pointed out my mistake. I copied the exactly code you provided and it is still not working. What have I done wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2024 10:36 AM
Hi @Lisa Goldman ,
try this code:
var catalogItem = new GlideRecord('sc_cat_item');
catalogItem.addQuery('sys_id', current.sys_id );
catalogItem.query();
if(catalogItem.next())
{
catalogItem.short_description = current.description;
catalogItem.update();
}
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2024 02:12 AM - edited 03-30-2024 02:22 AM
Hello @Lisa Goldman ,
Can you confirm the table name for the BR?
Try the below code:
(function executeRule(current, previous /*null when async*/ ) {
//Add your code here
var catalogItem = new GlideRecord('sc_cat_item');
if (catalogItem.get('sys_id', current.getUniqueValue())) {
// Update the catalog item
catalogItem.short_description = current.description; // Update with the desired field to be updated
catalogItem.update();
}
})(current, previous);
7 Views