- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 11:55 AM
We have users that are constantly adding New CIs/Phone Numbers and having an issue with duplicate phone #s being added because those are simply not being checked consistenly to see if it already exists. What is the best way to prevent this creation of duplicate phone#s? Business rule, etc? We are looking more in the lines of having a flag or something where once the # is saved, it prompts that "this # already exists" and denies the creation of the new #.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2017 11:45 PM
Hi Eddie,
Sorry, it is supposed to be gs.addErrorMessage() and not current.addErrorMessage().
Here is the complete script:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('u_phone_numbers');
gr.addQuery('name',current.name);
gr.addQuery('u_switch',current.u_switch);
gr.query();
if(gr.next()) {
gs.addErrorMessage("The phone number on the selected switch is already in use");
current.setAbortAction(true);
}
})(current, previous);
I hope this gets you what you need.
/Lasse
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2017 11:16 PM
No problem. Let me know if you run into any issues 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2017 09:27 AM
Hi Lasse,
I entered the new code but I am still having a couple errors (excuse my "rookie" skills☺). I also forgot one criteria of this that makes it a little more difficult. Let me explain:
So below is the form for our Phone Numbers. The Phone number itself is not unique because we have several 3 digit extensions that are the same. Although, these 3s are the same, the unique 1-1 is extensions with the respective switch. For example, there could be a 3 digit extension "222". We copuld have two extensions: 222 @ Switch "El Paso Avaya CM" & 222 @ Switch "Lubbock Avaya CM". So in this case, we need to have a query that looks at the "phone #" with its respective "switch".
Here is the "phone number" label:
Here is the "switch" label:
Here is the error I am getting with the code I have so far:
Please advise…
Thanks Lasse!
Eddie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2017 10:24 PM
Hi Eddie,
The script error is my bad. The "New" should have been "new". Sorry about that.
Based on your screenshots I modified the script so that it will take both the switch (u_switch) and the number (name) into consideration:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('u_phone_numbers');
gr.addQuery('name',current.name);
gr.addQuery('u_switch',current.u_switch);
gr.query();
if(gr.next()) {
current.setAbortAction(true);
current.addErrorMessage("The phone number on the selected switch is already in use");
}
})(current, previous);
I hope this helps.
/Lasse
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 05:33 PM
Awesome...I will give it a go and see what happens. I really appreciate you lasse!
Thanks!
Eddie
Sent from my Sprint Samsung Galaxy S ® 6 edge.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 09:15 AM
Hi Lasse,
I tried the new code and the duplicate restriction seems to be working by giving me an "invalid insert" flag when I tried to test a dupe # with the same switch. I did not get the error message though. Just to validate, is the "invalid insert" flag what is expected?
Thanks,
Eddie