The CreatorCon Call for Content is officially open! Get started here.

Apply logic on UI page and Catalog variable

babarat1
Tera Contributor

Hello All,

 

I have a custom UI page which is populated as UI Page variable in a catalog item as shown below

babarat1_0-1678713754693.png

I need help with the below 2 points

 

1.When "OK" button is selected it has to check the email id from the "sys_user" table.

If email id is avaliable it has to redirect to another URL for example "https:dev88888.service-now.com/sp"

 Variable name of UI page with email input is "email_id_uipage".

 

2. If not found ; it has to close and show other variables in the variable set.

Also, it has to take the email id entered in UI Page and set it to another variable from the variable set

 

Example. If "test@123.com" is entered from UI page variable and if email id does not exist in User table (after OK button is submitted) then that value should be passed to another variable "Email" as shown below

 

babarat1_1-1678715525308.png

 

Need help to achieve the above 2 thanks.

 

UI Page 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<div>

<form>
	<label for="uemailid">Email</label>
	<br><input type="text" id="uemailid" name="uemailid"></input></br>
</form>
	
<script>	

</script>

<button onclick="addEmail()">Ok</button>
<button onclick="onCancel()">Cancel</button>
</div>	
</j:jelly>

 

Querying server side with email (I have reference code) but need help on tweaking to satisfy the requirement

 

var gruser_list = new GlideRecord('sys_user');
gruser_list.addQuery('email',email_id_uipage);
gruser_list.query();
var results = [];
if(gruser_list.next())
{
return gruser_list.email;
}

TIA

@Allen Andreas @Ankur Bawiskar @Community Alums @SatyakiBose @priyasunku 

16 REPLIES 16

Ankur Bawiskar
Tera Patron
Tera Patron

@babarat1 

can you share what your business requirement is?

UI page won't work on portal

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, Thanks for the reply.

My business requirement is to have something like below.(sharing image for better understanding)

 

1. When the catalog item is opened it should have email validation at first place (string/any suitable variable type)

babarat1_1-1678773942484.png

 

 

2. We should have a Ok button (or any valid confirmation) in order to start the validation of email. Upon selection it should check the email address from the User table. When any match found it has to redirect to another URL "https:dev88888.service-now.com/sp".

 

3. If a match is not found, it should display other variables from a variable set. like below

babarat1_2-1678774218706.png

I need better idea/suggestion to implement the same.

 

TIA.

 

@Ankur Bawiskar @Allen Andreas 

 

@babarat1 

why not use string variable and have onChange validation on it to check if user is present in user table

OR

why not have a reference variable pointing to sys_user table? not all users may know the exact email address of users in user table

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

String field is ok. How will I validate the email address and show them a pop message saying. Yes, email id found and redirect it to different page.

2. How will show some set of variables if email id is not found. 

Can you please help me with any reference or suggestions please