0

I've added a custom field to Activity object for using it during Task creation/updating from Apex code. By default when I deploy my project through SFDX this field has no FLS settings. In the result I can't use this field in Apex code because I can't check accessibility of this field:

Map<String,Schema.SObjectField> fields = Schema.sObjectType.Task.fields.getMap();
if (fields.get('CallId__c').getDescribe().isAccessible()) {
    // use field task.CallId__c
}

Now I want to include to my managed package ability to turn on visibility of this field for all profiles. There is best practice for such deployment? On the other hand, perhaps my approach not right and I should walk another way for including FLS for field in my managed package?

1 Answer 1

1

There are two ways by which you can give field permission to profiles

  1. At the time of installation of package you can choose whether you want to give permissions to Admin profile or you want to choose All profiles. If you choose all profiles here then permission of custom field will be assigned to all the profiles.

  2. Now in case if you want to control field permission after installing the package you can package a permission set which will be assigned to users after package installation as per need. Now if there are lots of users then you can create a page through which you can assign that permission set to all users.

1
  • Thank you so much, @Mr.Frodo! Btw, perhaps, you can answer here on connected off-topic question: sObject Task contains WhoId field which I can fill when create the new Task, but in Schema.sObjectType.Task.fields this field is missed and I cannot check it accessibility. How I can check FLS for Task.WhoId field?
    – SlavaHq
    Mar 12, 2020 at 8:21

You must log in to answer this question.

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