Having a little trouble updating a business group in a script using builtin methods. I am able to get both custom properties into the business group object, but when I send back the updated business group... the getInfrastructureBusinessGroupsService().update(#businessGroup) method only sets the FIRST custom property no matter which one is first.
I do know that Sid put out a Custom Property Toolkit (written by Dan Lindsey: http://dailyhypervisor.com/vrealize-automation-vcac-6-1-custom-property-toolkit-for-vco/) that would handle this activity easily, but I am trying these updates directly for learning purposes.
Can anybody take a look at the below and at least tell me if I am just doing it wrong... and that is why it isn't working?
//setup a couple custom properties owner = new vCACCAFECustomProperty; owner.setName("businessGroupOwner"); owner.setValue(businessGroupOwner); owner.setIsEncrypted(false); owner.setIsRuntime(false); //this is Prompt User costCentre = new vCACCAFECustomProperty; costCentre.setName("costCenter"); costCentre.setValue(costCenter); costCentre.setIsEncrypted(false); costCentre.setIsRuntime(false); //this is Prompt User var myArray = new Array(); myArray.push(costCentre); myArray.push(owner); /*Reversed myArray.push(owner); myArray.push(costCentre); */ System.log(myArray.length); // this ends up being 2 as expected businessGroup.setCustomProperties(myArray); checkProps = businessGroup.getCustomProperties(); for each (prop in checkProps){ System.log(prop.getName()); } // BOTH PROPERTIES ARE IN THE LOCAL BUSINESS GROUP OBJECT AS EXPECTED // Send updated Business Group back into Cafe through host service // Behaves as an overwrite myService = host.createInfrastructureClient().getInfrastructureBusinessGroupsService(); myService.update(businessGroup); // Only sends in FIRST custom Property no matter which is first