I have a case where I'm attempting to update the same custom property across several business groups to a new value. However, when I use the vCACCAFESubtenantHelper.updateCustomProperty function, it silently fails to update the subtenant property with the new value. It definitely gets to that call, and my logging statements all look as I'd expect. Here is my code:
# The host, productCodePropName, and whatIf variables are static attributes or input parameters
var detectHyphenBetweenCodeAndDescriptionWithWhitespaceRegex = /(?!^\d{4})\s*-\s*/;
var subtenants = vCACCAFEEntitiesFinder.getSubtenants( host );
for( var s in subtenants ){
var subtenant = subtenants[s];
System.log( "Evaluating ProductCode for " + subtenant.name );
var productCode = null;
try{
productCode = vCACCAFESubtenantHelper.getCustomPropertyValue( subtenant, productCodePropName );
} catch ( e ){
if( /java\.lang\.NullPointerException/.test( e ) ){
System.error( productCodePropName + " does not exist for subtenant " + subtenant.name + ", skipping." );
} else {
throw e;
};
};
if( productCode ){
System.log( "\tOld ProductCode: " + productCode );
productCode = productCode.replace( detectHyphenBetweenCodeAndDescriptionWithWhitespaceRegex, '-' ).toUpperCase();
System.log( "\tNew ProductCode: " + productCode );
if( !whatIf ) {
System.warn( "\tUpdating subtenant to use the new ProductCode" );
var isRuntime = vCACCAFESubtenantHelper.isCustomPropertyPromptUser( subtenant, productCodePropName );
System.debug( "\t\tisRuntime: " + isRuntime );
var isEncrypted = vCACCAFESubtenantHelper.isCustomPropertyEncrypted( subtenant, productCodePropName );
System.debug( "\t\tisEncrypted: " + isEncrypted );
vCACCAFESubtenantHelper.updateCustomProperty( subtenant, productCodePropName, productCodePropName, productCode, isEncrypted, isRuntime );
};
};
};
When I look at the Inventory tab of vRO and navigate to the business group, the property is not updated (buried in that literal map string). Checking the business group on the vRA side also shows that the custom property on the business groups has not been updated. Am I doing something incorrectly here?