Apex to Assign Skuid License and Permission Set

  • 1
  • Question
  • Updated 2 years ago
  • Answered
We use Skuid to build an application review process in a public-facing Portal (someday we'll grow up and be big boys and girls in SF Communities -- we're not there yet). We seem not to be the only ones who find that Skuid's auto-assignment of licenses and Page View Permissions isn't effective for high volume SF licenses associates with portals and communities (e.g. Overage High Volume Customer Portal). Auto-assignment works fine for other SF licenses (internal staff), but not for external users.

So I've been approaching this from the apex side and nearly have a solution -- I think the only thing getting in our way is our complicated coding environment tripping up my unit testing. But I'm not sure. Has anyone else taken this approach?

//For Skuid only, adds a free, unlimited Permission Set and License to all new Users.
trigger SSA_Custom_User on User (after insert) {
    List<User> users= trigger.new;
        FOR(User u :users) {
            IF(u.ProfileId == '00e12000000RuwGAAS') {
public class SSACustomUser {
    public static void SkuidUserPermissions(String Id) {
        PermissionSet ps = [select Id, Name from PermissionSet where Name = 'Skuid_Page_Viewer' limit 1];
        PermissionSetAssignment psa = new PermissionSetAssignment
            (PermissionSetId = ps.Id, AssigneeId = Id);
            system.debug('user id is ' + Id);
        	insert psa;

    public static void SkuidUserLicense(String Id) {
        PackageLicense pl = [select Id, NameSpacePrefix from PackageLicense where NameSpacePrefix = 'Skuid' limit 1];
         UserPackageLicense upl = new UserPackageLicense
            (PackageLicenseId = pl.Id, UserId = Id);
            insert upl;
Photo of Dan Kray

Dan Kray

  • 70 Points

Posted 2 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 54,226 Points 50k badge 2x thumb
Official Response

We will be releasing a fix that addresses the issue you were experiencing in the upcoming maintenance releases due out on 2/13/18. With that, you should be able to auto-assign Licenses and Permission Sets to Self-Registered Portal / Community Users using Skuid's built-in functionality --- eliminating the need for any Apex Code here.