Orchestrator Function: Set ResourceElement Content

by Simon Sparks · 20 January 2026

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

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

Filename: Utilities.ts

Function: SetResourceElementContent

Description: This function gets the string text content of a ResourceElement from Orchestrator.

public static SetResourceElementContent(strResourceElementCategoryName: string, strResourceElementName: string, strResourceElementContent: string): boolean {

  try {
    let objResourceElementCategory: ResourceElementCategory = Server.getResourceElementCategoryWithPath(strResourceElementCategoryName);

    let arrResourceElement: ResourceElement[] = objResourceElementCategory.resourceElements;

    let objResourceElement: ResourceElement = arrResourceElement.find((objResourceElement: ResourceElement): boolean => {
      return objResourceElement.name === strResourceElementName;
    });

    let objMimeAttachment: MimeAttachment = objResourceElement.getContentAsMimeAttachment();
    objMimeAttachment.content = strResourceElementContent;

    objResourceElement.setContentFromMimeAttachment(objMimeAttachment);

    return true;
  }
  catch {
    return false;
  }
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like