I am attempting to update FLS using FieldPermission
records for profiles and permission sets. This is working fine for unmanaged
fields, but for managed fields
I am getting an error saying that the field does not belong to the object, when I know it does.
I am building a tool that lets user mass edit FLS across profiles and permission sets and everything works fine for unmanaged fields.
For example, I query this data:
SELECT Id, PermissionsEdit, Field, ParentId, PermissionsRead, SobjectType
FROM FieldPermissions
WHERE Field = 'Account.SBQQ__ContractCoTermination__c'
Which returns some records - here is a record returned for a permission set in the org:
{
"attributes": {
"type": "FieldPermissions",
"url": "/services/data/v46.0/sobjects/FieldPermissions/01k2J00005ITcelQAD"
},
"Id": "01k2J00005ITcelQAD",
"PermissionsEdit": true,
"Field": "Account.SBQQ__ContractCoTermination__c",
"ParentId": "0PS50000000ZpQ0GAK",
"PermissionsRead": true,
"SobjectType": "Account"
}
Then, when I attempt to update this record - for example, sending an update with the following data (or even the same data as Salesforce returned):
{
"Id": "01k2J00005ITcelQAD",
"PermissionsEdit": false,
"PermissionsRead": true,
}
The error response I get is this:
INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST:Cannot find Field Account.SBQQ__ContractCoTermination__c for SobjectType Account:--
I have tried a few variations with the same error each time:
- Insert new record which no existing permissions exist (same error)
- Use the Durable Id format (e.x.
Account.00N50000004RBWE
which produces the identical error) - remove namespace from the field
Account.ContractCoTermination__c
andAccount.SBQQ.ContractCoTermination__c
(I was just trying anything at this point)