Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

Avoid dups during manual entry

Sunny14
Tera Contributor

Hello Team,

ServiceNow OOB allows duplicate record while manual entry [by selecting Insert and stay] on Windows Server. 

The IRE works only during importing data.

How do I avoid that? I think I need to write Business Rule on Before Insert but not sure how do I go about it. 

Maybe I need to verify Name, Serial number etc.

Can anyone please help? 

Thanks. 

1 ACCEPTED SOLUTION

abbasshaik4
Tera Sage

Hello @Sunny14,

 

Please refer to the link below:
Solved: How to restrict duplicate records entry in a table... - ServiceNow Community


If it is helpful, please mark it as helpful and accept the correct solution by referring to this solution in the future it will be helpful to them.

 

Thanks & Regards,

Abbas Shaik

View solution in original post

4 REPLIES 4

abbasshaik4
Tera Sage

Hello @Sunny14,

 

Please refer to the link below:
Solved: How to restrict duplicate records entry in a table... - ServiceNow Community


If it is helpful, please mark it as helpful and accept the correct solution by referring to this solution in the future it will be helpful to them.

 

Thanks & Regards,

Abbas Shaik

Ehab Pilloor
Mega Sage

Hi @Sunny14 , 

 

Examine which fields are unique in your case, do a GlideRecord check to see if atleast one record is there and invalidate insert.

 

Sharing a template:

(function executeRule(current, previous /*null when async*/) {

    if (gs.nil(current.name))
        return;

    var gr = new GlideRecord('cmdb_ci_win_server');
    gr.addQuery('name', current.name); // I have used name as unique identifier, if you have serial_number as unique identifier, you can replace name with it in query 
    gr.setLimit(1);
    gr.query();

    if (gr.next()) {
        gs.addErrorMessage('A Windows Server CI with the same Name already exists: ' + current.name);
        current.setAbortAction(true);
    }

})(current, previous);

 

Note that BR will run on import as well.

 

Regards,

Ehab Pilloor

Thank you @Ehab Pilloor  for your response. It was very helpful. 

Hi @Sunny14,

Thanks for marking it as Helpful. Please mark above answer as solution too so that it helps anyone with similar query. 

Regards,

Ehab Pilloor