Activate plugin via script / automatically

Cem4
Mega Contributor

All,

 

is it possible to activate a plugin via script, e.g. set the value of com.glide.service-portal.knowledge-base from false to true. If not, is there another way to activate it automatically, so the activated functionality is a available with the next ServiceNow login?

 

Many thanks

1 ACCEPTED SOLUTION

Ashby
ServiceNow Employee
ServiceNow Employee

You can use the following to automatically activate plugins: 

All you need is the plugin ID..........

//Partial Version
//you can check following URL to see if the work is finished. It is finished when the completion time is set and the percent complete is 100.
//<instance>/sys_execution_tracker_list.do?sysparm_query=name%3DPlugin%20Installer
var plugins = [];
plugins.push('com.snc.pa.change');
plugins.push('com.snc.pa.problem');
plugins.push('com.snc.pa.premium');
plugins.push('com.snc.pa.solution.library');
var main = new GlideMultiPluginManagerWorker();
main.setPluginIds(plugins);
main.setProgressName("Plugin Installer");
main.setBackground(true);
main.start();

View solution in original post

19 REPLIES 19

Hi Jennifer,

Use Scripts - Background to run the script.  Allow time for the script to run, depending on how many plugins you have included.

Once you have kicked off the script, you can run this example script to check on the status of the plugin

var list = [
    'com.glide.cs.chatbot',
    'com.snc.pa.premium',
    'com.glide.platform_ml',  
    'com.sn_customerservice',
    'com.snc.csm_proxy_contacts', 
    'com.glide.awa',
   
];

for (var i = 0; i < list.length; i++) {
    var amp = new GlideRecord('v_plugin');
    amp.addQuery('id',list[i]);
    amp.addQuery('active','Inactive');
    amp.query();
    while (amp.next()) {    
		  gs.info(amp.getDisplayValue('id') +": "+amp.getDisplayValue('active'));
    }
}

 

 

Hi @Andrew Payze .

I've been using a modified version of Ashby's script for some time to help me prep a fresh PDI (thanks @Ashby !).  Just today I finally managed to make it also install demo data by adding "main.setIncludeDemoData(true);" after main.setPluginIds(plugins).

For my full Fix script you can view this years Hacktoberfest's code-snippets repository: Install Base PDI Plugins

Best regards,

Ingimar

I can confirm that in my experience the previous script by @Andrew Payze did not work and I reverted to installing plugins in my PDI manually.

The script posted/linked to by @Ingimar  however does seem to be working.  I'll try expand the list with the plugins I need (GRC mainly) and update you here agian. 

Thanks for all the work on this @Andrew Payze  and @Ingimar 

Joel L
ServiceNow Employee
ServiceNow Employee

Hello Ingimar, 

thank you for your script. I witnessed through using it on lab instances for Hardware Asset Management that the lab instances URL are lab.service-now.com ... 

Also, the method to list the installed plugins does not show the sn_ham plugin.

I will try to further investigate if it is a different type and another view could be complete.

Update: 

Using your method seems not to work with all plugins. When using the Execution Tracker i saw some working some causing an error. I have to further investigate. I used the following variant of the script to install plugins of which all besides Extended CMDB were already installed and some of them still worked and some did not. It does not seem the install with demo data had something to do with it, as I tried both variants with and without.

var plugins = [
    "com.snc.contract_management",      // Contract Management
    "com.snc.procurement",              // Procurement
    "com.snc.certification_v2",         // Data Certification
    "com.snc.document_management",      // Managed Documents
    "com.snc.extended_cmdb",            // Extended CMDB
    "com.snc.asset_myassets",           // My Assets
    "com.snc.cost_management",          // Cost Management
    "sn_hamp",                          // Hardware Asset Management
];

var main = new GlideMultiPluginManagerWorker();
main.setPluginIds(plugins);
main.setIncludeDemoData(true);
//main.setLoadDemoDataOnly(true); // Can be used to install demo data after installation of plugins.
main.setProgressName("Plugin Installer");
main.setBackground(true);
main.start();
Kind regards
Joel L.

Hi 

I tried this in an Orlando and Paris instance with a list of GRC plugins - The Execution task get's created but fails every time.    I did see that it works if the Plugin is already installed, in which case it then get's reinstalled.  

I can not find any documentation this class in the docs.sevicenow.com or developer.servicenow.com but am guessing in later versions there may be an additional parameter needed to install plugins that are not already installed? 

Also, do you know if there's a parameter to load the demo data some plugins have?   

Thanks