- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 03:28 PM
Can anyone let me know how I can have my after update business rule stop inserting duplicate records into my related list? I just need one record in the related list per user. Here is my business rule:
And here is the issue. This is the related list (duplicates appeared for the other two users as well but I deleted them):
I have a scheduled job that updates "Last reminded" and a few other fields. I run the scheduled job after the Business Rule inserts a record. The job updates the fields it needs to update but then the BR inserts the same user again. How can I stop this from happening?
Solved! Go to Solution.
- Labels:
-
Script Debugger
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 05:38 PM
//See the extra filter in the user exists check
function insertUser(sys_id)
{
var gdt = new GlideDateTime(current.trips_return_date);
gdt.addDaysLocalTime(10);
//Query if there is already a user for this scc with this due date.
var grUser = new GlideRecord('x_g_dnf3_fedsim_scc_ref_list');
grUser.addQuery('user', current.trips_user);
grUser.addQuery('sample', sys_id);
grUser.addQuery('due_date', gdt.getDate()); //check due date
grUser.query();
//insert only if there is not one already
if(!grUser.next()){
var grUserNew = new GlideRecord('x_g_dnf3_fedsim_scc_ref_list');
grUserNew.initialize();
grUserNew.user = current.trips_user;
grUserNew.sample = sys_id;
grUserNew.due_date = gdt.getDate();
grUserNew.insert();
}
}
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 03:56 PM
Can you show the conditions for the BR? It may be that those are at fault.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 04:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 04:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2022 04:35 PM
function insertUser(sys_id)
{
var gdt = new GlideDateTime(current.trips_return_date);
gdt.addDaysLocalTime(10);
//Query if there is already a user for this scc.
var grUser = new GlideRecord('x_g_dnf3_fedsim_scc_ref_list');
grUser.addQuery('user', current.trips_user);
grUser.addQuery('sample', sys_id);
grUser.query();
//insert only if there is not one already
if(!grUser.next()){
var grUserNew = new GlideRecord('x_g_dnf3_fedsim_scc_ref_list');
grUserNew.initialize();
grUserNew.user = current.trips_user;
grUserNew.sample = sys_id;
grUserNew.due_date = gdt.getDate();
grUserNew.insert();
}
}
Vinod Kumar Kachineni
Community Rising Star 2022