Programme Utility Methods

Programme Utility Functions

These methods can be used within any programme step that allows the use of javascript.


_i.utils.getVal(<queryObject>, <element>, <defaultValue>);

queryObject - Base object.
element - An array of the field you are looking for. This can be any level deep.
defaultValue - (optional) Returned value if element is not present in object. Will return null by default if no value is not specified.

The getVal function is used to ensure that conditional variables you are working with never get returned as undefined. This function will return a 'default' value if the data your working with doesn't exist or hasn't been defined. See usage example below:

	var eventId = _i.utils.getVal(data, ["Event Id"], false);;

If data['Event Id']  exists then the value of data['Event Id'] is returned. 

If data['Event Id']  doesn't exist (undefined) the third parameter of this function is returned. In the above example the variable 'eventId' would equal false.



date - Date to be parsed.

The parseDateValue function is used to parse a date stored in a programme's programme data, whatever it's format. So whether the format is a string, object, or number It will correctly parse the date.

It can be combined with moment.js as in the following example:

moment(_i.utils.parseDateValue(data["__trigger"]["Booking"]["Arrival Date"])).month();):

	var month = moment(_i.utils.parseDateValue(data["__trigger"]["Booking"]["Arrival Date"])).month();):; 

Still need help? Contact Us Contact Us