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
Deepika Gupta 26Deepika Gupta 26 

Validation issue

have a req that when i create new account that is RecordType ="Temporary Account" && Parent Account <> blank or Top Level account <> then make two field read only that is account category and account subcategory.Is it possible via validation rule?if yes,then how please suggest.
Parker EdelmannParker Edelmann
You might be able to use something similar to this:
AND($RecordType.Name = 'Temporary Account',
OR( ISBLANK(ParentId)
    ISPICKVAL( Parent.Type, 'Top Level'),
OR(  ISCHANGED(Account_Category__c),
     ISCHANGED(Account_Subcategory__c)  ))
You'll need to substitute the given fields with the correct API names, with the exception of $RecordType.Name. You most likely will need to change the logic a little to meet your needs. For example, you may need to add the NOT() function somewhere, or change some of the fields I used for others that you want evaluated, but the overall structure is there. If you have any questions, run into errors, or need me to change something, I'd be happy to help further. Otherwise, please let me know in some way that it resolved your problem.

Thanks,
Parker
Deepika Gupta 26Deepika Gupta 26
Thanks Parker.
I have written like this for my case :
AND($RecordType.Name = 'Temporary Account',
OR( 
    NOT(ISBLANK(Parent)),
    NOT(ISBLANK( UltimateParentAccount__c)),
OR(  ISCHANGED(AccountCategory__c),
     ISCHANGED(Account_Subcategory__c) 
 )))
But it showing me the error that Parent field is not found even it is there with the same field name that is becuase of that its data type is Hierarchy so could you please suggest how can i use hierarchy type field in validation rule.
Parker EdelmannParker Edelmann
Try "ParentId". The advanced formula editor is smart and will give you the API names of the fields you need as illustrated by this screenshot:
User-added image
Simply click the insert field button and you can have any field you want. Although the picture is of the Case object, the concept holds true for all objects. Let me know how it works or mark a best answer.

Thanks,
Parker