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
Chiel de Graaf.Chiel de Graaf. 

Validation rule problem in production

Hi All,

I've got this weird problem in one of my validation rules.
When setup and tested in the full sandbox environment the rule triggers as it should.
When the rule is moved to production the rule fails to trigger.

Here is the rule itself.
 
(RecordType.DeveloperName = "Campaign_Delivery" || 
RecordType.DeveloperName = "Sales_Management" || 
RecordType.DeveloperName = "Year_Deal" || 
RecordType.DeveloperName = "Aanbieding" || 
RecordType.DeveloperName = "Order_Management") && 
(ISCHANGED(StageName)|| ISNEW() ) && 
(ISPICKVAL(PRIORVALUE(StageName ),"Booking") || ISPICKVAL(StageName , "Booking")) && 
OR($UserRole.Name ="Media Sales Manager",
$UserRole.Name ="Media Account Manager",
$UserRole.Name = "Account Management (National)", 
$UserRole.Name = "Head of Aanbieding", 
$UserRole.Name = "Account Management (City)",
$UserRole.Name = "Automotive - Sales Support")

Anyone got an idea what is going wrong?

Regards
Chiel
Akhil AnilAkhil Anil
Hi Chiel,

I would double check whether the RecordType Names are same in the Production as it is in the SandBox. It mostly has to be a data related issue. Cross check the RecordType Names and picklist values with the values that you have in this formula.
Chris Gary CloudPerformerChris Gary CloudPerformer
I would check the Role Names in Production to make sure no one has changed them, and check the StageNames are the same as well.  I also would say to make sure the DeveloperNames of the record Types match between production and Sandbox as well.  I do have one question though - if you are already checking if the record is new OR the StageName has changed, does it matter if the record is not new that the Prior Stage name did not change? (Line 7).
Chiel de Graaf.Chiel de Graaf.
I already checked the names. That shouldn't be the problem. The sandbox is refreshed regurarly so names are always the same.

This morning i changed the logic. I replaced 
OR($UserRole.Name ="Media Sales Manager" , 
$UserRole.Name ="Media Account Manager" ,
$UserRole.Name = "Account Management (National)" , 
$UserRole.Name = "Head of Aanbieding" ,
$UserRole.Name = "Account Management (City)" , 
$UserRole.Name = "Automotive - Sales Support")
with
OR($UserRole.Name ="Media Sales Manager" || 
$UserRole.Name ="Media Account Manager" || 
$UserRole.Name = "Account Management (National)" || 
$UserRole.Name = "Head of Aanbieding" || 
$UserRole.Name = "Account Management (City)" || 
$UserRole.Name = "Automotive - Sales Support")

I will deploy this to production next week and see what happens.

As for line 6, it is put in there so it only fires when that specific field is changed or entered if new.