vCO Workflow Script to Check if a Custom Attribute Exists

vCO Workflow Script to Check if a Custom Attribute Exists

 

var objVcSdkConnection;
	objVcSdkConnection = objVcVirtualMachine.vimHost;
	
var objVcCustomFieldsManager;
	objVcCustomFieldsManager = objVcSdkConnection.customFieldsManager;

var blnFound;
	blnFound = false;

var arrVcCustomFieldDef;
	arrVcCustomFieldDef = objVcCustomFieldsManager.field;

for (var i = 0; i < arrVcCustomFieldDef.length; i++)
{
	var objVcCustomFieldDef;
		objVcCustomFieldDef = arrVcCustomFieldDef[i];

	if (objVcCustomFieldDef.name == strCustomFieldName)
	{
		blnFound = true;
		
		break;
	}
}

return blnFound;

Leave a Reply