+ Start a Discussion
Mauricio OliveiraMauricio Oliveira 

Add Error messages to standard pages

Hi there,

I am trying without success to add an error message to a Standard Contact details page. Is it possible? I have read a few topics which say you can't, others are using webservices or javascript code, but it is not clear to me if it is possible or not.

My context is this: I have a custom button in a Contact details page. What I want to do is to call apex code when pressing that button, which will do some operations (not validation, will actually call external webservices) and I wanted to add either a Success or Error message in the same Contact's page, not to redirect to some other visualforce page or something like that. Sounds pretty simple but my calls do ApexPages.addMessage or contact.addError are not adding anything in the Contact page.

Any help is appreciated.

Thank you in advance.
Best Answer chosen by Mauricio Oliveira
Ravi Dutt SharmaRavi Dutt Sharma
Hey Mauricio,

You can create a visualforce page and place it as an inline VF page on the contact page layout. This VF page will be used to display the outcome of your webservice call. Create a page block section in VF page which will be rendered based on a boolean variable. Control the value of the boolean variable in your code where your are calling the webservice. Hope this helps.

All Answers

Naval Sharma4Naval Sharma4
Hi Maurcio,

This link might be helpful for you.
http://salesforce.stackexchange.com/questions/72608/display-an-error-message-on-standard-page

Let me know if you still needs help.

Thanks,
Naval
Ravi Dutt SharmaRavi Dutt Sharma
Hey Mauricio,

You can create a visualforce page and place it as an inline VF page on the contact page layout. This VF page will be used to display the outcome of your webservice call. Create a page block section in VF page which will be rendered based on a boolean variable. Control the value of the boolean variable in your code where your are calling the webservice. Hope this helps.
This was selected as the best answer
Mauricio OliveiraMauricio Oliveira
Hi Naval,
Thanks for the link, but that approach relies on using javascript alerts to display errors/messages, which I don't want. I'm following this design for button/VF/controller: https://help.salesforce.com/apex/HTViewSolution?id=000175926&language=en_US

Ravi, I will take a look on that approach, thank you for your assistance.
Mauricio OliveiraMauricio Oliveira
Hi eveyrone,

Came back just to update this topic with my final solution.

I ended up by using an inline VF displaying the buttons and webservice calls outcomes. Here is what it looks like:

Inline VF

The first visible line in the VF, "Current status", already makes a webservice call on page load, which will identify if the user is currently registered, active or suspended in my other system. This status will actually control which action buttons are available (Activate or Suspend). When clicking in one of those buttons, apex code will perform more webservice calls, show the results below (success or error) and enable/disable the action buttons again.

I'm satisfied with this solution more than with my initial idea (using custom buttons). So, Ravi, thanks for the tip.

Kind regards.



 
Ravi Dutt SharmaRavi Dutt Sharma
Hey Mauricio,

Please mark it as the best answer if it helped you. Thanks.