JavaScript function: isInGroup

Searches for one configuration item (CI) in a Configuration Management list or query group.

Syntax

lib.ciGrouping.isInGroup( ci, groupName );

Arguments

The following arguments are valid for this function:

Name Data type Required Description
ci String Yes This argument contains the CI record you want to search for in the group.
groupName String Yes This argument contains the name of the configuration group where you want to search for the CI.

Return values

A Boolean value: true or false.

The function returns true if the function successfully finds the CI in the list or query group. The function returns false if it is unable to find the CI in the list or query group.

Description

This function is part of a system JavaScript and should not be directly modified.

This function searches for a CI in list or query groups and returns a Boolean value of true if successful.

Example

This example attempts to search for a CI in the following groups:

  • A list group
  • A query group

This example requires the following sample data:

  • Create a list group containing one or more configuration items (for example, a list group called "test01" containing the configuration item "DEFAULT Phone 0001")
  • Create a query group containing one or more configuration items (for example, a query group called "test04" containing the configuration items where type equals "telecom")
/* Create variables to store CI group name and the results of returnGroupMembers */
var targetCIGroup;
var targetCI;
var members;

function findInGroup( ci, group )
{
 inGroupTest = lib.ciGrouping.isInGroup( ci, group );
 if ( inGroupTest == true )
 {
  print( "Success. Found " + ci + " in " + group );
 }
 else
 {
  print( "Error. Could not find " + ci + " in " + group );
 }
}

/* Test returnGroupMembers on a list group. */
print( "Now testing isInGroup on list group...\n" );
targetCIGroup = "test01";
targetCI = "DEFAULT Phone 0001";
members = lib.ciGrouping.returnGroupMembers( targetCIGroup )
print( "Looking for " + targetCI + " in " + targetCIGroup + "..." );
findInGroup( targetCI, targetCIGroup );
print( "The current members of " + targetCIGroup + " are:\n" + members );

/* Test returnGroupMembers on a query group. */
print( "Now testing isInGroup on query group...\n" );
targetCIGroup = "test04";
targetCI = "DEFAULT Phone 0006";
members = lib.ciGrouping.returnGroupMembers( targetCIGroup )
print( "Looking for " + targetCI + " in " + targetCIGroup + "..." );
findInGroup( targetCI, targetCIGroup );
print( "The current members of " + targetCIGroup + " are:\n" + members );