- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2016 01:11 AM
Hi,
In our instance we are facing issue with duplicate Incident/Change/Problem/sc_task number being created.
We cannot make dictionary unique though we have the script with us to do it and then to remove those before setting number field as unique on task table. Neither we need to correct the old duplicate numbers.
Can anyone help me with a BR on (before insert update)to run globally on all tables only during insert and update so that we can restrict the entry of duplicate records in any table.
ctomasigoswami.sudiptaDeveloper Community
Kind Regards,
Kirtiman
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2016 03:55 AM
It is for a specific table.
you can modify it to global as well
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2016 02:08 AM
below code which i used to prevent duplication
function onBefore(current, previous) {
if (current.operation() == "update") {
checkDuplicateUpdate();
} else {
checkDuplicateInsert();
}
}
function checkDuplicateInsert()
{
if(!gs.nil(current.sys_id))
{
var dup = new GlideRecord("tablename");
dup.addQuery("fieldname", current.value);
dup.addQuery("u_active", 'true');
dup.query();
if (dup.next()) {
gs.addInfoMessage('Already record exists in the table .Check the existing ID ' +routing_id);
current.setAbortAction(true);
}
}
}
function checkDuplicateUpdate()
{
if(!gs.nil(current.sys_id))
{
var dup = new GlideRecord("u_l1_helpdesk_routing");
var dup = new GlideRecord("tablename");
dup.addQuery("fieldname", current.value);
dup.addQuery("u_active", 'true');
dup.addQuery("sys_id" , "!=" , current.sys_id);
dup.query();
if (dup.next()) {
//gs.addInfoMessage('count' +dup.getRowCount());
gs.addInfoMessage('Already record exists in the table .Check the existing ID '+drouting_id);
current.setAbortAction(true);
}
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2016 03:07 AM
Was that a global BR or running on a specific table?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2016 03:55 AM
It is for a specific table.
you can modify it to global as well
Harish