- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 10:10 PM
I have a table:'x_snc_aob_test1_request_baseline_input' .There have 3 fields -Account name(reference field) , Onsite/offshore(choice field) , Baseline input (integer field) .All are mandatory. Here an user can not create another record which has same account name and same onsite/offshore of any previously created records.At that time an error message should be shown -"Invalid insert". So ,how to do?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 10:31 PM
If you want to do with BR only then do with before insert
Sample logic:
(function executeRule(current, previous /*null when async*/ ) {
var grP = new GlideRecord("table_name");
grP.addQuery("field_name", current.getValue("field_name"));
grP.addQuery("field_name", current.getValue("field_name"));
grP.query();
if (grP.hasNext()) {
current.setAbortAction(true);
}
})(current, previous);
Hope it helps
Thanks,
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 10:19 PM
Why Business rule, You can do this without scripting
1.) Go to the Field/Dictionary record and check the "Unique" checkbox, It will not allow duplicates
2.) If you're not able to find the "Unique" checkbox, Configure the form layout and get it on the form

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 10:20 PM
I guess he just wants to prevent duplicate on 2 fields out of 3...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 10:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 10:31 PM
If you want to do with BR only then do with before insert
Sample logic:
(function executeRule(current, previous /*null when async*/ ) {
var grP = new GlideRecord("table_name");
grP.addQuery("field_name", current.getValue("field_name"));
grP.addQuery("field_name", current.getValue("field_name"));
grP.query();
if (grP.hasNext()) {
current.setAbortAction(true);
}
})(current, previous);
Hope it helps
Thanks,
Murthy
Murthy