Need count of licenses under software model form to be displayed in catalog form text field

ServiceNow10sun
Giga Guru

Hi All,

 

In the table alm_license  there is  related list 'license entitlements' . For each software license there is catalog form so the requirement is  user needs the number of count of 'license entitlements' to be displayed in one text field available in catalog form of each software catalog example "Variable name is lic count (type is multi line text filed).

 

I have achieved this for one catalog using script include and called the class into a on load catalog client script  and it is working , however my issue here is  I have total of more than 100 catalog  for each Software  , so do i need to create more than 100 script includes + Catalog client script ? or in one script include i need to write 100 classes and call in one catalog client script?

 

Any suggestions or help much appreciated.

 

sunita10_0-1691492981765.png

 

 

 

6 REPLIES 6

sushantmalsure
Mega Sage
Mega Sage

Better have this variable  lic count in variable set and this variable set can be included in multiple catalog items for each software license item . On variable set you can write a the same client script . By this way you will not be creating multiple clients scripts.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

yeah but Script include i need to write either multiple or single script include with multiple classes...

just single script include , no multiple classes.

Just put the same in one client script on variable set thats it.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Hi,

 

this is the script include am using 

var populatelicensecount1 = Class.create();

populatelicensecount1.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getLicensecount: function(licSysId) {

        gs.info("Received licSysId: " + licSysId); // Add this line for debugging

 

        var lic = new GlideRecord('alm_license');

        lic.addEncodedQuery('display_nameLIKEJetBrains IntelliJ IDEA');

        lic.query();

 

        var rowCount = lic.getRowCount();

        gs.info("Row count: " + rowCount); // Add this line for debugging

 

        return rowCount;

    },

 

    type: 'populatelicensecount1'

});

 

could you please tell me if any changes in the code needs to be done

thanks