This document contains sample code and step-by-step instructions for test driving the Partner Licensing Platform (PLP) using first-generation packaging (1GP).
This document assumes that you've completed the "Getting Started" instructions in the main README file of this repository. If you haven't, please do so before continuing here.
Unless otherwise noted, the commands shared in this guide can be copy/pasted directly into your terminal/CLI program and executed without modification.
In the first part of this demo, you'll connect the Salesforce CLI to your packaging org and create a simple first-generation managed package (1GP) using the provided sample code.
You'll need approximately 20 minutes to complete this part.
Authorize the Salesforce CLI to access a PLP-enabled packaging org using the following command.
- As part of the PLP dev preview onboarding process you were asked to create a Partner Developer Edition (PDE) org and give it a namespace beginning with
plpdp_
. - This PDE org is the same one you used when linking your
plpdp_
namespace to your PLP-enabled Dev Hub in the "Getting Started" instructions. - For the 1GP version of the PLP Demo App, this PDE org will become your packaging org.
- You must authorize the Salesforce CLI on your local machine to access this specific org.
sfdx force:auth:web:login -a PkgOrg:PLP-Dev-Preview
sfdx force:org:open -u PkgOrg:PLP-Dev-Preview
- Inside of your packaging org, open Setup.
- Type
pack
in the Quick Find box, then click on the Package Manager setup menu item.- A namespace prefix that starts with
plpdp_
should already be assigned to this org. - If this is not the case, then you are either in the wrong org or you have not correctly completed the "Getting Started" instructions.
- If further assistance is required, please reach out to the Partner Licensing Platform - Dev Preview group in the Partner Community.
- A namespace prefix that starts with
- In the Packages related list, click the
New
button. - Create a package using EXACTLY the following information.
- Package Name:
PLP Demo
- Language:
English
- Managed:
Checked
- Package Name:
- Click the
Save
button.
- Make sure that the value provided to the
-n
argument exactly matches the Package Name you specified in the previous step. - This ensures the metadata components that are deployed in the following step will automatically be added to your managed package.
sfdx force:source:convert -d mdapi-source -n "PLP Demo"
sfdx force:mdapi:deploy -d mdapi-source -l NoTestRun -w 15 -u PkgOrg:PLP-Dev-Preview
- Inside of your packaging org, open Setup.
- Type
pack
in the Quick Find box, then click on the Package Manager setup menu item. - In the Packages related list, click the package named
PLP Demo
. - In the Components tab of the Package Details page, verify that a number of metadata components are listed.
- If you do not see any metadata components in your package, one of two things happened
- The value you specified for the
-n
flag when runningforce:source:convert
did not exactly match the name of your package. - You did not use
force:mdapi:deploy
to deploy to your packaging org.
- The value you specified for the
- You can attempt to recover by carefully repeating the previous steps, or by manually adding all of the demo app's metadata to your managed package by clicking the
Add
button in the Package Details page.
- If you do not see any metadata components in your package, one of two things happened
- Make sure you're still on the Package Details page.
- Click the
Upload
button. - On the Upload Package screen, specify the following values, leaving everythig else as-is:
- Version Name:
ver 1.0
- Version Number:
1.0
- Release Type:
Managed - Released
- Version Name:
- Click the
Upload
button again, then click theOK
button when asked to confirm that you want to upload a Managed - Released package. - Wait for the package upload process to complete successfully.
- Note the use of the
-n
(nonamespace
) and-c
(noancestors
) flags. - These flags allow this scratch org to accurately simulate a subscriber org
sfdx force:org:create -n -c -a PLP-admin-user -f config/subscriber-scratch-def.json
- Run the command, below.
sfdx force:package1:version:list -u PkgOrg:PLP-Dev-Preview
- Your output will look something like this:
MetadataPackageVersionId MetadataPackageId Name Version ReleaseState BuildNumber
──────────────────────── ────────────────── ─────── ─────── ──────────── ───────────
04t00000000ZI00AAG 03300000000ZU00AAC ver 1.0 1.0.0 Released 1
- Make note of the
MetadataPackageVersionId
value for version1.0.0
of your app so you can use it during the next step.
- When executing the following command, make sure to replace
YOUR_PACKAGE_VERSION_ID
with the04t
Package Version ID you got fromforce:package1:version:list
during the previous step.
sfdx force:package:install -r -p YOUR_PACKAGE_VERSION_ID -w 10 -u PLP-admin-user
sfdx force:user:create -a PLP-demo-user -f config/demo-user-def.json -u PLP-admin-user
In the second part of this demo, you'll interact with the subscriber scratch org using two different users.
- The DEMO user simulates a standard user within the subscriber's org
- The ADMIN user simulates a system administrator within the subscriber's org.
Approximately 10 minutes are required to complete this part.
sfdx force:org:open -u PLP-demo-user
- In the subscriber demo org, click the App Launcher icon.
- Some call this the "waffle icon", a 3x3 grid of dots at the top-left of the page, right below the Salesforce logo and directly to the left of the word "Sales".
- Type
Feature
into the App Launcher's search box, then click on theFeature Access
item. - Click the button that says
Can I access Feature A?
.- The response should be "Nope".
- Click the button that says
Can I access Feature B?
.- The response should be "Nope"
These instructions will help you open the ADMIN user in a browser that is not your system default. This allows you to simulate both the DEMO and ADMIN user personas at the same time.
- The
-b
flag of theforce:org:open
command allows you to specify which browser the CLI will use when "opening" an org. The available options are:chrome
firefox
edge
- Execute the command below, making sure to replace
YOUR_NON_DEFAULT_BROWSER
with one of the three options that is not your system default.- For example, if your system default browser is Chrome, specify either
firefox
oredge
, depending on what's available on your local machine.
- For example, if your system default browser is Chrome, specify either
sfdx force:org:open -u PLP-admin-user -b YOUR_NON_DEFAULT_BROWSER
If you do not have access to at least one of the three alternative browsers on your machine, you can follow along with this demo by manually switching the user context using your default browser.
- Determine the current user context by clicking the user icon at the top-right of the Lightning Experience UI and inspecting the first and last name displayed there.
- The DEMO user appears as
Demo User (Non-Admin)
. - The ADMIN user appears as
User User
.
- The DEMO user appears as
- Using the Salesforce UI, log the current user out of your subscriber org.
- Use the Salesforce CLI to reopen the org using the desired user context.
- DEMO user context:
sfdx force:org:open -u PLP-demo-user
- ADMIN user context:
sfdx force:org:open -u PLP-admin-user
- DEMO user context:
- Using the ADMIN user context, open Setup.
- Type
Users
in the Quick Find box, then click on the Users setup menu item. - In the list of all users, click the Alias for
DemoUser
to enter the setup page forDemo User (Non-Admin)
. - Scroll down to the Permission Set License Assignments related list and click the
Edit Assignments
button. - Check the
Enabled
box forDemo FeatureA
.- Do not enable the PSL for
Demo FeatureB
yet.
- Do not enable the PSL for
- Click the
Save
button.
- Make sure you're still in the setup page for
Demo User (Non-Admin)
. - Scroll down to the Permission Set Assignments related list and click the
Edit Assignments
button. - Move
FeatureA User
from the list of available permission sets over to the list of enabled permission sets. - Click the
Save
button.
After completing this step, the following language can be used to describe the DEMO user.
- The DEMO user is entitled to use "Feature A" because they were assigned the
Demo FeatureA
Permission Set License (PSL). - The DEMO user has been granted access to "Feature A" by the org administrator because they were assigned the
FeatureA User
Permission Set.
The next step will demonstrate what happens when the ADMIN user tries to grant access to a feature that the DEMO user is not entitled to.
- Make sure you're still in the setup page for
Demo User (Non-Admin)
. - Scroll down to the Permission Set Assignments related list and click the
Edit Assignments
button. - Move
FeatureB User
from the list of available permission sets over to the list of enabled permission sets. - Click the
Save
button. - Note the error message that appears.
When you attempt to grant access using a permission set to a feature that the user is not entitled to via application of a Permission Set License (PSL), you get the following error:
Can't assign permission set FeatureB User to user Demo User (Non-Admin).
The user license doesn't allow the permission: Custom Permission Feature B
is not valid for this Permission Set.
Return to the "Feature Access Check Demo" page as the DEMO user to see which features are now accessible.
- Using the DEMO user context, click the App Launcher icon.
- If you are using two browsers, your DEMO user is probably still on this page.
- If this is the case, reload the page and skip to step 3.
- Type
Feature
into the App Launcher's search box, then click on theFeature Access
item. - Click the button that says
Can I access Feature A?
.- The response should be "Yes, you can!".
- Click the button that says
Can I access Feature B?
.- The response should be "Nope"
In the final part of this demo, you'll create and package a new entitlement and the means to grant access to it.
You'll need approximately 25 minutes to complete this part.
sfdx force:org:open -u PkgOrg:PLP-Dev-Preview
- In your packaging org, open Setup.
- Type
custom perm
in the Quick Find box, then click onCustom Permission Set License Definitions
. - In the Custom Permission Set License Definitions setup page, click the
New
button. - Type
All_Access
in the Label field and hit the TAB key. This will automatically set the Name field toAll_Access
as well. - Click the
Save
button.
- You should already be on the Custom Permission Set License Definition Detail page for the
All_Access
Custom PSL. - Find the Licensed Custom Permissions related list at the bottom of the page and click the
Add Licensed Custom Permission
button. - Move both
Feature A
andFeature B
from the list of Available Licensed Custom Permissions to the list of Included Licensed Custom Permissions. - Click the
Save
button.
- You should still be in Setup in your packaging org.
- Type
pack
in the Quick Find box, then click on the Package Manager setup menu item. - In the Packages related list, click the package named
PLP Demo
. - On the Components tab of the Package Details page, click the
Add
button. - On the Add to Package screen...
- Set the Component Type drop-down to
Custom Permission Set License Definition
. - Check the box next to
All_Access
. - Click the
Add to Package
button.
- Set the Component Type drop-down to
- Verify that the list of components in your package now includes the
All_Access
Custom PSL.
- Make sure you're still on the Package Details page.
- Click the
Upload
button. - On the Upload Package screen, specify the following values, leaving everythig else as-is:
- Version Name:
ver 2.0
- Version Number:
2.0
- Release Type:
Managed - Released
- Version Name:
- Click the
Upload
button again, then click theOK
button when asked to confirm that you want to upload a Managed - Released package. - Wait for the package upload process to complete successfully.
- Run the command, below.
sfdx force:package1:version:list -u PkgOrg:PLP-Dev-Preview
- Your output will look something like this:
MetadataPackageVersionId MetadataPackageId Name Version ReleaseState BuildNumber
──────────────────────── ────────────────── ─────── ─────── ──────────── ───────────
04t00000000ZI00AAG 03300000000ZU00AAC ver 1.0 1.0.0 Released 1
04t00000000ZJ00ZUG 03300000000ZU00AAC ver 2.0 2.0.0 Released 1
- Make note of the
MetadataPackageVersionId
value for version2.0.0
of your app so you can use it during the next step.
- When executing the following command, make sure to replace
YOUR_PACKAGE_VERSION_ID
with the04t
Package Version ID for version2.0.0
.
sfdx force:package:install -r -p YOUR_PACKAGE_VERSION_ID -w 10 -u PLP-admin-user
- Using the ADMIN user context in your subscriber scratch org, open Setup.
- Type
Users
in the Quick Find box, then click on the Users setup menu item. - In the list of all users, click the Alias for
DemoUser
to enter the setup page forDemo User (Non-Admin)
. - Scroll down to the Permission Set License Assignments related list and click the
Edit Assignments
button. - Check the
Enabled
box forAll_Access
. - Click the
Save
button.
- Make sure you're still in the setup page for
Demo User (Non-Admin)
. - Scroll down to the Permission Set Assignments related list and click the
Edit Assignments
button. - Move
FeatureB User
from the list of available permission sets over to the list of enabled permission sets. - Click the
Save
button. - This time, the attempt to assign the
FeatureB User
permset is successful!
After completing this step, the following language can be used to describe the DEMO user.
- The DEMO user is entitled to use BOTH "Feature A" and "Feature B" because they were assigned the
All_Access
Permission Set License (PSL). - The DEMO user has now been granted access to "Feature B" by the org administrator because they were assigned the
FeatureB User
Permission Set.
Return to the "Feature Access Check Demo" page as the DEMO user to see which features are now accessible.
- Using the DEMO user context in your subscriber scratch org, click the App Launcher icon.
- Type
Feature
into the App Launcher's search box, then click on theFeature Access
item. - Click the button that says
Can I access Feature A?
- The response should be "Yes, you can!"
- Click the button that says
Can I access Feature B?
- The response should be "Yes, you can!"
This demo gave you the chance to get a hands-on understanding of the fundamental building blocks of the Partner Licensing Platform.
In this demo, you learned that...
- Custom Permission Set Licenses entitle a subscriber's user to one or more features.
- Subscriber admins grant access to those features by assigning Permission Sets that include one or more Licensed Custom Permissions.
- Attempting to assign such Permission Sets results in an error when the target user does not have the entitlement that comes with the assignment of a Custom Permission Set License.
To learn more, please see Partner Licensing Platform Components and Concepts in the ISVforce guide.
Have questions or comments about this demo? Please visit the Partner Licensing Platform - Dev Preview group in the Partner Community.
Have general questions or comments about PLP? Please visit the main Partner Licensing Platform group in the Partner Community.