Saturday, December 31, 2016

Opportunity Contact Roles Validation

When you have a requirement to make sure, when each Opportunity reach certain criteria, Contact Roles is required, but Opportunity Contact Roles is not available in Workflow, Process Builder, and even Apex Trigger directly.

There are a few options to achieve this:
a). Process Builder on Opportunity and call Flow
On Opportunity when Edit, populate Primary Contact Role to a custom field, then use Validation Rule to make sure the opportunity comply with the rule.

b). 3rd party tool such as Roll Up Helper
Similar to above, use Roll Up Helper to populate Primary Contact Role to a custom field, then use Validation Rule to make sure the opportunity comply with the rule.

c). Write trigger on Opportunity
Similar to above, use trigger on Opportunity to populate Primary Contact Role to a custom field, then use Validation Rule to make sure the opportunity comply with the rule.

If you are too lazy to venture for option a and b, and have no developer for option c. Here is the easiest option by installing an unmanaged free app from AppExchange.

After install this app Opportunity Contact Roles Validation, you will find 2 new fields at Opportunity level and 1 validation rule, by default it would be:
AND( Probability > 30, NOT(Primary_Contact_Assigned__c))
change the rule if you would like to check if Probability is beyond 30%
AND( Probability > 0.3, NOT(Primary_Contact_Assigned__c))

Notes:
- You just need to modify the validation rule to follow your business process
- Because the trigger is on Opportunity, not Opportunity Contact Roles, new contact added to Contact Roles will not immediately effect, but when user edit the Opportunity, it will be re-calculate by Trigger.

This app require Enterprise, Unlimited, Performance edition, when I install into a DE, it give me warning that it will not work.


Type: Unmanaged Package; AppExchange

Paid/Free: free

Publisher: Pactera

Installationhttps://appexchange.salesforce.com/listingDetail?listingId=a0N300000025Vs1EAE

Version: 1.0.0


Blog last update: 31 December 2016