- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 05:18 AM
I have synced azure ad to servicenow. Now i need to get the list of users present in servicenow. How can this be done using client script?
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 01:01 PM
yes in servicenow when you create a variable there are different variable types. One is a String type which you are probably using. You can create a reference type and that should do what you are explaining above ^.
This is what it will look like on the form
if they enter a name that is not in the user table this happens...
I believe this is what you are looking for. No need to customize this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 06:26 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(!(/^[a-zA-Z\s]*$/g.test(newValue))==false){
alert(newValue);
var test="vig";
var decide="fsf";
var gr = new GlideRecord('sys_user');
gr.query("user_name");
while(gr.next()) {
var dbname=gr.name;
if(dbname==newValue){
decide="worked";
break;
}}
if(decide!="worked"){
g_form.setValue('username','');
alert("User not present in DB");
}
}
else{
g_form.setValue('username','');
alert("Only letters are allowed");
}
}
Thsi has worked for me.. Thanks all for the reply

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 06:33 AM
Mark ANSWER AS CORRECT For closing this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 07:09 AM
I am not sure what your form is for or what the logic is exactly for. but if you created a mandatory reference field to the user table. if the user submitting the form it already has the logic in place to look up and see what is in the database and too see if they spelled someone's name correctly and also reference that user record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 09:53 AM
Hi Nathan
I have created input text box which takes a username,(should not accept any other characters/numbers) in azure vm template.Here when user inputs a name it should be validated with the names present in user table.So I am checking username entered against the name coming from user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 01:01 PM
yes in servicenow when you create a variable there are different variable types. One is a String type which you are probably using. You can create a reference type and that should do what you are explaining above ^.
This is what it will look like on the form
if they enter a name that is not in the user table this happens...
I believe this is what you are looking for. No need to customize this