List of methods supported in macro

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

Let’s take a look!

Naming schemes

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.setBooleanValue(valueName, boolean)
  2. state.setContentValue(valueName, string)
  3. state.setDateTimeValue(valueName, datetime)
  4. state.setNumberValue(valueName, number)
  5. state.setPasswordValue(valueName, string)
  6. state.setStringValue(valueName, string)
  7. state.setValue(valueName, string)

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.setObject(valueName, StateObjectData) – StateObjectData is a single object either created with state.createObject or fetched from  state.getObject
  2. state.setArray(valueName, StateObjectData[])  –  StateObjectData[]  is an array either created by one more state.createObject objects or fetched from state.getArray 
  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. getPropertyValue(typePropertyId) 
  2. getPropertyStringValue(typePropertyId) 
  3. getPropertyContentValue(typePropertyId) 
  4. getPropertyPasswordValue(typePropertyId) 
  5. getPropertyNumberValue(typePropertyId) 
  6. getPropertyDateTimeValue(typePropertyId) 
  7. getPropertyBooleanValue(typePropertyId) 
  8. getPropertyArray(typePropertyId) 
  9. getPropertyObject(typePropertyId) 

Setting property values

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

  1. setPropertyValue(typePropertyId, string) 
  2. setPropertyStringValue(typePropertyId, string) 
  3. setPropertyContentValue(typePropertyId, string) 
  4. setPropertyPasswordValue(typePropertyId, string) 
  5. setPropertyNumberValue(typePropertyId, number) 
  6. setPropertyDateTimeValue(typePropertyId, Date) 
  7. setPropertyBooleanValue(typePropertyId, boolean) 
  8. setPropertyArray(typePropertyId, StateObjectData[]) 
  9. setPropertyObject(typePropertyId, StateObjectData) 

Null checking objects and lists

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.