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
SFDC Apex DevSFDC Apex Dev 

Hi!!! Created a validation rule but not working fine..

Created two field (data type-picklist) on the opportunity and have to make the fields mandatory when the Sales Occupy = Field Sales AND the stage is advancing beyond Stage 2, then these 2 fields mandatory.

I tried below... but not working....Could you please correct me??

AND ( NOT ( ISPICKVAL ( StageName,  '2. Discover' )  )  ),
 ISPICKVAL(Sales__c, 'Field Sales'), ISBLANK ( TEXT ( Fin_Se__c ) ) || ISBLANK ( TEXT ( Fin_Se_Type__c ) ) )
Raj VakatiRaj Vakati
try this
 
AND ( NOT ( ISPICKVAL ( StageName,  '2. Discover' )  )  ),
 ISPICKVAL(Sales__c, 'Field Sales'), ISBLANK ( TEXT ( Fin_Se__c ) ) || ISBLANK ( TEXT ( Fin_Se_Type__c ) ) )

 
SFDC Apex DevSFDC Apex Dev
Hi Raj,

I didn't find any difference in mine and yours...validation rule..
Raj VakatiRaj Vakati
Its with OR condition. Can you explain details i will write the validation for you  
SFDC Apex DevSFDC Apex Dev
Hi Raj, 

I have written below one.. which is working fine now.. but it is working for all record type.. i need for only one... Could you please help into that.. that i was not able to do..
AND ( NOT ( ISPICKVAL ( StageName,  '2. Discover' )  )  ||  ISPICKVAL(Sales__c, 'Field Sales' ) ),
 ISBLANK ( TEXT ( Fin_Se__c ) ) || ISBLANK ( TEXT ( Fin_Se_Type__c ) ) )
Raj VakatiRaj Vakati
Use this one and change the record type name
 
AND ( NOT ( ISPICKVAL ( StageName,  '2. Discover' )  )  ||  ISPICKVAL(Sales__c, 'Field Sales' ) ),
$RecordType.Name = "The RecType Name", 
 ISBLANK ( TEXT ( Fin_Se__c ) ) || ISBLANK ( TEXT ( Fin_Se_Type__c ) ) )

 
SFDC Apex DevSFDC Apex Dev
Will this help.... if profile is data loader it should not fire for this profile and only fire for the given record type id???

AND ( NOT ( ISPICKVAL ( StageName, '2. Discover' ) ) || ISPICKVAL(Sales__c, 'Field Sales' ) ),
( $Profile.Name <> "Data Loader" && RecordTypeId = "0121E000000MA76" ), ISBLANK ( TEXT ( Fin_Se__c ) ) || ISBLANK ( TEXT ( Fin_Se_Type__c ) ) )
Raj VakatiRaj Vakati
Dnt use the record id .. use name becase id is changes from org to org


Use this .. its well aligned
 
AND (
OR( NOT ( ISPICKVAL ( StageName, '2. Discover' ) ) , ISPICKVAL(Sales__c, 'Field Sales' ) ),
OR( $Profile.Name <> "Data Loader" && RecordTypeId = "0121E000000MA76" ),
OR( ISBLANK ( TEXT ( Fin_Se__c ) ) , ISBLANK ( TEXT ( Fin_Se_Type__c ) ) )
)

 
Raj VakatiRaj Vakati
Is its working ?
SFDC Apex DevSFDC Apex Dev

Hi Raj,

Mine one is working fine..

Thanks for your help.. :)