- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 09:33 AM
in location table whenever adding location filed value manually if that location is already existed then it show message that already existed that location & show invalid insert , this is what show if location is already existed in location table(cmn_location).
kindly help me with your suggestion how can i write business rule for that.
Thanks
Divya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 09:39 AM
use below script in on before BR on Insert
var target = new GlideRecord('cmn_location');
target.addQuery('name', current.name);
target.query(); // Issue the query to the database to get relevant records
if (target.next()) {
// add code here to process the incident record
gs.addErrorMessage("Location Name already exists.");
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 10:49 AM
Thank you Srnewbie for your response, code is working fine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 09:40 AM
Hi Divya,
You can achieve this oob by updating the unique flag on the name field.
OR
Write an onbefore insert business rule on location table for validation.
var gr = new GlideRecord('cmn_location')
gr.addEncodedQuery('name='+current.name);
gr.query()
if(gr.next()){
gs.addInfoMessage('YOUR MESSAGE HERE');
current.setAbortAction(true);
}
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2017 09:45 AM