Skip to main content

Enforce Character Limit on Fields

When extracting data from Outcomes, you may need to truncate a field, setting a specific character limit. For example, the system you're importing data into may have a 30 character limit, and your applications may contain first names that are longer than 30 characters. Using this advanced configuration, you can strip the additional characters, allowing these fields to meet your qualifications.

Include the Field in Your Export

To apply this configuration, you'll first need to identify the field you need to truncate. Then, determine the number of characters you want to use as a limit to this field's length. You'll need this information to modify the code for this configuration. Next, you can begin building your export and customizing that field.

  1. Find and select the field from the Available Fields area.

  2. Once the field is selected, click the function icon.

  3. A Field Expression window opens containing the Field Key for your selected field. Next, to truncate this field, you'll add a JavaScript Expression.

  4. Copy the following code into the Expression field. After this is done, you'll need to modify the expression, making it work with your selected field.
return (FIELD.KEY.TO.TRUNCATE) ? FIELD.KEY.TO.TRUNCATE.substring(0,30) : '';

The result looks similar to this example, which enforces a 30 character limit on the field:


Modify the Code

As seen in the example above, for the code to work properly, you'll need to modify it as follows:

  1. Add the target field key inside the first set of parentheses (i.e., replace FIELD.KEY.TO.TRUNCATE with the field key of the field you wish to truncate).
  2. Add the target field key before ".substring..." (i.e., replace FIELD.KEY.TO.TRUNCATE.substring with a new version that includes your intended field key).
  3. In the code above, the character limit is 30. If you have a different character limit, put that in place of the 30 in the code. For example, replace substring(0,30) with substring(0,45) to enforce a 45 character limit.
  4. Click Update to keep your changes. Continue building your export as desired.
  • Was this article helpful?