When attempting to add all users to a permission set programmatically using the Java SOAP API, I am running into an issue where all of the users are not being added to the permission set. The error message I am getting is:
Can't complete this operation because it would exceed the number of apps allowed by the user license.
And the error code is TABSET_LIMIT_EXCEEDED. I am not sure why the number of apps would cause this issue. When I try adding the users manually, the users are added. It is only when attempting to programmatically add them.
Some details about this permission set is that the only thing it does it only allows Visualforce Page Access to a few of my Visualforce Pages, nothing else. There is nothing related to Work.com or other Assigned Apps relating to this permission set.
Relevant code looks like the following:
String permissionSetId = "MyPermissionSet";
SObject[] userSObjects = getAllUsers();
List<SObject> newSObjects = new ArrayList<>();
for (SObject sObject : userSObjects) {
SObject newSObject = new SObject();
newSObject.setType("PermissionSetAssignment");
newSObject.setSObjectField("AssigneeId", sObject.getId());
newSObject.setSObjectField("PermissionSetId", permissionSetId);
newSObjects.add(newSObject);
}
SObject[] newSObjectsArray = newSObjects.toArray(new SObject[0]);
SaveResult[] saveResults = create(newSObjectsArray);
I've also set the allOrNone header and that has not effect on the results, still giving me this error. For reference, I am trying to add upwards to 200 or more users. Even trying around 2 users does not work programmatically.