If condition does not contain is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 12:15 PM
Hi Team
I am using workflow run script to check email variable,
If users enters name instead of @sgis.com then it should check user table else it should continue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 01:09 PM
Hi @AnilM99,
If you want to query the sys_user table using an email address, then change:
getEmail.addQuery('name', current.variables.email);
to
getEmail.addQuery('email', current.variables.email);
As the 'name' field on sys_user table is not an email address.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 04:53 PM
Hi @Bert_c1
thanks for the reply,
my query is if user enter name instead of email, we are checking name in user table and get the user email address.
If user enter email address correctly (eg. anil@sgis.com) we are not checking user table continue the workflow next step
Thanks,
Anil

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 07:25 PM - edited 08-02-2023 07:26 PM
hello there is a error in your script. Also donot use current as a variable in script to gliderecord replace that with ritm or define some other variable
var current = new GlideRecord("sc_req_item");
current.get("71793a9397147110d0d9f0571153af9a");
gs.print(current.variables.email);
if (current.variables.email == ""){
current.variables.email = "anil@sgis.com"
}
else if(current.variables.email.indexOf("@sgis.com") == -1 ){
gs.print("Hello not @sgis.com");
var getEmail = new GlideRecord("sys_user");
getEmial.addActiveQuery(); //getEmail not getemial
getEmail.addQuery('name', current.variables.email); //email is a field where user enters name and email both?
getEmail.query();
if(getEmail.next()){
gs.print("Hello User Found");
current.variables.email = getEmail.email;
}else{
gs.print("Hellow User Not Found");
current.variables.email = "anil@sgis.com";
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 09:05 PM
Hi @AnilM99,
I would suggest to use the Email id validation for email variable. it will avoid the issues, if user enters name.
Updated scripts:
var current = new GlideRecord("sc_req_item");
current.get("71793a9397147110d0d9f0571153af9a");
gs.print(current.variables.email);
if (current.variables.email == "") {
current.variables.email = "anil@sgis.com";
} else if (current.variables.email.toString().indexOf("@sgis.com") == -1) {
gs.print("Hello not @sgis.com");
var getEmail = new GlideRecord("sys_user");
getEmial.addQuery('active=true');
getEmail.addQuery('name', current.variables.email);
getEmail.query();
if (getEmail.next()) {
gs.print("Hello User Found");
current.variables.email = getEmail.email.toString();
} else {
gs.print("Hellow User Not Found");
current.variables.email = "anil@sgis.com";
}
}
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar