I am trying to create a permission set in my code but I'm getting some issues when I tried to assign an Idea, Product2 or Pricebook. With some other objects like custom or other Standards, I'm able to do it without any issue.
What is it wrong?
PermissionSet ps = new PermissionSet();
ps.Name='TestPermissionSet';
ps.label='TestPermissionSet';
insert ps;
//insert Object permission for Idea
ObjectPermissions op = new ObjectPermissions();
op.parentId = ps.Id;
op.SobjectType = 'Idea';
op.PermissionsCreate = true;
op.PermissionsRead = true;
insert op;
The error that I'm getting is
System.DMLException: Insert failed.
First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION,
The following permission isn't allowed: Read All Idea: []
Thanks