Description
You may see the following reconciliation error upon Vancouver upgrade -
TypeError: Cannot read property "null" from undefined
at sys_script_include.602e129eb0276300fa9b028ca0d3b864.script:1206
The error arises in the SamLicenseCalculator script include.
Allocations should not be processed on entitlements where software model has 'license_under_management'=false. However, a bug in the code processes allocations on these entitlements and causes downstream issues. License metric results are not created for these entitlements, but the problematic code attempts to create a 'rights used by' with an 'allocated not in use' value. The full code fix is available in Washington p1 but workarounds are available.
Steps to Reproduce
1) Create an allocation on a 'per device' entitlement (or other metric).
2) For a software model, set LUM as 'false'.
3) Run reconciliation.
Results:
a) Recon status is either 'partially completed' or 'failed'. In the progress summary logs, the message "TypeError: Cannot read property "null" from undefined" is displayed.
b) There might be a record in 'samp_licenses_required_by' for the allocated user/device with empty LMR and 'allocated not in use' > 0.
This issue is reproducible in before Vancouver p6.
Workaround
For the full code fix, please update to: Xanadu when available, WashingtonDC p1, or Vancouver p7.
If upgrading is not doable, one workaround is to retire all entitlements under unmanaged software models -
var gmu = new GlideMultipleUpdate('alm_license'); // entitlement table
gmu.addQuery('install_status', '!=', 7); // not retired
gmu.addQuery('software_model.license_under_management', false); // unmanaged software model
gmu.setValue('install_status', 7); // set retired
gmu.execute();
Allocations on retired entitlements are automatically ignored. You may optionally clean up the ignored allocations afterwards -
var gr = new GlideRecord('alm_entitlement'); // allocations table
gr.addQuery('licensed_by.install_status', 7); // retired entitlements
gr.query();
gr.deleteMultiple()
Alternatively, you may directly remove invalid allocations rather than retiring entitlements -
var gr = new GlideRecord('alm_entitlement'); // allocations table
gr.addQuery('licensed_by.install_status', 1); // active entitlement (optional query)
gr.addQuery('licensed_by.software_model.license_under_management', false); // unmanaged software model
gr.query();
From here, you can review and deleteMultiple() in the code or delete manually from the UI. Export the records first if you need a backup.
If the above workarounds are not sufficient, you may also implement the following -
Update the below lines of code at line 1177 in Script Include: SamLicenseCalculator
if (!lmrUsage.consumptionRule) {
return;
}
Note: This is a Protected Script, only Maint users can perform changes. *It is suggested to upgrade rather than making this code fix*
Related Problem: PRB1715795