Record Data Type

The Record data type is a composite object that has a series of values assigned to specific field names. It's analogous to an object in Javascript or JSON data stuctures.

A Record can contain a variety of data types in it, and these values can be reference using dot notation on the variable. For example in the Record shown below:

<dcs.Var Name="TestRecord1" Type="Record"> <SetField Name="FullName" Value="Bob Testperson" /> <SetField Name="Phone" Value="608-111-3333" /> <SetField Name="Age" Value="Old Enough" /> </dcs.Var>

If you reference the field like this: <dc.Out></dc.Out> , you'd get the following output:

Old Enough

If the Field doesn't have a type set on creation or addition of the field, if will default to string.

Conditionals

HasField

The HasField conditional checks if a Field with a name matching the value and if so, returns true. The field does not have to have a value currently set, it merely needs to be present to return true.

<dcs.Var Name="TestVar1" Type="Record"> <SetField Name="Field1" Type="LocalDate" Value="2022-08-01" /> <SetField Name="Field2" Type="String" /> <SetField Name="Field3" Type="List" /> </dcs.Var> <dcs.With Target="$TestVar1"> <HasField Name="Field2" Handle="doesF2Exist" /> </dcs.With> <dcs.If Target="$doesF2Exist" Equals="True"> <dc.Out>TestVar1 has a Field2 present</dc.Out> </dcs.If>

Output:

TestVar1 has a Field2 present

IsFieldEmpty

The IsFieldEmpty conditional checks if the field is empty and returns it as a Boolean value to the variable listed in Handle .

<dcs.Var Name="TestVar1" Type="Record"> <SetField Name="Field1" Type="LocalDate" Value="2022-08-01" /> <SetField Name="Field2" Type="String" /> <SetField Name="Field3" Type="List" /> </dcs.Var> <dcs.With Target="$TestVar1"> <IsFieldEmpty Name="Field2" Handle="isF2Empty" /> </dcs.With> <dcs.If Target="$isF2Empty" Equals="True"> <dc.Out>TestVar1's Field2 is empty</dc.Out> </dcs.If>

Output:

TestVar1's Field2 is empty

Operations

Set

The Set operation tried to parse a JSON like objective between the Set tags and assign the appropriate fields to the Record. (For more on on JSON, click here ) Note that the text does not need to be in exact, strict JSON format and the text can potentially be parsed from a JavaScript object, for example.

<dcs.Var Name="TestVar1" Type="Record"> <Set> { "Name": "Bob", "Age": 35 } </Set> </dcs.Var> <dc.Out>TestVar1 is {$TestVar1}<br /></dc.Out>

Output:

TestVar1 is { "Age": 35, "Name": "Bob" }

Update

The Update operation is similar to Set but will try to update existing fields and add new ones to a Record with already existing information.

<dcs.Var Name="TestVar1" Type="Record"> <SetField Name="Name" Type="String" Value="Dave" /> <SetField Name="Hometown" Type="String" Value="Bobville" /> </dcs.Var> <dc.Out>TestVar1 is {$TestVar1}<br /></dc.Out> <dcs.With Target="$TestVar1"> <Update> { "Name": "Bob", "Age": 35 } </Update> </dcs.With> <dc.Out>TestVar1 is {$TestVar1}<br /></dc.Out>

Output:

TestVar1 is { "Name": "Dave", "Hometown": "Bobville" } TestVar1 is { "Age": 35, "Name": "Bob", "Hometown": "Bobville" }

SetField

Though the SetField operation is normally used in the initial declaration of the Record , it can also be used afterward to set the value again.

<dcs.Var Name="TestVar2" Type="Record"> <SetField Name="Start" Type="LocalDate" Value="2022-08-01" /> <SetField Name="Name" Type="String" Value="Bob" /> <SetField Name="Orders" Type="List" /> <SetField Name="Age" Type="Integer" Value="25" /> </dcs.Var> <dc.Out>{$TestVar2.Name}'s age is {$TestVar2.Age}<br /></dc.Out> <dcs.With Target="$TestVar2"> <SetField Name="Age" Value="26" /> </dcs.With> <dc.Out>{$TestVar2.Name}'s age is {$TestVar2.Age}<br /></dc.Out>

Output:

Bob's age is 25 Bob's age is 26

EnsureField

The EnsureField operation checks to see if the field already exists, and if it doesn't, it will create a new field with the Name and Type provided in the appropriate attributes.

<dcs.Var Name="TestVar2" Type="Record"> <SetField Name="Start" Type="LocalDate" Value="2022-08-01" /> <SetField Name="Name" Type="String" Value="Bob" /> <SetField Name="Orders" Type="List" /> <SetField Name="Age" Type="Integer" Value="25" /> </dcs.Var> <dcs.With Target="$TestVar2"> <EnsureField Name="Age" Type="Integer" /> </dcs.With> <dc.Out>$TestVar2 is {$TestVar2}<br /></dc.Out> <dcs.With Target="$TestVar2"> <EnsureField Name="NumberOfPets" Type="Integer" /> <SetField Name="NumberOfPets" Value="12" /> </dcs.With> <dc.Out>$TestVar2 is {$TestVar2}<br /></dc.Out>

Output:

$TestVar2 is { "Orders": [ ] , "Start": "2022-08-01", "Age": 25, "Name": "Bob" } $TestVar2 is { "Orders": [ ] , "Start": "2022-08-01", "NumberOfPets": "12", "Age": 25, "Name": "Bob" }

RemoveField

The RemoveField operation removes the field with the Name matching in the attribute.

