How to setup a limit on approval when reached max purchased right count on software entitlement.

spandana kalla
Tera Contributor

Hi Community,

 

Firstly, we should write a script to limit approval once reached purchased right in one entitlements. Firstly we should query the current members of the AD group and then count the number of purchased rights in one entitlements. Compare it against the purchased right limit. I had already written a script in run script workflow. But it's not working. @Dr Atul G- LNG  @Ankur Bawiskar @Mark Roethof 

Script : 

 
var answer;
var item = current.cat_item.getDisplayValue();
var gr = new GlideRecord('alm_license');
gr.addQuery('display_name=DocuSign DocuSign CLM+ Standard User for SFDC', item);
gs.log('Suja' + item);
gr.query();
while (gr.next()) {
    var lic = gr.purchased_rights;
    gs.log('Suja' + lic);
    if (purchased_rights < 170) {

        answer = 'yes';
        gs.log('Suja' + answer);
    } else if (purchased_rights > 170) {

        answer = 'no';
        gs.log('Suja' + answer);
    }
}
 
Thanks,
Spandana.
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@spandana kalla 

script has issue in the way you are performing the query; this line

gr.addQuery('display_name=DocuSign DocuSign CLM+ Standard User for SFDC', item);

are these 2 catalog items? "DocuSign DocuSign CLM" and "Standard User for SFDC"?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar the add query which I gave is the entitlement name where we should check the purchased right count on this entitlement comparing with the group members of one group.

 

Thanks,

Spandana.

@spandana kalla 

the query is wrong.

Please correct it. We are not sure on the exact use-case, field names etc

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

 

@Ankur Bawiskar

Firstly do we need to query the group  and then compare the count on entilelment purchased right?

 

Thanks,

Spandana.