You need to sign in to do that
Don't have an account?
Ruby Kandah
How do I limit the number of records that can be edited in Salesforce with Validation Rules?
Hi Everyone,
I'm trying to program a validation rule and needed some help. Essentially, I have 3 fields that I would like to incorporate in this rule: Account Type (Picklist field), Deck Rank (Picklist field) and Lead List (Date field).
I want the rule logic to be something like this:
IF Account Type = GM Pick, someone can only change Deck Rank to "Ace of Spades" IF PRIORVALUE of Deck Rank was "Ace" AND there should be no more than 5 Ace of Spades for Lead List = 09/01/2016
Can someone help me translate this to Salesforce language?
Thank you!
I'm trying to program a validation rule and needed some help. Essentially, I have 3 fields that I would like to incorporate in this rule: Account Type (Picklist field), Deck Rank (Picklist field) and Lead List (Date field).
I want the rule logic to be something like this:
IF Account Type = GM Pick, someone can only change Deck Rank to "Ace of Spades" IF PRIORVALUE of Deck Rank was "Ace" AND there should be no more than 5 Ace of Spades for Lead List = 09/01/2016
Can someone help me translate this to Salesforce language?
Thank you!
Looks like you need to include ISPICKVAL for the PRIORVALUE to work... this time I tested on my own org to make sure it works haha. Give this one a try:
AND( ISPICKVAL( Type , "Prospect") , !ISPICKVAL(PRIORVALUE
(DeckRank__c), "Ace"), ISPICKVAL(DeckRank__c, "Ace of Spades"))
Here's the documentation that helped me:
https://help.salesforce.com/htviewhelpdoc?err=1&id=customize_functions_i_z.htm&siteLang=en_US
All Answers
Here's a validation rule you can use to handle the first part of your logic:
AND(AccountType = "GM Pick", PRIORVALUE(DeckRank) <> "Ace", DeckRank = "Ace of Spades")
This basically translates to: If AccountType = GM Pick AND the prior value of DeckRank was not "Ace", then DeckRank cannot be changed to "Ace of Spades". This means that the user cannot change the DeckRank to "Ace of Spades" unless the prior value was equal to "Ace".
You'll probably need a before insert trigger to handle checking for 5 accounts with Lead List = 09/01/2016 and Deck Rank = "Ace of Spades". Let me know if you need help writing that trigger, or if I didn't understand your requirements correctly. I'll be happy to help you walk through it.
This looks great! But I'm getting a syntax error: Error: Field Account_Type__c is a picklist field. Picklist fields are only supported in certain functions.
Oops! I apologize, you need to use ISPICKVAL for picklist fields. it should actually look like this:
AND( ISPICKVAL(AccountType , "GM Pick") , PRIORVALUE(DeckRank) <> "Ace", ISPICKVAL(DeckRank, "Ace of Spades"))
That should work. Let me know if there's any issues!
Error:Ace of Spades ranking can only be designated to accounts having a prior deck rank value of Ace
Looks like you need to include ISPICKVAL for the PRIORVALUE to work... this time I tested on my own org to make sure it works haha. Give this one a try:
AND( ISPICKVAL( Type , "Prospect") , !ISPICKVAL(PRIORVALUE
(DeckRank__c), "Ace"), ISPICKVAL(DeckRank__c, "Ace of Spades"))
Here's the documentation that helped me:
https://help.salesforce.com/htviewhelpdoc?err=1&id=customize_functions_i_z.htm&siteLang=en_US
It worked perfectly :) And thanks for sending me the link to the documentation!
Can you guide me through checking for 5 accounts with a lead list of 09/05/2016? This type of rule would be a huge help!
Ruby
You're very welcome. As for checking for 5 accounts, I believe you will need a before insert, before update trigger.
Hope this helps!
IF(ISPICKVAL( Account_Type__c, "GM Pick") && ISPICKVAL(Deck_Rank__c, "Ace of Spades") && Lead_List__c = THIS MONTH,1,0)
Basically saying that if account type = gm pick, deck rank = ace of spades and lead list = this month, assign a 1, else assign a 0...it works fine, however, i want it to total it based on the account owner -- right now, there isnt a common identifier, like an account owner for it to aggregate the total...do you know how I can aggregate the total based on account owner?
So essentially, if Account Owner = Ruby and account type = gm pick, deck rank = ace of spades and lead list = this month, add all of the records that belong to ruby with these conditions specified together...
If there isn't a good way to write this in a formula field, I can revert to making the trigger :)
Ruby
Unfortunately, you can't look at other account records to aggregate with a formula field. The only other records you can look at are if the account has any related objects. Here's some documentation regarding formula fields:
https://developer.salesforce.com/page/An_Introduction_to_Formulas
Maybe there is another way, but I think making a trigger is easier :)
That code does not look at the account owners. It should be a simple change though, you just need to adjust the query to include the owner field, and look through the list to find accounts with the same owner as the account you're inserting/updating.
Try it out, and let me know if you run into any issues!