List of methods supported in macro

You can execute JavaScript code from within your flow, by using the Macro element.

We have the following types of functions: Getting values, Updating values, Getting property values and Setting property values. Each of these have the following content types – Array, Boolean, Content, Date/Time, Number, Object, Password, String, Value.

When getting or updating a value, the name of the value (optionally including a property name) will be expected in the following formats:

  1. {![My Value]}
  2. {![My Object].[Property Name]}

Getting values

  1. state.getArray(valueName) – Returns a StateObjectData Array containing the objectData for a List value.
  2. state.getBooleanValue(valueName) – Returns a JavaScript Boolean value.
  3. state.getContentValue(valueName) – Returns a JavaScript String value.
  4. state.getDateTimeValue(valueName) – Returns a JavaScript Date value.
  5. state.getNumberValue(valueName) – Returns a JavaScript Number value.
  6. state.getObject(valueName) – Returns a StateObjectData Object containing the objectData for an Object.
  7. state.getPasswordValue(valueName) – Returns a JavaScript String value.
  8. state.getStringValue(valueName)  – Returns a JavaScript String value.
  9. state.getValue(valueName) – Returns a JavaScript String value regardless of ContentType. Only applicable to scalar ContentTypes: String, Number, Boolean, Content, Password, DateTime.

Updating values

  1. state.setArray(valueName, StateObjectData[]) – Sets the List Value to the StateObjectData Array given.
  2. state.setBooleanValue(valueName, boolean) – Sets the Boolean value to the JavaScript Boolean given.
  3. state.setContentValue(valueName, string) – Sets the Content Value to the JavaScript String given.
  4. state.setDateTimeValue(valueName, datetime) – Sets the DateTime Value to the JavaScript Date given.
  5. state.setNumberValue(valueName, number) – Sets the Number Value to the JavaScript Number given.
  6. state.setObject(valueName, StateObjectData) – Sets the Object Value to the StateObjectData Object given.
  7. state.setPasswordValue(valueName, string) – Sets the Password Value to the JavaScript String given.
  8. state.setStringValue(valueName, string) – Sets the String Value to the JavaScript String given.
  9. state.setValue(valueName, string) – Sets the Value to the JavaScript String given regardless of ContentType. Only applicable to scalar ContentTypes: String, Number, Boolean, Content, Password, DateTime.

When updating an object or a list (array) value, we will need to pass in StateObjectData. This can be fetched via a state.getArray or state.getObject call.

We can also create new objects, like this:

  1. state.setArray(valueName, StateObjectData[])  –  StateObjectData[]  is an Array either created by one more state.createObject objects or fetched from state.getArray.
  2. state.setObject(valueName, StateObjectData) – StateObjectData is a single Object either created with state.createObject or fetched from state.getObject.
  3. state.createObject(typeElementId)  – Returns a newly created  StateObjectData  Object of the type specified via the typeElementId.

Getting property values

The StateObjectData objects support the following methods for querying their properties:

  1. getPropertyArray(typePropertyId) – Returns a StateObjectData Array value of the Array property with the Property Id given.
  2. getPropertyBooleanValue(typePropertyId) – Returns a JavaScript Boolean value of the Boolean property with the Property id given.
  3. getPropertyContentValue(typePropertyId) – Returns a JavaScript String value of the Content property with the Property Id given.
  4. getPropertyDateTimeValue(typePropertyId) – Returns a JavaScript Date value of the DateTime property with the Property Id given.
  5. getPropertyNumberValue(typePropertyId) – Returns a JavaScript Number value of the Number property with the Property Id given.
  6. getPropertyObject(typePropertyId) – Returns a StateObjectData Object value of the Object property with the Property Id given.
  7. getPropertyPasswordValue(typePropertyId) – Returns a JavaScript String value of the Password property with the Property Id given.
  8. getPropertyStringValue(typePropertyId) – Returns a JavaScript String value of the String property with the Property Id given.
  9. getPropertyValue(typePropertyId) – Returns a JavaScript String value of the property with the Property Id given (regardless of ContentType). Only applicable to scalar ContentTypes: String, Number, Boolean, Content, Password, DateTime.

Setting property values

The StateObjectData objects support the following methods for updating property values:

  1. setPropertyArray(typePropertyId, StateObjectData[]) – Sets the Array property on the Object with the property id given to the StateObjectData array given.
  2. setPropertyBooleanValue(typePropertyId, boolean) – Sets the Boolean property on the Object with the Property Id given to the JavaScript Boolean given.
  3. setPropertyContentValue(typePropertyId, string) – Sets the Content property on the Object with the Property Id given to the JavaScript String given.
  4. setPropertyDateTimeValue(typePropertyId, Date)  – Sets the DateTime property on the Object with the Property Id given to the JavaScript Date given.
  5. setPropertyNumberValue(typePropertyId, number) – Sets the Number property on the Object with the Property Id given to the JavaScript Number given.
  6. setPropertyObject(typePropertyId, StateObjectData) – Sets the Object property on the Object with the Property Id given to the StateObjectData Object given.
  7. setPropertyPasswordValue(typePropertyId, string) – Sets the Password property on the Object with the Property Id given to the JavaScript String given.
  8. setPropertyStringValue(typePropertyId, string)– Sets the String property on the Object with the Property Id given to the JavaScript String given
  9. setPropertyValue(typePropertyId, string) – Sets the property on the Object with the Property Id given to the JavaScript String given (regardless of ContentType). Only applicable to scalar ContentTypes: String, Number, Boolean, Content, Password, DateTime.

Null checking objects and lists

This applies to getArray, getObject, getPropertyArray and getPropertyObject:

 

You may also want to see:

  1. Boomi Flow developer documentation 
  2. Creating a macro
  3. Deleting a macro
  4. Tutorial: Using a JavaScript macro

Check out the glossary for a definition of terms and key concepts that appear in the Boomi Flow website, drawing tool, technical documentation, blogs, and marketing communications.

If you need to take a closer look, click on the images to enlarge them. Have a question? Click the Help button on the bottom right-hand corner of this page to ask.