function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC1adminSFDC1admin 

Opportunity Validation Rule - HELP PLEASE

Hi all - Hope that someone out there can help me with this issue. I just found out from Customer support (after waiting over 5 days for a response to a logged case) that they (basic support) do not help with validation rules - we need premier support (not an option currently with my company). Anyhow - I am rambling - here is my issue:

I am trying to create a validation rule in Opportunities whereby the sales rep must enter a value in the "Sales Interface Order Number" field when the opportunity stage is Closed Won. Because we are integrated with another system, any opportunity created by the Interface or updated by the Interface is not to be held to the rule. I have set up the rule as follows, however when testing it does not run - HELP!

AND(OR(CreatedBy.Alias <> "FChil", LastModifiedBy.Alias <> "FChil"), ISPICKVAL(StageName, "Closed Won"), ISNULL(Sales_Interface_Order_Number__c))
NPMNPM
Is Sales_Interface_Order_Number__c a text field?  If it is ISNULL does not work with Text.  WIth Text to check for null you use the LEN() function
 
LEN(Sales_Interface_Order_Number__c)=0
 
Will check if Sales_Interface_Order_Number__c is null.
SFDC1adminSFDC1admin
It is a text field. You are awesome. I just changed my formula and tested - IT WORKS! Looks like I need to review formulas.

This was so easy and I truly appreciate your quick response to my call for help.

Thank you again.

Linda
SFDC1adminSFDC1admin
You solved my last problem, now I have a new problem with the same validation rule. When using it as previously written, it locked out our "Interface" user from updating records also. So instead of using the Createdbyalias and lastmodifiedbyAlias, I changed it to the following: AND( OR($User.Alias <> "FChil"),  ISPICKVAL(StageName, "Closed Won"), LEN(Sales_Interface_Order_Number__c)=0), Which works and allows our "interface user" to update records.

Here is my problem, I want to also include in my OR statement additional alias' to be able to update opportunities even if there is no Sales Interface Order Number (SION). I had it written as:

AND( OR($User.Alias <> "FChil", $User.Alias <> "LJohn"),  ISPICKVAL(StageName, "Closed Won"), LEN(Sales_Interface_Order_Number__c)=0) and when testing, our Interface user Fchil is no longer able to insert/update records without the SION.

Help please!
NPMNPM

I do not see anything obvious.  Maybe someone else will see the issue. 

Can you paste in the actual code?  It looks like what you have here may be missing a parentheses?

Kent ManningKent Manning
I don't see anything in the way your formula is typed that is wrong, but I'm wondering if your logic within the OR statement is correct?  If the user is "FChil" then your first test within the OR statement is false. However the second test is evaluating to true because  $User.Alias is not equal to  "LJohn", it equal to "FChil"  Therefore the OR statement is evaluating to true, and hence the  entire AND statement is true.  You might try this statement

AND(NOT(OR($user.alias = "FChil", $user.alias = "LJohn")), ISPICKVAL(StageName, "Closed Won"), LEN(Sales_Interface_Order_Number__c)=0)

By adding the NOT ( ) function in front of the OR, you are making the statement false when the user is either "FChil" or "LJohn". Which is what you are trying to acheive.

Hope this helps and gets you going.


SFDC1adminSFDC1admin
Your suggestion/advice worked got the rule up and running before I went on vacation. Thanks for your help!