Need a pop up alert when we create a account with same or simillar name?

Ramu6
Tera Contributor

Hi All,

 

I have requirement that  we have an accounts, when the Accounts team wants to create new account , then on the new form if they enter name which already created and trying to save form then there alert or validation should be there , this name already exist 

Ramu6_0-1708409882506.png

 

Please help me sort out this

 

Thanks 

Ram

9 REPLIES 9

@Sohail Khilji 

Thanks for code

But actually it needs on the Account table not user table, On Account form we have name field, for that i need to check

 

in the code just replace the sys_user table with your table name... its simple


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

@Sohail Khilji 

I have tried this code , but it not stop the saving the form, Record gets created with that name 

Service_RNow
Mega Sage

Hi @Ramu6 

you should write before insert business rule on the custom table and then query the table.

Note: Ensure you give correct field names here

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord(current.getTableName());
	gr.addQuery("u_account", current.u_account); // give correct field name
	gr.addQuery("u_trouble_type", current.u_trouble_type); // give correct field name
	gr.addQuery("u_assignment_group", current.u_assignment_group); // give correct field name
	gr.setLimit(1);
	gr.query();
	if (gr.hasNext()) {
		gs.addErrorMessage("This is a duplicate record");
		current.setAbortAction(true);
	}

})(current, previous);

Please mark reply as Helpful/Correct, if applicable. Thanks!

@Service_RNow 

Thanks for the code

Basically here "name field" on the account table was not reference field , its text field

And basically here two things

1. if user enters same name when he create new account it should not allow him and need display error message?

2.If user enter simillar name like example " Indian Times" is one of the existing account so if user try to create simmilar like "Indian " or type "Times" then its needs to alert a pop up saying , "there already simillar name exist, do you want to continue ?, if click ok then save the form or he need to able to change

 

Thanks

Ram