I want a pop up alert if account create with simillar name?

Deepika61
Tera Contributor

Hi All,

 

Actually i have a requirement that i have Account form, on that name field with string field, so whenever user will create new record if he type similar name which already exist . example  Asian Paints is one account,

1.so if he wants create with same name then it won't submit a record 

2. second senario was " Asian paints" , if he type something simillar like Asian or Paints , then it pop up a alert message saying " already a record exist similar name , do you want proceed?, if he click ok it save otherwise , will update new name

 

Please help me to achieve this

Thanks

Deepika

11 REPLIES 11

@Amit Gujarathi 

Thanks for the resonse

I tried this , form getting saved with that name , it doesnot prevent the submission

Deepika61
Tera Contributor

@Amit Gujarathi @Service_RNow @Sumanth16 @Dr Atul G- LNG 

 

I have written this code 

Script include

var accontnameinfo = Class.create();
accontnameinfo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
accountname: function() {
var input = this.getParameter('sysparm_account');
var userGR = new GlideRecord('customer_account');
userGR.addQuery('name','CONTAINS', input);
userGR.query();
if (userGR.next()) {


return true;

}


},

type: 'accontnameinfo'
});

 

Client Script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

//Type appropriate comment here, and begin script below

var ga = new GlideAjax('accontnameinfo');

ga.addParam('sysparm_name', 'accountname');

ga.addParam('sysparm_account', newValue);

ga.getXMLAnswer(dosomething);

function dosomething(response) {

var answer = response;

if (answer) {

alert(' Account with simillar name already exists, Please create different one');

 

 

}

 

}

}

 

This code working , it check the the simillar name and giving a pop up alert, in this i want add one more thing like if new name exactly same with exist one i need to pop up and clearing the value and making that field mandatory

 

Please help me on this

 

Thanks 

Deepika