Using DataCheckpoint variable
This example shows how to easily use predefined constant DataCheckpoint on JS statement.
Motivation
Suppose we have list of entries (ID, Name, Autonumber) and we have to make Autonumber incremented behalf of last stored number in DataCheckpoint.
Input schema
| Column | Data type |
|---|---|
| ID | number |
| Name | string |
| Autonumber | number |
Input data
| ID | Name | Autonumber |
|---|---|---|
| 1 | Smith | 1 |
| 2 | Johnson | 2 |
DataCheckpoint from last TaskRun
const DataCheckpoint = 10;
Ouput schema
| Column | Data type |
|---|---|
| ID | number |
| Name | string |
| Autonumber | number |
JavaScript statement
var output = inputData.map(function(item) { // transforming function applied to each input record
return { // returns transformed record
ID: item.ID, // copied ID from input
Name: item.Name, // copied Name from input
Autonumber: item.ID + DataCheckpoint // new derived property created as sum of current ID and DataCheckpoint constant value from last TaskRun
};
});
return output; // returning re-mapped array
First run
Output data
| ID | Name | Autonumber |
|---|---|---|
| 1 | Smith | 11 |
| 2 | Johnson | 12 |
new DataCheckpoint value will be 12
Second run
Output data
| ID | Name | Autonumber |
|---|---|---|
| 1 | Smith | 13 |
| 2 | Johnson | 14 |
new DataCheckpoint value will be 14
...