- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 05:41 AM
Hi there!
I've created a BR in order to update a value from demand tablo to an enhancement table. It's a simple query and no much more...
but for some reason it runs very slow
the business rule is an 'after' type with a particular field change and it should modify a field in another table with the same value so:
(function executeRule(current, previous /*null when async*/) {
// it finds the related enhancement records
var udd = new GlideRecord('rm_enhancement');
udd.addQuery('enhancement', current.sys_id);
udd.query();
// set the due date with the same value
while (udd.next()) {
udd.u_due_date = current.requested_by;
udd.update();
}
})(current, previous);
I tested this BR in PDI and it works fast.
I used the field 'enhancement' because it is the reference field from demand table to enhancement table and because I couldn't find a reference demand field from the enhancement table.
any suggestion?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 07:19 AM
Keep the if condition and update the below query condition
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 05:45 AM
Hi @Leonel Sandroni,
As you are updating the single record right ?
then use the If condition instead of while condition this will fix your issue.
(function executeRule(current, previous /*null when async*/) {
// it finds the related enhancement records
var udd = new GlideRecord('rm_enhancement');
udd.addQuery('enhancement', current.sys_id);
udd.query();
// set the due date with the same value
if (udd.next()) {
udd.u_due_date = current.requested_by;
udd.update();
}
})(current, previous);
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 05:55 AM
I tried with IF instead of WHILE but it doesn't work, the BR does not change the values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 07:19 AM
Keep the if condition and update the below query condition
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 08:29 AM
Ok, in this way, just check and update the only record that I need!!
This is the solution. So...for the next time...When I need to update only one matching record I should use IF inestead WHILE. Thanks!!!