CMDB groups and changes

Eric M
Giga Expert

In the Istanbul and jakatra release came the concept of CMDB groups. anyone using them with change ? and how are you using them?

Best,

Eric

1 ACCEPTED SOLUTION

johnfw
Kilo Expert

Hi Eric, wish I could help, but have the same question.


In the CI field in CHG, I want users to be able to select a group, and then all CIs within that group to populate the 'affected CIs' related list.


We tried overriding the reference qualifier with "sys_class_name=cmdb_ci_server^ORsys_class_name=cmdb_group" but this didn't work.



If you have had any luck, please share



John


View solution in original post

34 REPLIES 34

You mention the CMDBGroupAPI Script Include but on my Kingston instance with the CMDB Group plugin installed, I don't see any script like this or any references to such a script anywhere.  I see a doc page but no script.  Is there a script include that I need to install from somewhere in order to use this API?

Hey all!  For those who are interested in using CMDBGroup in conjunction with the SNGuru enhancement to CI Groups, I have been able to easily integrate the two using the CMDBGroupAPI, so I thought I would share.  I knew if there were an API it couldn't be too hard to do this.  To implement this I just added a CMDB Group reference field to the CI Group class, to serve as the "controller" for the CI group membership.  I then created a UI action (code snippet below) to refresh the membership, though this refresh could be triggered from any number of different events as needed.

Here is the code:

refreshMembers(current);

function refreshMembers(ci_group) {
	//u_group_controller is a reference field of type CMDBGroup, which controls the membership of the group if present
    //Complete list of group members from CMDBGroup; may want to look further at what happens in case of ACLs hiding some members.
	var response = sn_cmdbgroup.CMDBGroupAPI.getAllCI(current.u_group_controller, false);
    var parser = new JSONParser();
    var parsed = parser.parse(response);
    if (parsed.result) {
		var idList = parsed.idList; 
		
		//Remove all automatically added items in the list
		var members = new GlideRecord("u_cmdb_ci_grmember");
		members.addQuery("u_ci_group", ci_group.sys_id);
		members.query();
		while (members.next()) {
			if (!idList[members.sys_id]) {
				members.deleteRecord();
			}
		}

		idList.forEach( function(sys_id) {
    
			//Add each group member from the group controller to the CI group
			var currentMember = new GlideRecord("u_cmdb_ci_grmember");
			currentMember.addQuery("u_ci_group", ci_group.sys_id);
			currentMember.addQuery("u_ci", sys_id);
			currentMember.query();
			if (currentMember.getRowCount() == 0) {
				var newMember = new GlideRecord("u_cmdb_ci_grmember");
				newMember.initialize();
				newMember.u_ci_group = ci_group.sys_id;
				newMember.u_ci = sys_id;
				newMember.insert();
			}
		} );
    } else {
        //gs.print("fail to retrieve list, errors: " + JSON.stringify(parsed.errors));
    }
}

It is easy to see now how the CMDB Group can be leveraged to do a variety of different kinds of tasks in ServiceNow with just a little bit of implementation work.  And the fact that you can incorporate multiple encoded CI queries, CMDB queries, and manual lists certainly adds to the usefulness, even though the CMDB Query Builder is still not the most reliable or flexible tool.  Looking forward to incorporating this elsewhere.  While logical grouping of CIs may not be the typical focus of configuration management, they are an effective tool both for configuration managers and CI owners.

Paul Coste2
Giga Expert

Eric, I think I've got a better answer for you down below.  See my reply on how to integrate CMDB Group with CI Group. And you could use a similar approach if you wanted to skip the SNGuru modification and stay more out-of-box, simply by adding the CMDB Group reference to the Change and then similar code to populate the Affected CIs table of the Change instead.  There's your answer!  Hope this helps!  I'm really looking forward to using it myself, now that I know how it works.

Hey Paul,

It appears that your solution that you referenced above "best answer for you down below" is missing. I'm very interested if you have updated your solution now with the latest status of ServiceNow (we are on Paris) or if your original solution is still applicable.

We would like to leverage the CMDB Groups capability to create "Patching Groups" and associate infrastructure CIs to that group and then allow for the selection of that patching group in a Change template to have the related CIs automatically be populated in the "Affected CI" tab.

Thoughts?

Hi tomcollins,

This post on the new capability of Dynamic CI group in Paris maybe of use.

Hope this helps

Thanks

Sam