vCO Workflow Script to Check if a Custom Property Exists

vCO Workflow Script to Check if a Custom Property Exists

 

var arrvCACVirtualMachine;
	arrvCACVirtualMachine = Server.findAllForType("vCAC:VirtualMachine", "VMUniqueID eq '" + objVCVirtualMachine.config.instanceUuid + "'");

var objvCACVirtualMachine;
	objvCACVirtualMachine = arrvCACVirtualMachine[0];

var objvCACEntity;
	objvCACEntity = objvCACVirtualMachine.getEntity();

var objvCACHost;
	objvCACHost = Server.findForType("vCAC:VCACHost", objvCACEntity.hostId); 

var arrVCACEntityProperties;
	arrVCACEntityProperties = objvCACEntity.getLink(objvCACHost, "VirtualMachineProperties");

var blnStatus;
	blnStatus = false;

for ( var i = 0; i < arrVCACEntityProperties.length; i++ )
{
	var objVCACEntityProperties;
		objVCACEntityProperties = arrVCACEntityProperties[i];

	var strPropertyName;
		strPropertyName = objVCACEntityProperties.getProperty("PropertyName");
	
	if ( strPropertyName == strCustomPropertyName )
	{
		blnStatus = true;
			
		break;
	}	
}

return blnStatus;

Leave a Reply