0

I'm new to Salesforce and I have to allow edit permission to some fields only if they are blank. Otherwise they shouldn't be editable. My validation rule look like this for the moment, I'm a bit stuck. Probably I have to include ISCHANGED as well, but don't know exactly how

AND($Setup.Application_Control__c.Run_Validation_Rules__c = TRUE,
AND(NOT(ISBLANK(dfsle__CanManageAccount__c)  || ISBLANK(status)  || ISBLANK(username) )))

1 Answer 1

3

You can use

AND( 
    ISCHANGED(field__c), 
    NOT( ISBLANK( PRIORVALUE(field__c) ) ) 
)

The Idea is to check the previous value of the field and fire validation rule

https://help.salesforce.com/s/articleView?id=sf.customize_functions_priorvalue.htm&type=5

https://help.salesforce.com/s/articleView?id=sf.customize_functions_ischanged.htm&type=5

Thanks

10
  • I try it, but somehow I still can edit the field when there is already a value Commented Oct 17, 2022 at 14:01
  • Hi Livia, have you changed the field__c to your field. Could you please show your Updated Validation Rule
    – Pavlo M
    Commented Oct 17, 2022 at 14:37
  • 1
    This is a custom setting to toggle rules on and off declaratively. $Setup.Application_Control__c.Run_Validation_Rules__c = TRUE, We use this to allow admins to get around validations and I'm assuming you're doing the same thing. It sounds like you're flagged as run validations = false at the user or profile level and it's not firing. Commented Oct 17, 2022 at 14:37
  • 1. Please remove $Setup.Application_Control__c.Run_Validation_Rules__c = TRUE this part and check that rule works for all users as expected. 2. please check values .Application_Control__c.Run_Validation_Rules__c and add this to rule
    – Pavlo M
    Commented Oct 17, 2022 at 14:40
  • Hi! So I have this 4 fields. If one is blank you could edit it. This is how my VR looking now AND(ISCHANGED(dfsle__CanManageAccount__c), dfsle__CanManageAccount__c= FALSE, OR (ISCHANGED(dfsle__Username__c), ISBLANK(PRIORVALUE(dfsle__Username__c) ) ), OR (ISCHANGED(dfsle__Provisioned__c), ISBLANK( PRIORVALUE(dfsle__Provisioned__c) ) ), OR (ISCHANGED(dfsle__Status__c), ISPICKVAL(dfsle__Status__c, "") ) ) (The first field is a checkbox, and the last one is a picklist) Commented Oct 18, 2022 at 8:40

You must log in to answer this question.

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