Need to get the value of the license allocated on the alm_license table

Community Alums
Not applicable

Hi All, 

 

Having a requirement that, need to get the licenses allocated on the form of alm_license table. 

we have two field on the one is Active rights, and the other is Allocations Available. Need to have the allocated licenses also. for that we created a new custom filed called 'u_license_allocated'(integer-type). 

chanti1_0-1707364508540.png

 

On the alm_license table we have a business rule that will get the count of Allocations available. like as below. 

It runs before - insert,update

Condition - current.license_metric.changes() || current.install_status.changes() || current.purchased_rights.changes() || current.rights.changes() ||current. product_type.changes() ||current.unlimited_license.changes()||global.AssetUtils.isPlaybookInReview(current)

 

(function executeRule(current, previous /* null when async */) {
// License durarion { PERPETUAL_LICENSE : 1, SUBSCRIPTION_LICENSE : 2 }
var SUBSCRIPTION_LICENSE = 'subscription';
 
// License state { IN_USE : 1, ON_ORDER : 2, RETIRED : 7 }
var ON_ORDER = '2';
var RETIRED = '7';
 
if ((current.getValue('product_type') === SUBSCRIPTION_LICENSE && current.getValue('install_status') === ON_ORDER)
|| current.getValue('install_status') === RETIRED || current.unlimited_license) {
current.allocations_available = 0;
return;
}
 
// If license metric is Consumption, allocation is not applicable
if (current.license_metric.getValue() === LicenseMetric.CONSUMPTION) {
current.allocations_available = current.rights;
return;
}
 
var allocSum = new GlideAggregate('alm_entitlement');
allocSum.addQuery('licensed_by', current.sys_id);
allocSum.addAggregate('SUM', 'quantity');
allocSum.setGroup(false);
allocSum.query();
allocSum.next();
current.allocations_available = current.rights - Number(allocSum.getAggregate('SUM', 'quantity'));
}(current, previous));
 
 
Its a system created one that will populate the value of the Allocations Available. 
 
 
Like the same way we need to get the count of the License allocated. tried the same way of getting the value but no result. 
Need suggestions to achieve it. 
 
 
1 REPLY 1

shloke04
Kilo Patron

Hi @Community Alums ,

 

I do not think you need to create a custom attribute to calculate Allocated license. Rather there are 2 OOTB attribute named as below:

 

1. Device Entitlements

2. User Entitlements 

 

Which contains the info you are looking for. Sample screenshot below:

shloke04_0-1707377285186.png

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke