Prevent Duplicate values for Responsibilties
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 04:20 AM
Hi Team,
I have a requirement wherein I need to make sure that contact Relationship table if already have any of the mentioned responsibilities , it should not get readded.
Suppose now I create a new record with Contact Relationship with responsibility as "Billing Contact" and "XYZ", the BR is not working, its allowing to create the record.
I have written Before Insert BR as follows on sn_customerservice_contact_relationship table:
var gr = new GlideRecord("sn_customerservice_contact_relationship");
gr.addQuery('company', current.company);
gr.addQuery('u_authority_role', current.u_authority_role);
gr.addQuery('contact', current.contact);
gr.query();
if (gr.next()) {
var authroles = current.getDisplayValue('u_authority_role');
var autrole = authroles.split(',');
for (var i = 0; i < autrole.length; i++) {
var role = gr.u_authority_role.getDisplayValue();
if (role.indexOf(autrole[i]) != -1) {
gs.addErrorMessage('This contact already has a contact relationship established with this account. For any changes, please edit the existing record.');
current.setAbortAction(true);
}
}
}
1 REPLY 1
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 05:20 AM
Hi All,
This is fixed. I needed to remove the line //gr.addQuery('u_authority_role', current.u_authority_role);