If first name and last name or email address exist in user table the pop up should get display

Mansi roy
Tera Contributor

Hello All,

 

Can anyone please help on the below requirement.

 

I have three variables  in catalog item. First name, last name and email address.

If first name+last name provided in the catalog item if exist int he user table the pop up should get display or else if  email address if exist also in user the pop up should get display.

 

Can anyone please help me on this.

 

 

1 ACCEPTED SOLUTION

@Mansi roy 

you will have to repeat similar script for other variables as well.

yes 1 for first name and 1 for last name

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Mansi roy 

you will have to write 2 onChange catalog client scripts and query sys_user in each of those

what's your actual business requirement here?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

 @Ankur :Hello Ankur I have written one script include.

 

var validateUserDetail = Class.create();
validateUserDetail.prototype = Object.extendsObject(AbstractAjaxProcessor, {
validateUserDetail:function(){
    var currentEmail=this.getParameter('sysparm_email');
    var gr = new GlideRecord('sys_user');
    gr.addQuery('email',currentEmail);
    gr.query();
    if(gr.next())
    {
        return true;

    }
    else{
        return false;
    }
},

    type: 'validateUserDetail'
});
 
Onchange client script:
 
 var fname =g_form.getValue('firstname');
   var lname=g_form.getValue('name');
   var uid = g_form.getValue('user_id');
   var eadd = g_form.getValue('external_mailadress');

   
var userGA = new GlideAjax('validateUserDetail');
userGA.addParam('sysparm_name','validateUserDetail');
userGA.addParam('sysparm_email',newValue);
userGA.getXMLAnswer(result);
function result(answer){
    if(answer=='true')

    {

    alert("ATTENTION: There already exists another active identity with the same first and last name:"+''+eadd+''+uid+
    "If this is the same person, please use the request'Additional Access Rights'"+''+link+
"instead, select 'Different Requirement' in that request and explain your request."+"If it is a different person, the new identity will get an email address with additional number as suffix to the last name.If you have any questions, please contact zentrale_it-koordination@hcob-bank.com.")
    }
 
Do I need to create same for first name and last name? Onchange client will be two one will be for first name and other will be for last name.
 
Please let me know

@Mansi roy 

you will have to repeat similar script for other variables as well.

yes 1 for first name and 1 for last name

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Mansi roy 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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