Skip to main content
Meenakshi Somasundaram 님이 #Data Management에 질문했습니다
We have a requirement like when users access accounts of another application(accounts are private), they cannot add or edit tasks to these accounts. We want to check if task's associated account recordtype is different, cannot add tasks/update tasks. But validation rule is not working.  Here is example:

 

$User.ProfileId='00e80000001OLz2' 

 

&&  Account.RecordTypeId='012300000004zPxAAI'
답변 1개
  1. 2015년 1월 13일 오후 9:06
    Firstly, you should be creating the Validation Rules on the Task object and not the Account object. The reason behind is that, it is the Task that is getting created and when a Task is created, there are not updates happening on the Account and so a VR on the Account doesn't make any sense.

     

    Here comes the problem: We cannot reference the related Account's Record Type while writing a VR on the Task. The Task object is one of it's kind in Salesforce that can have 'x' of Parent. This means that the Related To field(which is where we actually specify the Account) can take an Account Record, Opportunity, or even Custom Objects. So Salesforce as of now, doesn't allow(or give a way) you to access fields on the records related via Related To or Name fields on the Task.

     

    Now, the only reliable option will be to make use of an Apex Trigger that prevents the creation of the Task. It is very easy especially this one but implementing a Trigger has lot of background procedures to completed and requires you to be on one of the higher edition like that of the EE.

     

    Other possible solutions(only on EE), is to associate the Record Type to that Page Layout which doesn't have the New button on the Activities Related List. Thus Users will not be able to create New Tasks since there is no button. Also, since you cannot even Update Tasks, you might even need to think about removing the entire Activity History/Open Activities Related List OFF from the Page Layout. But remember he or she can still go to the Home tab, click New Task and associate an Account of this invalid Record Type to it. That can be curbed only via an Apex Trigger! 
0/9000