<dcs.Var Name="TestVar2" Type="Record"> <SetField Name="Start" Type="LocalDate" Value="2022-08-01" /> <SetField Name="Name" Type="String" Value="Bob" /> <SetField Name="Orders" Type="List" /> <SetField Name="Age" Type="Integer" Value="25" /> </dcs.Var> <dcs.With Target="$TestVar2"> <RemoveField Name="Orders"/> </dcs.With> <dc.Out>TestVar2 is {$TestVar2}<br /></dc.Out>

Output:

TestVar2 is { "Start": "2022-08-01", "Age": 25, "Name": "Bob" }

NewList

The NewList operation creates a new List variable on a Field Name . This List can then be accessed and added to like any other List variable

<dcs.Var Name="TestVar2" Type="Record"> <SetField Name="Start" Type="LocalDate" Value="2022-08-01" /> <SetField Name="Name" Type="String" Value="Bob" /> <SetField Name="Age" Type="Integer" Value="25" /> </dcs.Var> <dcs.With Target="$TestVar2"> <NewList Name="Orders"/> </dcs.With> <dcs.With Target="$TestVar2.Orders"> <AddItem Type="String" Value="Order 1"/> <AddItem Type="String" Value="Order 2"/> </dcs.With> <dc.Out>TestVar2 is {$TestVar2}<br /></dc.Out>

Output:

TestVar2 is { "Orders": [ "Order 1", "Order 2" ] , "Start": "2022-08-01", "Age": 25, "Name": "Bob" }

NewRecord

The NewRecord operation creates a new Record variable on a Field Name . This Record can then be accessed and added to like any other Record variable

<dcs.Var Name="TestVar2" Type="Record"> <SetField Name="Start" Type="LocalDate" Value="2022-08-01" /> <SetField Name="Name" Type="String" Value="Bob" /> <SetField Name="Age" Type="Integer" Value="25" /> </dcs.Var> <dcs.With Target="$TestVar2"> <NewRecord Name="Order1"/> </dcs.With> <dcs.With Target="$TestVar2.Order1"> <SetField Name="Id" Type="String" Value="1" /> <SetField Name="Cost" Type="Decimal" Value="24.99" /> <SetField Name="OrderPlaced" Type="LocalDate" Value="2022-11-01" /> </dcs.With> <dc.Out>TestVar2 is {$TestVar2}<br /></dc.Out>

Output:

TestVar2 is { "Start": "2022-08-01", "Order1": { "OrderPlaced": "2022-11-01", "Id": "1", "Cost": 24.99 } , "Age": 25, "Name": "Bob" }

FieldsToList

The FieldsToList operation takes the record referenced in Target , gathers a list of all fields in the record and assigns it to a new list named in the Handle variable

<dcs.Var Name="TestVar2" Type="Record"> <SetField Name="Start" Type="LocalDate" Value="2022-08-01" /> <SetField Name="Name" Type="String" Value="Bob" /> <SetField Name="Age" Type="Integer" Value="25" /> </dcs.Var> <dcs.With Target="$TestVar2"> <FieldsToList Handle="ListVar"/> </dcs.With> <dc.Out>ListVar is {$ListVar}<br /></dc.Out>

Output:

ListVar is [ "Start", "Age", "Name" ]

CopySelectFields

The CopySelectFields operation takes the fields from the variable designated in the Fields and Source attributes respectively and adds them to the Records marked in the Target attribute. Please make sure there's no leading or trailing whitespace between the field names and that they are comma separated.

<dcs.Var Name="TestVar2" Type="Record"> <SetField Name="Start" Type="LocalDate" Value="2022-08-01" /> <SetField Name="Name" Type="String" Value="Bob" /> <SetField Name="Age" Type="Integer" Value="25" /> </dcs.Var> <dcs.Var Name="TestVar3" Type="Record"> </dcs.Var> <dcs.With Target="$TestVar3"> <CopySelectFields Source="$TestVar2" Fields="Name,Age"/> </dcs.With> <dc.Out>TestVar2 is {$TestVar2}<br /></dc.Out> <dc.Out>TestVar3 is {$TestVar3}<br /></dc.Out>

Output:

TestVar2 is { "Start": "2022-08-01", "Age": 25, "Name": "Bob" } TestVar3 is { "Name": "Bob" }

Merge

The Merge operation compares the target Record with the Record listed in the Value attribute, and combines the two. If an existing field is found, it will overwrite the value. Otherwise, it will create a new field in the target record.

<dcs.Var Name="TestVar2" Type="Record"> <SetField Name="Start" Type="LocalDate" Value="2022-08-01" /> <SetField Name="Name" Type="String" Value="Dave" /> <SetField Name="Age" Type="Integer" Value="25" /> </dcs.Var> <dcs.Var Name="TestVar3" Type="Record"> <SetField Name="Name" Type="String" Value="Bob" /> <SetField Name="Hometown" Type="String" Value="Bobville" /> </dcs.Var> <dc.Out>TestVar2 is {$TestVar2}<br /></dc.Out> <dc.Out>TestVar3 is {$TestVar3}<br /></dc.Out> <dcs.With Target="$TestVar2"> <Merge Value="$TestVar3"/> </dcs.With> <dc.Out>TestVar2 is {$TestVar2}<br /></dc.Out>

Output:

TestVar2 is { "Start": "2022-08-01", "Age": 25, "Name": "Dave" } TestVar3 is { "Name": "Bob", "Hometown": "Bobville" } TestVar2 is { "Start": "2022-08-01", "Age": 25, "Name": "Bob", "Hometown": "Bobville" }