
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 05:18 AM
I'm having two tables table1 and table2, I have written script for insertion of record once I insert record in table1 automatically in table2 record should be create here is my script
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 05:25 AM
@Community Alums Here is how you should write your script.
var gr = new GlideRecord("u_mytable");
gr.addQuery('u_name',"abraham.lincoln");
if(gr.next()){
var grc = new GlideRecord("u_mytablecopy");
grc.addQuery('u_name',gr.getValue('u_name'));
if(grc.next()){
grc.delete();
}
gr.delete()
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 05:31 AM
Hi @Community Alums ,
Please use gr.initialize() when your inserting the new record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 05:24 AM
Actually I want to delete that record using background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 05:25 AM
Hi @Community Alums
Do you want script for Business Rules?
There should be some reference field on Table 2 referring to the record in Table 1 for better management.
You might need to create 3 BRs, After - Insert, After - Update and Before - Delete on table 1. Please let me know if you want script for all the three BRs.
Anvesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 05:35 AM
Hello Anvnesh,
Im really greatful if you could provide me that code.
Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 05:25 AM
@Community Alums Here is how you should write your script.
var gr = new GlideRecord("u_mytable");
gr.addQuery('u_name',"abraham.lincoln");
if(gr.next()){
var grc = new GlideRecord("u_mytablecopy");
grc.addQuery('u_name',gr.getValue('u_name'));
if(grc.next()){
grc.delete();
}
gr.delete()
}
Hope this helps.