MidServer selection data stream

KoenHaemels
Tera Contributor

Hi

 

I need to create a Data Stream in the Workflow Studio that runs from a specific MidServer.

You need to provide a data p-i-l-l picker for it but...
There is no connection alias available for it and i can't create an extra step to perform a "Look Up Record" in a Data Stream like in an Action. The only possible solution i can think of is to use a script in the "Mid Server" field.

 

Am i correct for this? And can someone provide a valid script for it?
I already tried this script, but doesn't seem to find my Mid server.

 

 

 

// Define the MID Server name
var midServerName = "MyMidServer";

// Create a new GlideRecord object for the 'ecc_agent' table
var gr = new GlideRecord('ecc_agent');

// Add a query to find the MID Server by name
gr.addQuery('name', midServerName);

// Query the database
gr.query();

// Check if the MID Server record exists
if (gr.next()) {
    // Output the MID Server information
    gs.info('MID Server Name: ' + gr.name);
    gs.info('MID Server Status: ' + gr.status);
    gs.info('MID Server IP Address: ' + gr.ip_address);
} else {
    // Output a message if the MID Server is not found
    gs.info('MID Server not found');
}

 

 

 

 
Thanks in advance!

2 REPLIES 2

vinsanity16985
Tera Contributor

Did you ever figure this out?

Hi @vinsanity16985 

There were 2 ways to get this fixed.

Option 1:
Pass the mid server value by creating it as input variable of type as reference field. So you can use this data pill in your flow.

Option 2:
I tuned the script a bit to this and it worked.

 

// Create a new GlideRecord object for the 'ecc_agent' table, which stores MID Server information
var midServerGR = new GlideRecord('ecc_agent');

// Add a query to filter for the specific MID Server by name, if known
midServerGR.addQuery('name', 'NameOfYourMidServer');

// Query the table
midServerGR.query();

// Check if the MID Server exists and retrieve the sys_id
if (midServerGR.next()) {
  var midServerSysId = midServerGR.sys_id;
  // You can now use the sys_id as needed
  gs.info('MID Server sys_id: ' + midServerSysId);
  return midServerSysId;
} else {
  gs.info('MID Server not found');
}