Issue
Overview
This Article will Demonstrate to use CloudMidSelectionApi to have the Cloud Operations go through specific MID server
Configure CloudMidSelectionApi
- Login to the Instance
- Impersonate with the user have Admin Privileges
- Make sure the Application is Cloud API
- Navigator >> Discovery >> MID server >> Choose the MID server to configure with "CloudMidSelectionApi"
- Navigator >> System Definition >> Script Includes
https://<Instancename>.service-now.com/sys_script_include_list.do
- From the name field choose "CloudMidSelectionApi"
https://<Instancename>.service-now.com/sys_script_include.do?sys_id=019292f7132893009f325db12244b04b&sysparm_view=&sysparm_record_target=&sysparm_record_row=1&sysparm_record_list=nameCONTAINScloudmid%5EORDERBYname&sysparm_record_rows=1
- Modify from Line 59 as per your requirement
Example Script
- Edit script include CloudMidSelectionApi, Line No 59
change from
return midSelector.selectMid(app, null, capabilities, context);
to:
if (JSON.parse(context).service_account_id == 'xxxxxx-xxxx-xxxx-xxxx-xxxxxx') { >>>>> Cloud Service Account ID
return 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
}
else {
// Now we have everything set up - call the mid selector API to select one mid
var selectedmid = midSelector.selectMid(app, null, capabilities, context);
return midSysId;
}