Scriptlet: Split data field values

Let's say you collect phone number as a single field on your ion form but need to export this as three separate values. This scriptlet splits phone and saves it into three ion data collection fields.

// splits and saves respondent.phone into three LiveBall data collection fields
// respondent.phone must be collected in xxx-xxx-xxxx format for this example
var phone = respondent.phone;
var phoneParts = newArray();
phoneParts = phone.split("-");
actionSaveData("area code", phoneParts[0]); // "areacode" represents the data name to save value into
actionSaveData("prefix", phoneParts[1]); // "prefix" represents the data name to save value into
actionSaveData("suffix", phoneParts[2]); // "suffix" represents the data name to save value into

If you have any questions, please contact us on help@rockcontent.com. 😀