• Seba Melgin2323
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi guys,
I'm trying to DELETE a PermissionSetAssignment on an Uninstall class (which implements UninstallHandler). Here is the code:
 
global void onUninstall(UninstallContext ctx) { unassignPermissionSet(ctx.uninstallerId()); }

/**
* @description
* deletes the assignment between current User and the permissionSet.
*/
public static void unassignPermissionSet(Id currentUserId) {
     PermissionSet[] ps = [SELECT Id FROM PermissionSet WHERE Name = :VOIQConstants.PERMISSION_SET_NAME];
     PermissionSet psVOIQPermSet;
     if (ps.size() > 0) {
         psVOIQPermSet = ps.get(0);

         // Assign the current User to Permission Set.
         if (PermissionSetAssignment.sObjectType.getDescribe().isDeletable()) {
             delete [SELECT Id FROM PermissionSetAssignment WHERE PermissionSetId = :psVOIQPermSet.Id];
         }
     }
 }
When I try to uninstall the package (which is a managed package) it throws an error:

Developer script exception (...). : Uninstall : DML operation DELETE not allowed on PermissionSetAssignment

Anyone can help us on it ? The PermissionSet is in the same package we trying to uninstall. Any suggestion to delete the permissionSetAssignment on another event than Uninstall ? (with the same purpose). Thanks !
Hi guys,
I'm trying to DELETE a PermissionSetAssignment on an Uninstall class (which implements UninstallHandler). Here is the code:
 
global void onUninstall(UninstallContext ctx) { unassignPermissionSet(ctx.uninstallerId()); }

/**
* @description
* deletes the assignment between current User and the permissionSet.
*/
public static void unassignPermissionSet(Id currentUserId) {
     PermissionSet[] ps = [SELECT Id FROM PermissionSet WHERE Name = :VOIQConstants.PERMISSION_SET_NAME];
     PermissionSet psVOIQPermSet;
     if (ps.size() > 0) {
         psVOIQPermSet = ps.get(0);

         // Assign the current User to Permission Set.
         if (PermissionSetAssignment.sObjectType.getDescribe().isDeletable()) {
             delete [SELECT Id FROM PermissionSetAssignment WHERE PermissionSetId = :psVOIQPermSet.Id];
         }
     }
 }
When I try to uninstall the package (which is a managed package) it throws an error:

Developer script exception (...). : Uninstall : DML operation DELETE not allowed on PermissionSetAssignment

Anyone can help us on it ? The PermissionSet is in the same package we trying to uninstall. Any suggestion to delete the permissionSetAssignment on another event than Uninstall ? (with the same purpose). Thanks !

Salesforce announced PermissionSet feature in its recent release, and I'm loving it. 

 

The Winter ‘12 Salesforce release has introduced Permission Sets as a new way to manage security within the application. Each user continues to have a Profile, but Permission Sets can now be given to individual users to extend their permissions beyond what is described in their Profile. One of the current limitations is that there is no way to manage assignments of Permission Sets for more than one user at a time, which makes administration tedious.

 

So I'm trying to build visualforce page for a System Administrator to manage (assign and remove) Permission Sets for more than one user at a time i.e., Develop a tool  to assign or remove one or more permission sets to or from one or more users.

 

However, I'm caught with error "Save error: DML not allowed on PermissionSetAssignment" when trying to make INSERT DML call on PermissionSetAssignment object. API version of my apex class is 23.0 and Docs too says that this object is Createable. 

 

What is that I'm missing or is it something not released yet?