Customize Error Message (to user-friendly message)

  • 1
  • Question
  • Updated 3 years ago
Sorry if this is a duplicate question, but am unable to find a solution on community. I have a Salesforce process builder to add the Task WhoId as a campaign member based on a custom field value. It does not allow users to select the value more than once per Contact (WhoId) if they already belong to the campaign. The error message makes no sense to the users, so I need to customize a system error message.
Is there a simple way or sample of this that does not require heavy coding? -- Thanks for any help!
Photo of TJBuice

TJBuice

  • 414 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
TJ,

I don't think there is any way to change the Apex error message without adding a trigger or custom Apex class.

You may want to use Skuid to adjust what the user can do on the page when the WhoId has already been added to the Campaign.  You could disable or hide the field that allows them to 'add' the WhoId to the Campaign.  This will prevent the error from the process builder.

Thanks,

Bill
Photo of TJBuice

TJBuice

  • 414 Points 250 badge 2x thumb
Interesting. I will do some research on this. Thanks Bill!
It may be over my head as the page is on the Task model and the rendering will have to go through the WhoId and then relate it to an existing Campaign Member on a specific Campaign. Unless I am overthinking it, but guides me in a direction to think it through.
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
TJ,

What I am thinking that you can do is to add a model to your page that does a query on Campaign Member where the ContactId is the WhoId from your task.  If this model is empty, then display your field.

If this is a page that creates a New Task, then you'll need to add a model action to do the Campaign Member lookup when the WhoId changes.

Thanks,

Bill