Issue Creating Manual Endpoint via Flow Designer

aen612
Tera Guru

In Flow Designer, I'm trying to create Service Groups, Application Services and manual endpoint(s) for each Service.

Basically, we receive records that have reference fields to custom CIs. When we receive one of these records, we want to check if a Service Group, Application Service, etc. exist and if not, create one so that any associated alerts display on the Event Management dashboard.

If I manually create a Service Group, then Application Service, then manually add CI, add the Service as a Group Member everything works. When I do it in Flow Designer, everything appears to work except the icon for the CI does not display on the service map.

Everything appears to be identical (I've compared xml in a diff checker) when creating manually vs flow designer. 

Any ideas? I almost feel like I've run into this before but can't recall exactly...

Here's the flow:
find_real_file.png

  1. Create Service Group (cmdb_ci_service_group)
    find_real_file.png
  2. Create Application Service (cmdb_ci_service_discovered)
    find_real_file.png
  3. Create Manual Endpoint (cmdb_ci_endpoint_manual)
    find_real_file.png
  4. Create Entry Point (sa_m2m_service_entry_point)
    find_real_file.png
  5. Create Service Group Members (sa_service_group_member)
    find_real_file.png

Here's the map:
find_real_file.png


Here's what I'm expecting the map to look like:
find_real_file.png

1 ACCEPTED SOLUTION

aen612
Tera Guru

I got this working, with the help of our ServiceNow Solution Consultant.

Here's what she said "manual endpoints behave differently as well as “Created Manually” Application Services.  Manual Endpoints are created as result of “adding” a manual CI from the UI as Entry Point or Add CI on canvas. Tthe API/Source Code behind the UI creates 2 additional CI Relationships between the Application Service and the CI.  Finally the Service Association is updated, but these are not standard GlideRecord tables and is not recommended/designed to add/remove directly to it.

Steps 1,2,5 are acceptable/doable.  But I would like to direct you to this API for steps 3 & 4.  This link is only for Created Manually application services.

https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/product/configuration-management...

Application services provide APIs that let you perform operations such as creating and updating an application service, populating it with CIs from the CMDB, and retrieving details from an existing application service.
"

So, I ended up creating another script step with the Application Service and Custom CI (API Info) records as inputs:

(function execute(inputs, outputs) {

var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://******.service-now.com/api/now/cmdb/app_service/create');
request.setHttpMethod('POST');

//Eg. UserName="admin", Password="admin" for this code sample.
var user = '*******';
var password = '******';

request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json');request.setRequestBody("{\"name\":" + "\"" + inputs.app_service + "\"" + ",\"service_relations\":[{\"parent\":\"\",\"child\":" + "\"" + inputs.site_id + "\"" + "}]}");
var response = request.execute();
gs.log(response.getBody());

})(inputs, outputs);


That works great! Ran into another issue trying to set the Application Service's operational_status to operational. I ended up having to add a Wait Duration (currently at 30 seconds but will shorten that).

Here's the new script step:

find_real_file.png

 

And finally here's the full flow:

find_real_file.png

View solution in original post

1 REPLY 1

aen612
Tera Guru

I got this working, with the help of our ServiceNow Solution Consultant.

Here's what she said "manual endpoints behave differently as well as “Created Manually” Application Services.  Manual Endpoints are created as result of “adding” a manual CI from the UI as Entry Point or Add CI on canvas. Tthe API/Source Code behind the UI creates 2 additional CI Relationships between the Application Service and the CI.  Finally the Service Association is updated, but these are not standard GlideRecord tables and is not recommended/designed to add/remove directly to it.

Steps 1,2,5 are acceptable/doable.  But I would like to direct you to this API for steps 3 & 4.  This link is only for Created Manually application services.

https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/product/configuration-management...

Application services provide APIs that let you perform operations such as creating and updating an application service, populating it with CIs from the CMDB, and retrieving details from an existing application service.
"

So, I ended up creating another script step with the Application Service and Custom CI (API Info) records as inputs:

(function execute(inputs, outputs) {

var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://******.service-now.com/api/now/cmdb/app_service/create');
request.setHttpMethod('POST');

//Eg. UserName="admin", Password="admin" for this code sample.
var user = '*******';
var password = '******';

request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json');request.setRequestBody("{\"name\":" + "\"" + inputs.app_service + "\"" + ",\"service_relations\":[{\"parent\":\"\",\"child\":" + "\"" + inputs.site_id + "\"" + "}]}");
var response = request.execute();
gs.log(response.getBody());

})(inputs, outputs);


That works great! Ran into another issue trying to set the Application Service's operational_status to operational. I ended up having to add a Wait Duration (currently at 30 seconds but will shorten that).

Here's the new script step:

find_real_file.png

 

And finally here's the full flow:

find_real_file.png