0

I am working on a validation formula where I need to check if the Approval Officer's value is 005f4y78378u8373. If it is, I will then check if the product falls into any of the following categories: cosmetics, camera, laptop, mobile. If it does, I need to verify if the amount is greater than 10000. If it is, I should display a validation message. Additionally, if the product is a bike and the amount is greater than 6000, I should display the validation message as well, and so forth. However, my formula is not working correctly. Can someone please help me identify where I went wrong or if there is a problem with my logic?

If the conditions are true, I should see a validation message stating that the product exceeds your approval limit. However, currently, my formula is not functioning correctly. If my approval officer is 005f4y78378u8373 and my product is Special with an amount greater than 3000, the system should display a validation message. However, this is not happening currently.

IF(
    AND(
        Approval_Officer__c = "005f4y78378u8373",
        OR(
            AND(
                Amount__c > 1000,
                OR(
                    ISPICKVAL(Product__c, "Cosmetics"),
                    ISPICKVAL(Product__c, "Camera"),
                    ISPICKVAL(Product__c, "Laptop"),
                    ISPICKVAL(Product__c, "Mobile")
                )
            ),
            AND(
                Amount__c > 6000,
                ISPICKVAL(Product__c, "Bike")
            ),
            AND(
                Amount__c > 7500,
                OR(
                    ISPICKVAL(Product__c, "FAN"),
                    ISPICKVAL(Product__c, "WATCH"),
                    ISPICKVAL(Product__c, "BED"),
                    ISPICKVAL(Product__c, "MEDICINE"),
                    ISPICKVAL(Product__c, "TV")
                )
            ),
            AND(
                Amount__c <= 3000,
                ISPICKVAL(Product__c, "Special")
            ),
            AND(
                Amount__c > 5000,
                ISPICKVAL(Product__c, "Special_product")
            )
        )
    ),
    false,
    true
)
3
  • Thanks for posting your question. To help identify you however you need to add some details about what you're expecting to happen, what is happening and what you've tried already. As an aside, you should never use a hard coded record id in this way as your validation rule will need to be updated in each environment or if the user every changes. May 11, 2023 at 4:37
  • I have added the detail. May 11, 2023 at 4:47
  • 1
    Again, please stop adding random tags to your questions.
    – Derek F
    May 11, 2023 at 11:53

1 Answer 1

0

The specific situation you've detailed in your question is because the operator is the wrong way around for the amount when the product is 'Special'. This should be Amount__c >= 3000 if it should be fired when the amount is more than 3000.

Also, validation rules are fired when the formula evaluates to true, so you need to switch the true and false around and the end of your formula.

3
  • I have attempted to implement the suggested formula, but the validation rule is not being triggered, and the record is still being saved. May 11, 2023 at 4:59
  • Sorry just realised that your true and false are around the wrong way too. Have updated the answer. Were you getting this validation rule firing in the opposite scenario? May 11, 2023 at 5:05
  • I tried changing the scenario, still instead of firing the validation record is getting saved. May 11, 2023 at 5:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .