{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":709,"path":"api-reference/server-api-reference/BusinessServiceManagerAPI.md","title":"BusinessServiceManager - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# BusinessServiceManager- Global\n\nThe BusinessServiceManager API provides methods that unify service management by converting manually-created services to application services, populating application services, and adding/removing configuration items and connections.\n\nUse BusinessServiceManager methods in global server scripts. You must have the Application Service administrator \\[app\\_service\\_admin\\] role to call this API.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## BusinessServiceManager - BusinessServiceManager\\(\\)\n\nInstantiates a BusinessServiceManager object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n```\nvar bsManager = new SNC.BusinessServiceManager();\n```\n\n## BusinessServiceManager - addCI\\(String service\\_id, String source\\_id, String target\\_id\\)\n\nAdds a CI to a manually-created application service.\n\n|Name|Type|Description|\n|----|----|-----------|\n|service\\_id|String|Sys\\_id of the application service to add a CI to. Must be of type cmdb\\_ci\\_service\\_discovered.|\n|source\\_id|String|Sys\\_id of the CI whose outgoing connection joins the target CI.|\n|target\\_id|String|Sys\\_id of the CI to add to the service. Cannot be an excluded item. Excluded items are CIs configured in the Manual CI Inclusions/Exclusions \\[svc\\_manual\\_ci\\_exclusions\\_inclusions.list\\] table.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\n//Application service is 'PeopleSoft Portals'\n//Source CI is windows server 'PS Apache01'\n//Target CI is 'SAP WEB01'\n\nvar bsManager = new SNC.BusinessServiceManager();\nvar appService = bsManager.addCI('2fce42d80a0a0bb4004af34d7e3984c8','3a27d4370a0a0bb4006316812bf45439', '3a6cadc1c0a8ce01001f1e5d0d7d68fa');\n```\n\n### Add a new entry point\n\nUse the addCI\\(\\) method to add a new entry point to a service by providing the following parameter values in your request:\n\n-   Provide the service\\_ID as normal.\n-   Leave the source\\_ID value empty. For example, use `''`.\n-   For target\\_ID, enter the Sys ID of the CI under which to add the new entry point.\n\nAs a result, the addCI\\(\\) method creates a new entry point with a connection to the specified target CI. The following is an example of how to add a new entry point:\n\n```\n//Application service sys_id is '49de2b3187cd9d50d5c8a6880cbb35ea' \n//Source CI is passed as an empty string as '' \n//Target CI sys id is '15ca5fb187129910d5c8a6880cbb3537'   \n\nvar bsManager = new SNC.BusinessServiceManager(); \nvar appService = bsManager.addCI('49de2b3187cd9d50d5c8a6880cbb35ea','', '15ca5fb187129910d5c8a6880cbb3537');\n```\n\n## BusinessServiceManager - addEntryPoint\\(serviceId, endpointGr\\)\n\nAdds an entry point to the application service and starts discovery on the entry point.\n\n|Name|Type|Description|\n|----|----|-----------|\n|serviceId|Sting|Sys\\_id of the application service to add the connection to.|\n|endpointGr|String|Glide Record object in the CI Endpoint \\[cmdb\\_ci\\_endpoint\\] table or its child table to add to the application service.|\n\n<table id=\"table_dlj_sw2_zwb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag indicating the entry point was successfully added to the application service.\n\n Possible values:\n\n-   true: the addition was successful.\n-   false: the addition was not successful.\n\n</td></tr></tbody>\n</table>The following addEntryPoint\\(\\) method shows how to add a new entry point to the application service.\n\n```\nvar now_GR = new GlideRecord(\"cmdb_ci_endpoint_tcp\");\nnow_GR.initialize(); \nnow_GR.setValue(\"host\", \"10.196.39.251\");\nnow_GR.setValue(\"port\", \"8080\");\nnow_GR.insert();\nvar bsManager = new SNC.BusinessServiceManager();\nvar serviceId = \"5bf65ebeedb91300964f6fa662989533\";\nbsManager.addEntryPoint(serviceId,now_GR);\n\n```\n\nOutput:\n\n```\ntrue\n```\n\n## BusinessServiceManager - addEntryPointWithoutStartDiscovery\\(serviceId, endpointGr\\)\n\nAdds a new entry point without starting discovery.\n\n|Name|Type|Description|\n|----|----|-----------|\n|serviceId|String|Sys\\_id of the application service to add the connection to.|\n|endpointGr|String|Glide Record object in the CI Endpoint \\[cmdb\\_ci\\_endpoint\\] table or its child table to add to the application service.|\n\n<table id=\"table_bt2_252_zwb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag indicating the entry point was successfully added to the application service.\n\n Possible values:\n\n-   true: the addition was successful.\n-   false: the addition was not successful.\n\n</td></tr></tbody>\n</table>The following example shows how to use the addEntryPointWithoutStartDiscovery\\(\\) method to add a new entry point to the application service without initiating discovery.\n\n```\nvar now_GR = new GlideRecord(\"cmdb_ci_endpoint_tcp\");\nnow_GR.initialize(); \nnow_GR.setValue(\"host\", \"10.196.39.251\");\nnow_GR.setValue(\"port\", \"8080\");\nnow_GR.insert();\nvar bsManager = new SNC.BusinessServiceManager();\nvar serviceId = \"5bf65ebeedb91300964f6fa662989533\";\nbsManager.addEntryPointWithoutStartDiscovery(serviceId,now_GR);\n\n```\n\nOutput:\n\n```\ntrue\n```\n\n## BusinessServiceManager - addManualConnection\\(String source\\_id, Object manual\\_endpoint, String service\\_id\\)\n\nAdds a manually created connection to an application service.\n\n|Name|Type|Description|\n|----|----|-----------|\n|source\\_id|String|Sys ID of the CI to add to the connection.|\n|manual\\_endpoint|Object|GlideRecord object in the cmdb\\_ci\\_endpoint\\_manual table to add to the application service.|\n|service\\_id|String|Sys ID of the application service to add the connection to.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar now_GR = new GlideRecord(\"cmdb_ci_endpoint_manual\");\nnow_GR.initialize(); \nnow_GR.name='myEndpoint'; \nnow_GR.insert();\n\nvar bsManager = new SNC.BusinessServiceManager();\nvar appService = bsManager.addManualConnection(\"3a307c930a0a0bb400353965d0b8861f\", now_GR, \"2fce42d80a0a0bb4004af34d7e3984c8\");\n```\n\n## BusinessServiceManager - isReadingPermitted\\(Object gr, String userSysID\\)\n\nChecks the roles of a specified user and the permissions data configured for a specified service/service group and returns a Boolean value that indicates whether the user can view the service/service group.\n\nThe following defines the process flow that the method uses to determine whether the user can view the service/service group:\n\n1.  If the specified record is a service group, checks the user roles and group policy. For more information on assigned roles for service groups, see [Assign a role to a service group](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/it-operations-management/t_EMAssignRoleSvcGroup.md).\n2.  If the roles list contains “itil” but doesn’t contain “app\\_service\\_admin” and “sam\\_core\\_user”, return true.\n3.  If the roles list contains “maint”, return true.\n4.  If the roles list contains “app\\_serivce\\_user” but doesn’t contain “app\\_service\\_admin” and “sm\\_app\\_owner”, and the service isn’t operational, return false.\n5.  Check the group of the service.\n    1.  If the service belongs to a single group, and the group is “all”, return true.\n    2.  For any non “all” group, checks the policy for user roles and group based on the rules specified in [Assign a role to a service group](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/it-operations-management/t_EMAssignRoleSvcGroup.md). If any of them returns true, return true.\n\n<table id=\"table_snj_253_kyb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ngr\n\n</td><td>\n\nGlideRecord\n\n</td><td>\n\nGlideRecord of the service/service group. This GlideRecord can be from one of the following tables:-   Service Instance \\[cmdb\\_ci\\_service\\_auto\\]\n-   Application Service Group \\[cmdb\\_ci\\_service\\_group\\]\n-   Dynamic CI Group \\[cmdb\\_ci\\_query\\_based\\_service\\]\n-   Manual Services \\[cmdb\\_ci\\_service\\_manual\\]\n-   Mapped Application Service \\[cmdb\\_ci\\_service\\_discovered\\]\n-   Service \\[cmdb\\_ci\\_service\\]\n\n</td></tr><tr><td>\n\nuserSysId\n\n</td><td>\n\nString\n\n</td><td>\n\nSys\\_id of the user record. Table: User \\[sys\\_user\\]\n\n</td></tr></tbody>\n</table><table id=\"table_tnj_253_kyb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the user has permission to view the specified service/service group.Possible values:\n\n-   true: User can view the specified service/service group.\n-   false: User can't view the specified service/service group.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method to check the specified user's ability to access the specified service group.\n\n```\nvar cmdbServGr = new GlideRecord('cmdb_ci_service_discovered');\ncmdbServGr.addQuery('sys_id', \"123123123123123123123123\");\ncmdbServGr.query();\nvar userId = gs.getUserID();\n\nvar bsManager = new SNC.BusinessServiceManager();\nwhile (cmdbServGr.next()) {\n  var answer = bsManager.isReadingPermitted(cmdbServGr, userId);\n\n  //do something with / according to the answer\n\n}\n```\n\n## BusinessServiceManager - migrateManualToApplicationService\\(String service\\_id\\)\n\nConverts a manual service to an application service.\n\n|Name|Type|Description|\n|----|----|-----------|\n|service\\_id|String|Sys ID of the manual service to convert.|\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if the migration to an application service succeeds.|\n\n```\nvar bsManager = new SNC.BusinessServiceManager();\nvar appService = bsManager.migrateManualToApplicationService(\"451047c6c0a8016400de0ae6df9b9d76\");\n```\n\n## BusinessServiceManager - populateApplicationService\\(String service\\_id, Number levels, String black\\_listed\\_relation\\_types\\)\n\nPopulates an application service with relations and CIs from the designated entry point.\n\n|Name|Type|Description|\n|----|----|-----------|\n|service\\_id|String|Sys ID of the application service to populate.|\n|levels|Number|Number of levels of CIs to add from the CMDB.|\n|black\\_listed\\_relation\\_types|String|Relation types to exclude when populating the application service.|\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if the operation is successful.|\n\n```\nvar bsManager = new SNC.BusinessServiceManager();\nvar appService = bsManager.populateApplicationService(\"5bf65ebeedb91300964f6fa662989533\", 10, \"Depends on::Used by\");\n```\n\n## BusinessServiceManager - removeCI\\(String service\\_id, String target\\_id\\)\n\nRemoves a manually created CI from an application service.\n\n<table id=\"table_bcz_py1_sdb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nservice\\_id\n\n</td><td>\n\nString\n\n</td><td>\n\nSys ID of the application service to remove a CI from.\n\n **Note:** Passing a GlideRecord object is also supported.\n\n</td></tr><tr><td>\n\ntarget\\_id\n\n</td><td>\n\nString\n\n</td><td>\n\nSys ID of the CI to remove from the application service.\n\n **Note:** Passing a GlideRecord object is also supported.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar bsManager = new SNC.BusinessServiceManager();\nvar appService = bsManager.removeCI(\"2fce42d80a0a0bb4004af34d7e3984c8\", \"3a290cc60a0a0bb400000bdb386af1cf\");\n```\n\n## BusinessServiceManager - removeEntryPoint\\(serviceId, endpointSysId\\)\n\nRemoves an existing entry point from the application service.\n\n|Name|Type|Description|\n|----|----|-----------|\n|serviceId|String|Sys\\_id of the application service to add the connection to.|\n|endpointSysId|String|Sys\\_id of the entry point endpoint to remove.|\n\n<table id=\"table_yj2_n32_zwb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag indicating that the entry point was successfully removed from the application service.\n\n Possible values:\n\n-   true: the update was successful.\n-   false: the update was not successful.\n\n</td></tr></tbody>\n</table>The following example removes the entry point associated with Sys\\_id “aa65ebeedb91300964f6fa6629895ss” from the given application service.\n\n```\nvar bsManager = new SNC.BusinessServiceManager();\nvar serviceId = \"5bf65ebeedb91300964f6fa662989533\";\nvar entrypointId = “aa65ebeedb91300964f6fa6629895ss”;\nbsManager.removeEntryPoint(serviceId, entrypointId);\n\n```\n\nOutput:\n\n```\ntrue\n```\n\n## BusinessServiceManager - removeManualConnection\\(String source\\_id, String endpoint\\_id, String service\\_id\\)\n\nRemoves a manually created connection and the connected CI from an application service.\n\n|Name|Type|Description|\n|----|----|-----------|\n|source\\_id|String|Sys ID of the CI connected to the endpoint.|\n|endpoint\\_id|String|Sys ID of the manually created connection to remove from the application service|\n|service\\_id|String|Sys ID of the application service to remove the connection from.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar bsManager = new SNC.BusinessServiceManager();\nvar appService = bsManager.removeManualConnection(\"3a307c930a0a0bb400353965d0b8861f\", \"60ce3176edb91300964f6fa6629895d1\", \"2fce42d80a0a0bb4004af34d7e3984c8\");\n```\n\n## BusinessServiceManager - updateEntryPoint\\(serviceId, endpointGr\\)\n\nUpdates an existing entry point in the application service.\n\n|Name|Type|Description|\n|----|----|-----------|\n|serviceId|String|Sys\\_id of the application service to add the connection to.|\n|endpointGr|Object|Glide Record object in the CI Endpoint \\[cmdb\\_ci\\_endpoint\\] table or its child table to add to the application service.|\n\n<table id=\"table_pht_422_zwb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag indicating the update was successfully applied to the entry point.\n\n Possible values:\n\n-   true: the update was successful.\n-   false: the update was not successful.\n\n</td></tr></tbody>\n</table>The following updateEntryPoint\\(\\) example shows how to update the connection with a new entry point.\n\n```\nvar now_GR = new GlideRecord(\"cmdb_ci_endpoint_http\");\nnow_GR.get(“11f65ebeedb91300964f6fa66298951”);\nnow_GR.setValue(“protocol”, “https”);\nvar bsManager = new SNC.BusinessServiceManager();\nvar serviceId = \"5bf65ebeedb91300964f6fa662989533\";\nbsManager.updateEntryPoint(serviceId,now_GR);\n\n```\n\nOutput:\n\n```\ntrue\n```\n\n"}}