Skip to content

Instantly share code, notes, and snippets.

@chelnak
Last active June 22, 2021 06:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelnak/813167f381ab99acc1e6 to your computer and use it in GitHub Desktop.
Save chelnak/813167f381ab99acc1e6 to your computer and use it in GitHub Desktop.
A vRO Scriptable task that will parse a JSON Resource Element
//vRO Scriptable task to parse a resource element and
//edit values
//inputs:
//jsonTemplate : ResourceElement
//reservationName : String
//subtenantId : String
//outputs
//payload : String
//Get the content of the Resource Element
template = jsonTemplate.getContentAsMimeAttachment();
//Use JSON.parse to parse content in to a useable object
jsonObject = JSON.parse(template.content);
//Now we can manipulate individual values, which makes the template dynamic
jsonObject['name'] = reservationName;
jsonObject['subTenantId'] = subtenantId;
//Convert object back to string ready to POST
payload = JSON.stringify(jsonObject);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment