Autopopulate service and service offerings field based on affected CI in incident form

Nivedha Y
Tera Expert

 Hi Community,

 

I have a requirement to autopopulate service and service offerings field based on affected CI selected in an incident form.

I have created Three dynamic CI groups (Gold, Silver, Bronze) and corresponding CI relationships for sync Service offerings and the dynamic CI groups (contains:contained by)

Parent: Service offering

Child: Dynamic CI Group

Followed the steps in this below docs:

https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/product/csdm-implementation...

 

Now, I wanted to autopopulate service and service offering associated to the CI affected. But, I dont know how to achieve this and I am new to CMDB module.

Can anyone please assist me on the same.
Thanks in advance.

 

 

4 REPLIES 4

Community Alums
Not applicable

Hi @Nivedha Y ,

Please look at this Property in the screenshot :

SandeepDutta_0-1708934576081.png

 

 

 

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Nivedha Y ,

 

I see you need this functionality on 'INCIDENT', were as Out of the box on change management there is UI action called "Refresh Impacted Services" that populates the Impacted Services related list at the bottom with the services impacted by the CI on the change. 

 

see if you can do the same for your incident module too..

 

That UI action calls a script include called CIUtils.   In the event you don't like the out of the box Impacted Services approach, you will need to use the CIUtils to populate your list field.   You can look at the Refresh Impacted Services UI action as an example on how to call it.

 

I hope this helps...


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Anubhav24
Mega Sage
Mega Sage

Hi @Nivedha Y ,

 

Can you try below code as per your requirement , we had worked on a similar scenario almost 2 years back :

 

getServicesfromCI: function(CI, company) {
var out = [];
var finalArray = [];
var splitCI = CI.toString().split(",");
for (var i = 0; i < splitCI.length; i++) {
out = this.getservicesfromCIBSA(splitCI[i], company);
this.COUNT = 0;
if (out)
finalArray.push(out);
}

return finalArray;
}

getservicesfromCIBSA: function(CI, company) {
var cmdbGroups = [];
var cmdbUtils = new global.cmdbUtils();

var relGr = new GlideRecord("cmdb_rel_ci");
relGr.addEncodedQuery("parent.sys_class_name=u_customer_business_service^type.nameINContains::Contained by,Depends on::Used by^childIN" + CI + "^parent.companyIN" + company);
relGr.query();

if (relGr.hasNext()) {
while (relGr.next()) {

this.cbs_array.push(relGr.getValue('parent'));
}

return this.arrayUtil.unique(this.cbs_array);
} else {
var splitCI = CI.toString().split(",");
for (var i = 0; i < splitCI.length; i++) {

var ciGr = cmdbUtils.getGrRecord(splitCI[i], 'cmdb_ci');

var cmdbGroupsTemp = cmdbUtils.getGroupForCI(ciGr);
var cmdbGroupTempSplit = cmdbGroupsTemp.toString().split(",");

cmdbGroups.push(cmdbGroupTempSplit);
}
var relGrCMDB = new GlideRecord("cmdb_rel_ci");
relGrCMDB.addEncodedQuery(" parent.sys_class_name=u_customer_business_service^type.name=Contains::Contained by^child.sys_class_name=cmdb_ci_query_based_service^child.ref_cmdb_ci_query_based_service.cmdb_group.group_nameIN" + cmdbGroups + "^parent.companyIN" + company);
relGrCMDB.query();

if (relGrCMDB.hasNext()) {
while (relGrCMDB.next()) {

this.cbs_array.push(relGrCMDB.getValue('parent'));
}
return this.arrayUtil.unique(this.cbs_array);
}
}
}

The above is used to populate service using CI , you need to customise it based on your scenario/variables usage, let me know if this works for you then we can connect for service offering as well. The variables passed in the function are self-explanatory by their names to decide what values are  being passed in form of variables.

Please mark helpful/correct if my response helped you.

 

Nivedha Y
Tera Expert

Hi,

Thank you all for the reply, I have tried with all the above solutions of your. Unfortunately, not able to achieve what I require. And I am very new to this CMDB part and couldn't understand how to do this.

Here, When I select the CI the service and service offerings field were not populated. 

NivedhaY_1-1708944453425.pngNivedhaY_2-1708944505324.pngNivedhaY_3-1708944536355.png

NivedhaY_4-1708944572647.png

PFA. Hope this will help to identify the solution.

Please guide me if any one have came across this type of scenario.