We are thinking to have a field under Contact Object that counts the number of consecutive won opportunities.

If the Opportunity has the stage "Failure" the counter must be updated to 0 but if it has the stage "Closed Won" the counter must be incremented by 1 until have Failure Stage again.

Has some experienced anything similar to share?

Thank you in advance :-)

  • 1
    How is the Contact related to the Opportunities? Through standard Contact Roles, or through some custom field on the Opportunity object? – Jeremy Nottingham Oct 22 '14 at 12:05

This trigger would probably want to be an after insert/update. Within you would query for the contact based on whatever your logic is. Then based on the sage of the opportunity you update the custom field as you described.

Since there is the chance you will have many opportunities processed at one time, you should be sure to bulkify the trigger. That would likely require maintaining a mapping of opportunity to contact, and then iterating over the map to update the contacts, and updating the contacts in one statement.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.