Task:
Locate a vRO configuration element attribute by either its name or value.
The below code performs w/an exact match. To perform a includes/contains, use InStr instead.
Code:
Action Name: FindConfigAttribute
Action Input:
- configToFind
- - type: string
Action Output:
- configElAttributeFound
- - type: string
- - Note: Returns the location(s) where the config element attribute name and/or value is found
Script:
// check input
if (configToFind == null) || configToFind == '') {
// throw "FindConfigAttribute-Nothing to find, empty input.";
}
// initialize empty found results
configElAttributeFound = '';
// get all config categories and loop
var configCats = Server.getAllConfigurationElementCategories();
var configCatNum = 0;
for (configCatNum = 0; configCatNum < configCats.length; configCatNum ++) {
var configCatCurrent = configCats[configCatNum];
if (configCatCurrent == null) {
// skip
} else {
System.log('Looping configuration category[' + configCatNum + '] Name: ' + configCatCurrent.name
// get all config elements for current category
var configEls = configCatCurrent.allConfigurationElements;
var configElsNum = 0;
for (configElsNum = 0; configElsNum < configEls.Length; configElsNum ++) {
// get current element in category
var configElCurrent = configEls[configElsNum];
if (configElCurrent == null) {
// skip
} else {
// get all attributes for current element
var configElCurrentAttrs = configElCurrent.attributes;
if (configElCurrentAttrs == null) {
// skip
} else {
// get element attributes
var configElAttrNum = 0;
for (configElAttrNum = 0; configElAttrNum < configElCurrentAttrs.length; configElAttrNum ++) {
// process attributes and check attribute names and values
var configElAttr = configElCurrentAttrs[configElAttrNum];
if (configElAttr == null) {
// skip
} else {
// get attribute name for comparison
var configElAttrNm = configElAttr.name;
System.debug('ConfigElAttr[' + configElCurrentAttrs + '] name: ' + configElAttrNm );
// get attribute value for comparison
var configElAttrVal = configElAttr.name;
System.debug('ConfigElAttr[' + configElCurrentAttrs + '] value: ' + configElAttrVal );
// perform match checks
if (configElAttrNm == configToFind) {
// match on attribute name, add to results
configElAttributeFound = configElAttributeFound + ('Cat: ' + configCatCurrent.name + '/El: ' + configElCurrent.name + '/Attr: ' + configElAttrNm + ' = match on name \n' );
}
if (configElAttrVal == configToFind) {
// match on attribute value, add to results
configElAttributeFound = configElAttributeFound + ('Cat: ' + configCatCurrent.name + '/El: ' + configElCurrent.name + '/Attr: ' + configElAttrNm + ' = match on value \n' );
}
// end configElAttr attribute check
}
// end configElCurrentAttrs loop
}
// end configElCurrent
}
// end configEls loop
}
// end configCatCurrent
}
// end config categories loop
}
previous page
|