Skip to Content

Scripting example in Jitterbit App Builder - Humanizer

This example demonstrates how to set cell values using an action registered on the Filter event. It leverages the Humanizer library included with App Builder. In this example, the script generates a user friendly description of the file size.

Table schema

Column Data Type Primary Key Auto-generate Nullable
FileId GUID Yes Yes No
FileName NVARCHAR(255) No No No
FileSize INTEGER No No Yes
FileSizeDescription NVARCHAR(50) No No Yes

Note that the FileSizeDescription column does not need to be defined on the table: it can be defined on the business object.

Script

#r "Humanizer.dll"

using Humanizer.Bytes;

foreach (EventRow row in Table.Rows)
{
    int fileSize = row["FileSize"].GetValueAsInteger();
    var byteSize = new ByteSize(fileSize);
    row["FileSizeDescription"].Value = byteSize.ToString("#.#");
}