I'm attempting to assign a permission set to the automated process user but I'm getting the following error:
System.DmlException: Insert failed. First exception on row 0; first error: TABSET_LIMIT_EXCEEDED, Can't complete this operation because you reached the limit of 0 of standard apps for Automated Process for the Automated Process user license. : []
There's a help article, but we don't have a knowledge tab so this doesn't help.
I've made my permission set is completely empty to eliminate variables.
Permission Set metadata
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<description>My description</description>
<hasActivationRequired>false</hasActivationRequired>
<label>My test permission set</label>
</PermissionSet>
There's a similar question, however the answer there was to use PlatformEventSubscriberConfig instead, which doesn't actually solve this problem.
My code that applies the permission set. I'm running this from the execute anonymous window as system admin, and from a button in a VF page as system admin.
User automatedProcessUser = [SELECT Id FROM User WHERE alias = 'autoproc'];
PermissionSet automatedProcessPermissionSet = [SELECT Id FROM PermissionSet WHERE Name = 'my_permission_set_name'];
List<PermissionSetAssignment> permissionSets = [
SELECT Id
FROM PermissionSetAssignment
WHERE AssigneeId = :automatedProcessUser.Id
AND PermissionSetId = :automatedProcessPermissionSet.Id
];
if(permissionSets.size() == 0) {
insert new PermissionSetAssignment (
AssigneeId = automatedProcessUser.Id,
PermissionSetId = automatedProcessPermissionSet.Id
);
}