You need to sign in to do that
Don't have an account?

Package Install Failed cause by a custom Validation Rule
Hi,
I have a test class that create a new Opportunity to work with. The problem is that some customers have their own validation rules in some of the Opportunity object, and cause the insert fail.
Opportunity newOppty = new Opportunity(StageName='Qualification', Probability=10, Amount=100.00, Type='Existing Customer - Downgrade', LeadSource='Web', IsPrivate=false, Name='John Bess Oppty', ForecastCategoryName='Pipeline', CloseDate=Date.today());
insert newOppty;There is a way to know if there are any validation rule on the opportunity fields before the insert and create a valid Opportunity?? What is the best practice in this case?, because I can't what the users can have differents validations depend of each Org.
Thanks
J.
Any one??
Right now i'm using try catch, but i think there NEED to be a better way to do it .
Opportunity currentOppty;
try {
Opportunity newOppty = new Opportunity(StageName='Qualification', Probability=10, Amount=100.00, Type='Existing Customer - Downgrade', LeadSource='Web', IsPrivate=false, Name='John Bess Oppty', ForecastCategoryName='Pipeline', CloseDate=Date.today());
insert newOppty;
currentOppty = newOppty;
}
catch (Exception e) {
List<Opportunity> opttyList = [select name from Opportunity limit 1];
if (opttyList.size() > 0) {
currentOppty = opttyList[0];
}
}
Thanks in advance!!
J.
Same here. I REALLY need some mechanism like disabling rules on tests or some function that builds a valid opportunity for me. Otherwise I'm lost!
Hope someone can help..
Thanks!
I'm having that same problem. A way around it could be using a custom oppty, but that doesn't apply to our needs.
Anyone knows any work around to disable validation rules?
Thanks!