- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2022 09:00 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2022 02:08 AM
You need to add some query if you want to update existing record.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('u_table_1');
gr.addQuery(); // eg. gr.addQuery('fieldName', 'value');
//gr.addQuery('active', true); // eg
gr.query();
//gr.insert(); // use this line if you want to create new record
while(gr.next()){
gs.log(gr.u_table_2); // here use gr.fieldName
gr.fieldName = 'value';
gr.update(); // to update the record matching your query.
}
})(current, previous);
Note: replace fieldName as per your column/field names in your tables.
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2022 09:07 PM
Hi,
There are two ways to achieve this.
1. Using Business rule
2. Using flow designer.
You can try using After business rule and use script with GlideRecord query to update another record.
Note: As being fresher I would recommend not to request script, first give a try by yourself and share your script. We would be more happy to correct your script.
Happy Learning 🙂
Anil
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2022 01:56 AM
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('u_table_1');
gr.addQuery();
gr.query();
gr.insert();
while(gr.next()){
gs.log(gr.u_table_2);
}
})(current, previous);
is this right or not?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2022 02:08 AM
You need to add some query if you want to update existing record.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('u_table_1');
gr.addQuery(); // eg. gr.addQuery('fieldName', 'value');
//gr.addQuery('active', true); // eg
gr.query();
//gr.insert(); // use this line if you want to create new record
while(gr.next()){
gs.log(gr.u_table_2); // here use gr.fieldName
gr.fieldName = 'value';
gr.update(); // to update the record matching your query.
}
})(current, previous);
Note: replace fieldName as per your column/field names in your tables.
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2022 02:09 AM
You can find some examples on below links:
https://servicenowguru.com/scripting/gliderecord-query-cheat-sheet/
https://www.servicenowelite.com/blog/2019/9/29/gliderecord-scripting
Thanks,
Anil Lande
Thanks
Anil Lande