The CreatorCon Call for Content is officially open! Get started here.

current.update() vs gr.update() difference

ankit_sharma487
Kilo Guru

                                      current.update() vs gr.update() difference

1 ACCEPTED SOLUTION

Aakash Shah4
Tera Guru

Hi Ankit,



current.update() will act on the current table i.e the table on which the script is running(Server side).



gr.update() will act on the table which you are querying.


For example



var gr = new GlideRecord('incident');



This gr over here is an object of class GlideRecord which is refering the table incident hence gr.update() will update the records on the incident table.



Now if this line is written on a Business Rule which is running on change_Request table


the current.update() will update the records on the change table and gr.update() will update the records on incident table.



I hope this explains the difference.


View solution in original post

4 REPLIES 4

Aakash Shah4
Tera Guru

Hi Ankit,



current.update() will act on the current table i.e the table on which the script is running(Server side).



gr.update() will act on the table which you are querying.


For example



var gr = new GlideRecord('incident');



This gr over here is an object of class GlideRecord which is refering the table incident hence gr.update() will update the records on the incident table.



Now if this line is written on a Business Rule which is running on change_Request table


the current.update() will update the records on the change table and gr.update() will update the records on incident table.



I hope this explains the difference.


Addition to what is mentioned, current.update() should not be used in before Business rule.


Actually it should not be used in any type of business rule.


Here is a nice blog explaining the same


Never use current.update in a Business Rule


Reddy31
Tera Contributor

Current.update() will perform action on the current record... Which triggerd that action.

 

gr.update() will update the record which is assigned to 'gr' object.

For instance... If your are querying a incident or change or any other table and you store the queries record in your 'gr' variable.. that record will be updated.

 

make sure you don't use current.update in query business rule it might create a loop.. at some point if that's necessary make sure you don't trigger other functionalities like br and notifications... You use mention 

SetWorkflow(false);