
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 10:33 PM
Hi,
I'm needing to do a check on a catalog item as it is being filled in.
I have a text field called:
group_name
What I want to do is after the field is filled in have it check the sys_user_group to see if a group name already exists that is the same.
I was thinking that I'd be able to do it via an onchange client script, but can't seem to get that to work.
Ultimately I want a message to come up advising that the name is already being used if it is found and to just let the person carry on if it is not found.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 11:26 PM
it means the value is not getting passed
Also I have updated the client script line as this
if(answer.toString() == 'true'){
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 10:19 PM
you copied wrong script include name
the name should be checkRecords
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 10:24 PM
Ok thanks - updated and tried again.
No error this time, but also no result as such.
I entered a name that I know was not an active group name and also one that I no is an active group name.
No messages came up and the log showed the same for both tries:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 10:48 PM
the name came undefined in function?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 11:04 PM
Yes it is getting an undefined value
It's what is added to the log because of the gs.info()
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRecordPresent: function(){
var name = this.getParameter('sysparm_groupName');
var gr = new GlideRecord('sys_user_group');
gr.addQuery('name', name);
gr.setLimit(1);
gr.query();
gs.info();
return gr.hasNext();
},
type: 'checkRecords'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 11:06 PM
Either way there is no message coming up if I add a group name that I know exists already and is active