+ Start a Discussion
LavanyaLavanya 

How to display error message to user about record already exisis.

Hi i am having a custom button "convert" once i click convert if the record exists it must must show that the account already exists. This convert button is similar as lead convert button.

Thanks ,

Regards,

Lavanya.

 

Achilles21Achilles21

You can write a before insert trigger on your object. You can get the value of the Account field selected/entered by the user and compare it with a value that you'd fetch using an SOQL on Account.

 

You can then display your message using addError method when the query doesnot return Null.

Bhawani SharmaBhawani Sharma

<apex:PageMessage summary="Your Error Message " Severity="ERROR" strength="3" rendered="{!(leadObj.Converted__c)}" />

 

Add this on your page.

Raj.ax1558Raj.ax1558

Hi,

 

In that case you need to write a trigger on object that you useing and action is Before update. 

Suppose, in lead conversion you can write trigger on lead update. 

 

In that trigger you can write your logic for checking records that is already exist or not. If exist then write addError() methord on a particular field. 

 


Click on KUDOS button if the post helps you! marked as solution for others users help in a same query.

 

Thank You,

Raj Jha