ClosePlan License Assignment
- 1 Introduction
- 2 API Reference
- 2.1 Retrieving User License
- 2.1.1 getUserLicense()
- 2.1.1.1 Signature
- 2.1.1.2 UserLicense Class
- 2.1.1.2.1 Global Properties
- 2.1.1 getUserLicense()
- 2.2 Modifying User License
- 2.2.1 setUserLicense()
- 2.2.1.1 Signature
- 2.2.1.1.1 Parameters
- 2.2.1.2 UserLicenseRequest[]
- 2.2.1.3 UserLicenseRequest Class
- 2.2.1.3.1 Properties
- 2.2.1.1 Signature
- 2.2.2 Scopes
- 2.2.2.1 Type of scopes
- 2.2.2.2 Available scopes
- 2.2.3 Examples
- 2.2.3.1 Using APEX
- 2.2.3.2 Using Flows
- 2.2.1 setUserLicense()
- 2.1 Retrieving User License
Introduction
ClosePlan Package licensing uses a site-wide configuration for all Subscribers instead of a per-seat configuration. This means, technically, that every user has access to the package.
Site-wide configuration overcomes Salesforce licensing issues inherent in Lightning Experience which are yet to be solved.
Instead of full site-wide licensing, ClosePlan uses internal Licensing to provide Users with access to ClosePlan modules. Previously, access was driven through permission sets, which worked well and Customers started to provision users automatically without a need to manually find and provision using the User Manager. However in either a manual or automated approach, ClosePlan would not be able to enforce any license limits based on what has been contracted.
As a result, the ClosePlan User Manager is used. The User Manager controls and provides visibility into provisioned Users within the subscriber's organization over time. As a result, automated provisioning has been removed because subscribers cannot access or manipulate license data.
To automate User Provisioning, we provide APEX APIs.
Technical Requirements
Apex Invocable
Flows / Process Builder Invocable
Bulkified
ClosePlan Package/User License not required for running User
Limitations
Only Users with
ManageProfilesPermissionsets
orAssignPermissionSets
permission will be able to successfully invoke APIs to assign/modify user license.
API Reference
User Management APIs provide the ability to retrieve user license information or assign or change user licensing using the scopes
API methods are provided through global TSPC.CPUserManagement
class.
Retrieving User License
Following methods allow accessing User ClosePlan license information through APEX
getUserLicense()
Signature
global static UserLicense getUserLicense()
global static UserLicense getUserLicense(Id userId)
UserLicense Class
TSPC.CPUserManagement.UserLicense
Global Properties
Property | Type | Description |
---|---|---|
| ID | Readonly; |
| string | Readonly; |
| string | Readonly; |
| string | Readonly; |
| string | Readonly; |
| string | Readonly; |
| string | Readonly; |
|
| Readonly; True if at-least one module has at-least read access |
Modifying User License
Following methods allow to modify user ClosePlan license through APEX, Flows or Process Builder.
API methods to modify ClosePlan user licenses can be invoked only in the context of the user who has “Manage Profiles and Permission Set“ or “Assign Permission Sets” permission granted. For instance, invoking API methods as a result of user profile update by the user without sufficient permissions would be canceled.
In order to assign users with ClosePlan licenses, the organization must have spare licenses of the given type available. In case licenses are depleted, the allocation will be canceled without any warning for the whole batch.
Users who have been suspended will be automatically skipped. If you want to change the license for these users, use ClosePlan User Manager.
setUserLicense()
Signature
global static void setUserLicense(UserLicenseRequest[] requests)
Parameters
Property | Type | Description |
---|---|---|
| UserLicenseRequest[] | List of UserLicenseRequest objects |
UserLicenseRequest Class
TSPC.CPUserManagement.UserLicenseRequest
Properties
Property | Type | Description |
---|---|---|
| User |
|
| string |
|
Scopes
Scopes refer to scope type followed by the modifier class. Types can represent the app or module they grant access to or additional access modifier.
Type of scopes
The list of modules includes app-wide suite
or module-based deal
, and account
. There are only two classes of access:
read: read access to all the ClosePlan module data.
full: modifying data in any way e.g. creating, editing, or deleting.
Note that not every combination of suite
and module
accesses is valid as they can be mutually exclusive.
Additional types currently include only the level
with two classes available:
user: standard access for end-users. If level not specified,
level:user
will be applied by default if not level not set yet (license create)admin: elevated access, which grants read/write access to ClosePlan admin section
In order to remove/deactivate user, use remove
scope as an only value. Note that removal will be ignored if other scopes are added for the user at the same time.
Available scopes
level:admin
level:user
suite:full
suite:read
deal.playbook:full
deal.playbook:read
deal.scorecard:full
deal.scorecard:read
deal.relations:full
deal.relations:read
remove
Examples
Using APEX
// Get users based on user name or any other logic
String[] userNames = new String[]{'user@yourorg.com'};
// User fields Id, UserType, IsActive are required
User[] users = [SELECT Id, UserType, IsActive FROM User WHERE Username IN: userNames AND isActive=true];
// Build Licence Request List
TSPC.CPUserManagement.UserLicenseRequest[] ulrs = new TSPC.CPUserManagement.UserLicenseRequest[]{};
for(User u : users){
TSPC.CPUserManagement.UserLicenseRequest ulr = new TSPC.CPUserManagement.UserLicenseRequest();
ulr.user = u;e
// set scopes based on available scopes.
// If level scope is ommited, new assignments will default to level:user while
// already provisioned users will keep their current level.
ulr.scopes = 'suite:full level:user';
ulrs.add(ulr);
}
// Execute
TSPC.CPUserManagement.setUserLicense(ulrs);
Using Flows
The following example shows how to create Flow to assign ClosePlan license automatically whenever new user is Created
Setup > Process Automation > Flows
Click New Flow
Select Record-Triggered Flow
Click Create
Click Object and select User
You can define any conditions you like
Although it's handled by the Service, you could add
UserType equals Standard
, because only Standard Users are supported.
Or change the Condition Requirements list to None to execute every time
Click Done
Click Circle Plus sign to Add Element
Select Action
Search for ClosePlan: Set User License and select it
Use
Assign ClosePlan License
as an action Label. API Name will be autofilled.Populate the Scopes field based on the available scope list above according to your needs.
We will use
suite:full
in our case to provide user with full suite access.
Populate User field with
{!$Record}
. This value will be always the same.Click Done
Click Save
fill Label (ie: 'ClosePlan: License assignment flow') and API Name
Click Save
Finally, click Activate