Find your content:

Search form

You are here

Approval process with AND( OR() ) doesn't seem require all

 
Share

I thought that should be able to wrap a bunch OR conditions with an AND that would require TRUE from each OR such as this.

AND(OR(ISPICKVAL(Apttus_Proposal__Opportunity__r.Sales_Typ__c, "New"),
ISPICKVAL(Apttus_Proposal__Opportunity__r.Sales_Typ__c, "Migration")), 
Apts_Rollup_Net_Price_11__c >= 4000, Total_Adjustment_Percentage__c > 0)

or this

AND(OR(ISPICKVAL(Apttus_Proposal__Opportunity__r.Sales_Typ__c, "New"),
ISPICKVAL(Apttus_Proposal__Opportunity__r.Sales_Typ__c, "Migration")),
OR(Apts_Rollup_Net_Price_11__c >= 4000), OR(Total_Adjustment_Percentage__c > 0))

but neither seem to work.

thanks for any suggestions.


Attribution to: Miklr

Possible Suggestion/Solution #1

For problems like these, I like to back up and do the following:

  1. Check each condition individually to isolate the problem
    1. Check the ISPICKVAL literals for typos
    2. Double-check the comparisons to make sure I didn't reverse the greater-than/less-than signs
  2. Re-format the expression, providing indentation to help see the blocks grouped together
  3. Write the requirement in words, then pseudo-code, then work through the expression with pen and paper to verify I haven't made a logic error

Attribution to: Mike Chale

Possible Suggestion/Solution #2

Try using && and || in place of AND and OR. It makes it much more readable and you may pinpoint your mistake. I've done that with your first formula. The second one doesn't make sense as your ORs wrap only one condition.

(ISPICKVAL(Apttus_Proposal_Opportunity_r.Sales_Typ__c, "New") || ISPICKVAL(Apttus_Proposal_Opportunity_r.Sales_Typ__c, "Migration")) && Apts_Rollup_Net_Price_11__c >= 4000 && Total_Adjustment_Percentage__c > 0

In pseudo code, you'd read it as Mike stated in his comment: (Sales Type is New or Migration) AND (Net price is more than or equal to 4000) AND (the percentage is more than 0)


Attribution to: Daniel Hoechst

Possible Suggestion/Solution #3

The logic is slightly flawed, I've layed out your first one, with indentation, which makes it clearer what is happening.

AND(
    OR(
        ISPICKVAL(Apttus_Proposal_Opportunity_r.Sales_Typ__c, "New"),
        ISPICKVAL(Apttus_Proposal_Opportunity_r.Sales_Typ__c, "Migration")
    ), 
    Apts_Rollup_Net_Price_11__c >= 4000,
    Total_Adjustment_Percentage__c > 0
)

I'd recommend laying out your code similarly so you can see clearly what is happening.

In this instance it will only return true if the OR, and the check on Apts_Rollup_Net_Price_11__c and Total_Adjustment_Percentage__c all return true. If you can clarify what exactly you want to test for we can probably give you the code you need, but with a neater layout it'll likely help you get there yourself.


Attribution to: David Gillen

Possible Suggestion/Solution #4

The following finally worked for me:

AND(OR(INCLUDES(Apttus_Proposal__Opportunity__r.Product__c, "HEHR"), INCLUDES(Apttus_Proposal__Opportunity__r.Product__c, "HPM")), OR(ISPICKVAL(Apttus_Proposal__Opportunity__r.Sales_Typ__c, "New"), ISPICKVAL(Apttus_Proposal__Opportunity__r.Sales_Typ__c, "Migration")), Total_Initial_Fees__c >= 4000, Total_Adjustment_Percentage__c > 0)

And in pseudo code it would be: Product is 'HEHR' OR 'HPM', AND Sales type is 'New' OR 'Migration', AND total fees are greater than 4000, AND Total Adjustment Percentage is greater than 0

I then verified it worked against each condition, by testing on a mock proposal and submitting for approval thanks for everyones feedback.


Attribution to: Miklr
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/315

My Block Status

My Block Content