+ Start a Discussion
ministe2003ministe2003 

Apex page messages on standard salesforce pages

Hi all,

Writing some apex which converts an opportunity to another custom object of mine, and it acts upon a button press.  When it fails I want to display page messages to inform the user why it failed.  However, with it being a standard page I dont seem to be able to do it.  In a custom page obviously I'd just stick in the <apex:messages /> tag but with this being the standard Opportunity page, how can I display messages?

 

Thanks!

 

Steven

Best Answer chosen by Admin (Salesforce Developers) 
Ispita_NavatarIspita_Navatar

Try implementing the validation via an apex trigger, add in it the logic to check the validation and in case of the validation failing raise error with add-error method. Please refer the following for reference:-


if(strAcctRecTypeName == 'Limited Partner')            {                if(strPAccRecTypeName != 'Institution')                {                      Trigger.new[0].parentId.addError('A '+strPAccRecTypeName+' cannot be the Parent of a Limited Partner. Please select an Institution instead of a '+strPAccRecTypeName+'.');                }            }


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

All Answers

Ispita_NavatarIspita_Navatar

Try implementing the validation via an apex trigger, add in it the logic to check the validation and in case of the validation failing raise error with add-error method. Please refer the following for reference:-


if(strAcctRecTypeName == 'Limited Partner')            {                if(strPAccRecTypeName != 'Institution')                {                      Trigger.new[0].parentId.addError('A '+strPAccRecTypeName+' cannot be the Parent of a Limited Partner. Please select an Institution instead of a '+strPAccRecTypeName+'.');                }            }


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

This was selected as the best answer
ministe2003ministe2003

addError? does that work differently to the apex page messages?  I might try that in future, for now I just direct the user to another custom page with the error.

 

Thanks

Steven

davcondevdavcondev

What about a success message?

GaryP.ax988GaryP.ax988

 


davcondev wrote:

What about a success message?


 

that is exactly what I am trying to do!! I keep seeing comments about using triggers and error messages but how about just a friendly "request submitted" type of message on a standard saleforce page (one where you can't edit the visualforce code)..     

 

Good luck!

bgoncloudbgoncloud

Hi,

 

Were you able to achieve this? displaying a success message on top of a standard salesforce page?