Orchestrator Function: Convert an Array of Objects to an Array of Properties

by Simon Sparks · 1 November 2025

To use this function add it to the class library file named Utilities.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: Utilities.ts

Description: Orchestrator Function to Convert an Array of Objects to an Array of Properties

Function ConvertObjectArrayToArrayOfProperties

publicstaticConvertObjectArrayToArrayOfProperties<T>(arrUnknown:T[],strValuePropertyName:string="id",strLabelPropertyName:string="name"):Properties[]{

letarrProperties:Properties[]=arrUnknown.map((objUnknown:T):Properties=>{

letstrValue:string=objUnknown[strValuePropertyName];
letstrLabel:string=objUnknown[strLabelPropertyName];

letobjProperties:Properties=newProperties()
objProperties.put("value",strValue);
objProperties.put("label",strLabel);

returnobjProperties;
});

returnarrProperties;
}

Example of Usage:

letarrProperties:Properties[]=Utilities.ConvertObjectArrayToArrayOfProperties(arrVcVirtualMachine,"id","name");

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like