- 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:33 AM
Thank you. It's working.
- 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:33 AM - edited 09-27-2023 05:35 AM
Hi @Community Alums ,
For deletion you can write before delete BR on table 1 record when deleted.
var grc = new GlideRecord("u_mytablecopy");
grc.addQuery("u_name", current.u_name);//take unique field in table 1 to match with table 2
grc.query();
if (grc.next()) {
grc.deleteRecord();
}
For insertion you can write after BR on table 1 record when inserted.
var grc = new GlideRecord("u_mytablecopy");
grc.initlize()
grc.u_name = current.u_name;
grc.u_mobile_number = current.u_mobile_number;
grc.insert();
Please mark helpful if it works.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 05:48 AM
Writing code without having a clear design or even a well defined requirement will get you nowhere. Moreover, background scripts are only suitable for a very limited number of uses cases. Most of the time, there is a better alternative.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2023 01:12 PM
A "background script" typically refers to a script or program that runs in the background of a computer or system, performing tasks without a user interface or direct interaction. Background scripts are often used for automation, system maintenance, data processing, or other tasks roofing companies Auburn AL that don't require user intervention. Here's a simple example of a background script in Python that periodically prints a message:
In this example, the script defines a function background_task that runs indefinitely, printing a message every 5 seconds. This script can be executed in the background, and the user won't interact with it directly.
Keep in mind that more complex background scripts can perform tasks like data analysis, file processing, server maintenance, and much more. The key is that they operate independently, often without a graphical user interface, to carry out specific functions........