+ Start a Discussion
JustAGirlyGeekJustAGirlyGeek 

Opportunity Trigger

I have been tasked with finding a way to prevent users from moving to 70% or greater probability in an opportunity when Opportunity Products with a certain record type exist. We have valid SAP products and what we call Prospect Products (these shouldn't be allowed in opportunity with 70% or greater probability). We are also thinking of adding a field to the product table for prospect products that are "allowed" so those would obviously need to be excluded from the criteria and will be allowed in the forecast.

 

I know this can be done with Rollup summary fields and validation rules but it's very clunky and not full proof. I am thinking a trigger would be more suitable but I wouldn't even know where to start with my VERY limited code writing capabilities.

 

Anyone willing to take on this challenge? Thanks in advance!

SFAdmin5SFAdmin5

always use a declarative solution over a programmatic one if you can.  if you can accomplish the objective with validation rules and rollup fields (the declarative solution) that is definitely preferable to writing a trigger to solve the problem.  validation rules and fields are easy for even novice admins to troubleshoot and fix.  once code is in production it requires someone with much more experience and skill to maintain over time.  there's nothing clunky about using that declarative solution if it works.

 

that said if you find the declarative solution definitely won't work, then we can help with a trigger, but it sounds from your post that you think validation and rollup fields can do the job.

JustAGirlyGeekJustAGirlyGeek

I understand your concern. After reviewing my issue in more detail, a declarative way will not work for what I need to accomplish. Our users have the ability to create prospect products while adding products to their opportunities. An approved flag will be set after the fact on the product table and I would need a way for that change to be reflected on the opp line item in order for the validation rule to properly work.

 

EDIT: BTW, I've tried setting up the workflow rules, RUS, and validation rules but the approved flag will trip me up. I would still need a trigger to update my opp line items when the flag is activated or deactivated.

SFAdmin5SFAdmin5

ok let me see if i can help you with a trigger

SFAdmin5SFAdmin5

i'm trying to figure out the requirements here.  can you provide an example flow of what exactly you want to happen here?  that would make things easier for me.  thanks

JustAGirlyGeekJustAGirlyGeek

Hi Ross, I got a few examples from posting my question to the Salesforce Stack Exchange. Always good to get multiple opinions since this could probably be written in a few different ways. Have a look and let me know what you think.

 

http://salesforce.stackexchange.com/questions/4225/opportunity-management

 

Thanks for your help!