Determine MID server through script

bennybiesmans
Kilo Explorer

Hello,

 

Normally the MID servers will be determined by IP Ranges and Capibilities. (IP ranges are to static we want to determine it dynamically)

We want to dynamically determine the MID server based on a TAG and based on that TAG we want to start a script that forces a MID server to use if a workflow starts.

It didn't work with 'MID Server Capability Value Tests' but maybe it is possible to write your own capability to determine the MID server.

 

Thanks.

 

Greetings,

Ben

4 REPLIES 4

Brandon Smith3
Kilo Expert

Ben, possibly use a script along with sys_properties that you can define. Use this in conjunction with a workflow script to evaluate and set the MID.



System Property:


midServer1 = MID.1



Workflow Script:


if (tag = 1){


midServer = gs.getProperty('midServer1');


}



Hope this helps?


Hello Brandon,



Thanks for the reply.



But how can you force   to use a specific MID server if you know for example midServer = gs.getProperty('midServer1');


Is this only possible if you manipulate the ECC queue and change the Agent = mid.server.midServerxxx or can you start a script in the preprocessing in the workflow activities to do that.



I did succeeded to do that with a Business Rule on the ECC Queue but are there other solutions. Because if an workflow activity starts it normally determines based on IP Ranges and capabilities which MID server it will uses but I would like to force to use another MID server.



Script would be:


var ecc_gr = new GlideRecord('ecc_queue');


      ecc_gr.addQuery('state', 'ready');


      ecc_gr.query();


      if (ecc_gr.next()) {


              ecc_gr.agent = 'mid.server.midServerxxx';


              ecc_gr.update();


      }



Greetings...


I haven't tried it, but can you create a custom capability for mids that need special treatment and add a required mid server capability to the activities for those mids?


Aditya Telideva
ServiceNow Employee
ServiceNow Employee

Hi benny,


As of now Servicenow provides that functionality through export set and you need not write any script.



To achieve your requirement:


1) Create custom table to hold the values user submits


2) Create export definition, export target, export set and scheduled export mention file name etc, csv format etc


3) Scheduled export will be active false since you will be triggering it via script


4) Have after insert business rule on your custom table to trigger the scheduled export



script below:



var gr = new GlideRecord("scheduled_data_export");


gr.addQuery("sys_id", ''); // sys_id of your scheduled export


gr.query();


if (gr.next()) {


gs.executeNow(gr); // if using in scoped app



SncTriggerSynchronizer.executeNow(gr); // if using in non-scope app i.e global


}



Thanks,


aditya Telidevara