Populate Business Service Based on CI Selection

Steve Kelly
Mega Sage

Hi all,

New to ServiceNow, and am in the set up and configuration stage. Here is what we would like to do:

On the Incident form, we would like Business Service to be populated, based off the Configuration Item that is selected. This would

only apply wherever there is a relationship between the CI and a Business Service (we have all of our Applications and some other CI types

related to a Business Service. The relation ship is usually Business Service depends on CI).

From researching I see this is probably possible using business rules with a script or with some use of dot-walking or both. Anyone have a

suggestion here?

Much appreciated,

Steve

1 ACCEPTED SOLUTION

Hi Steve - you could use the combination of a Dynamic Reference Qualifier + Script Include, but here's a simpler solution:



  1. The Incident table already has Business service [business_service] field (inherited from the Task table). Add this field to the Incident form.
  2. Configure the Dictionary settings for the Business service field as below in the Reference Specification tab (you   need to use the Dictionary's Advance view to see these fields):
    Reference: Business Service
    Use reference qualifier: Advanced
    Reference qual: javascript:'sys_idIN' + new CIUtils().servicesAffectedByCI(current.cmdb_ci);
  3. Save the Dictionary changes.
  4. Open a new or existing Incident form and test. In case a CI is not related to any Business Service, the list won't show anything.


find_real_file.png


View solution in original post

24 REPLIES 24

Hello @drjohnchun 

I have similar type of requirement .i have created three custom fields.

1]configuration items which is referring cmdb_ci table

2]parent ci 

3]child ci

so when a user selects a configuration item based on that configuration I want to show related child ci and parent in respective fields. I spent a lot of time on this but not getting expected output.

please guide me on this.

Thank You.

Hi John,

Can you please help me out with the function servicesAffectedByCI to return the value in a on change client script so that if there is only one matching service then auto populate the Service else show the list as a reference
I cant seem to figure out and make changes to the function as per my requirement

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Steve, included out of the box is a script included called CIUtils that can help you with this.   The "Refresh Impacted Services" that John Chun mentions utilizes this script include.   Basically it will leverage the CI relationships to go up the hierarchy and provide you with a listing of the services associated to your CI.   You can read more about it here:


CIUtils - ServiceNow Wiki



You will want to leverage the servicesAffectedByCI function and pass it the current.cmdb_ci.   So for example:


var serviceIDs = new CIUtils().servicesAffectedByCI(current.cmdb_ci);



An array will be returned so if you have more than one service associated, you can loop through them or you can just set it to the first one like:



current.business_service = serviceIDs[0];


Michael,



Thank you for the advice, I think we will try going with this method. Would this be a UI Script that would be run on the Incident form or how would we implement the code?



Cheers,



Steve


Levent
Kilo Explorer

Hi,

I have the same question. I know the Configuration Item and want to populate the corresponding the Business Service Offering. I want to do this by using the REST API calls.

For example:

By using https://community.servicenow.com/community?id=community_question&sys_id=f5d64ba5db1cdbc01dcaf3231f9619c2 I can get the user sys_id based on user name.

I am looking for a corresponding REST API calls.

Thank you in advance,

 

Levent