Programme Utility Methods

Programme Utility Functions

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

getVal

_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:

function(data){
	var eventId = _i.utils.getVal(data, ["Event Id"], false);
	logger.info(eventId);
}

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.

Still need help? Contact Us Contact Us