Can we use update function multiple time in BR ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 09:26 AM
Hello,
I had a requirmeent where i written a customize code and used multiple updates for differnet tables whichis working fine but just want to know is this is a best practise ?
function ba_renderTaskApprovalsMoot() {
current.approval = 'cancelled';
current.update(); // this is to update my current table
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
var qc = gr.addQuery('state', 'requested');
qc.addOrCondition('state', 'not requested');
qc.addOrCondition('state', 'approved');
gr.query();
while (gr.next()) {
gr.state = 'cancelled';
gr.update(); // this is to update my approval table
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 09:31 AM
Hello Shaik,
As a best practice use BEFORE business rule to update the current objects and create an AFTER business rule to update the record in another table.
P.S: Don't use current.update() when before business rule is created.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 09:37 AM
Reference below link for more info.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 09:54 AM
The above code i written on after BR, my concern is just to update the field value on some condition is it required to create an extra BR so thats the reason i just included 1 line code in the existing BR, will that impact in future ???

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 10:42 AM
Hello Shaik,
Go with two business rules to avoid performance issues. Please let me know if you have additional questions.