Data / Increment variables
Task in alpha phase
This Data Factory task is in phase. You can contact the Product-Live team at contact@product-live.com if you want more details and get an early access.
This task allows to atomically increment (or decrement) the numeric value of a variable.
Task name:
Examples
json
{
"name": "data-variable-increment",
"taskReferenceName": "increment_variable",
"description": "Increment variable by 1",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"request": {
"method": "INLINE",
"contentType": "application/json",
"model": "default",
"json": {
"operations": [
{
"key": "a",
"type": "increment",
"context": {
"variableId": "12345"
},
"valueField": "value",
"incrementBy": 1
}
]
}
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
json
[
{
"key": "a",
"response": {
"object": "variable",
"id": "12345",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-05-17T10:30:00.000Z",
"key": "MY_COUNTER",
"name": "My Counter",
"status": "ACTIVE",
"value": "11",
"isSecret": false
}
}
]1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
json
{
"name": "data-variable-increment",
"taskReferenceName": "decrement_variable",
"description": "Decrement variable by 5",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"request": {
"method": "INLINE",
"contentType": "application/json",
"model": "default",
"json": {
"operations": [
{
"key": "a",
"type": "increment",
"context": {
"variableId": "12345"
},
"valueField": "value",
"incrementBy": -5
}
]
}
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
json
[
{
"key": "a",
"response": {
"object": "variable",
"id": "12345",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-05-17T10:30:00.000Z",
"key": "MY_COUNTER",
"name": "My Counter",
"status": "ACTIVE",
"value": "5",
"isSecret": false
}
}
]1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Definition
| Property | Type | Required | Description |
|---|---|---|---|
| The name (or type) of the task | |||
| The unique name of the task in your job. It is used to reference this task in the workflow. | |||
| The functional description of this task in your job. | |||
The type of the task. It must be SUB_WORKFLOW. | |||
| : | true: the job continues if there is an error on this task. false: the job fails. | ||
| Input parameters of the task. See below |
Inputs Parameters
| Property | Type | Required | Description |
|---|---|---|---|
| The Product-Live API key. If not provided, an automatically generated API key will be used to perform the request on behalf of the current user. If provided, the given API key will be used to perform the request. | |||
| See below | |||
Today, application/json and application/xml are supported. | |||
INLINE: The request body is provided inline in the request object. ATTACHMENT: The request body is provided as an attachment in the request object. | |||
| The request body as a JSON object. | |||
| See below | |||
| A unique key to identify the element in the batch. This key will be associated to the element in the output. | |||
| The element to create or update. See examples below | |||
| Some element may require additional context to be created or updated. | |||
| The request body as a file. | |||
| The outputs of the request. Default: [{"mediaType": "application/json", "outputMode": "INLINE", "outputKey": "json"}]. | |||
The media type of the output. Today, application/json and application/xml are supported. | |||
INLINE: The output is provided inline in the output object. ATTACHMENT: The output is provided as an attachment in the output object. INLINE is only supported for mediaType=application/json | |||
| The key of the output. Either json or xml | |||
Default: DEFAULT. The model/format used in the output. Today, only 'DEFAULT' is supported. |
contentType=application/json
Each operation in the operations array must have type set to "increment".
json
{
"operations": [
{
"key": "a",
"type": "increment",
"context": {
"variableId": "12345"
},
"valueField": "value",
"incrementBy": 1
}
]
}1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
json
{
"operations": [
{
"key": "a",
"type": "increment",
"context": {
"variableId": "12345"
},
"valueField": "value",
"incrementBy": 5
},
{
"key": "b",
"type": "increment",
"context": {
"variableId": "12346"
},
"valueField": "value",
"incrementBy": 1
}
]
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Context requirements
| Property | Type | Required | Description |
|---|---|---|---|
| The ID of the variable to increment |
Increment operation properties
| Property | Type | Required | Description |
|---|---|---|---|
| A unique key to identify the operation in the batch. This key will be associated to the result in the output. | |||
Must be "increment" | |||
Context object containing the variableId | |||
The name of the field to increment on the target entity. For variables, use "value". | |||
The value to add. Default: 1. Use a negative number to decrement. |
Outputs
| Property | Type | Description |
|---|---|---|
An object containing the outputs of the task. Each output key is the key of the output defined in the outputs[][outputKey] input parameter. |
Example
If your input parameters is as follows:
json
{
"...": "...",
"outputs": [
{
"mediaType": "application/json",
"outputMode": "INLINE",
"outputKey": "json_inline"
},
{
"mediaType": "application/xml",
"outputMode": "ATTACHMENT",
"outputKey": "xml_attachment"
}
]
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
The output will be as follows:
json
{
"outputs": {
"json_inline": {
"...": "...",
"...": "..."
},
"xml_attachment": {
"url": "..."
}
}
}1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Json output - outputs[].outputMode=INLINE and outputs[].mediaType=application/json
output.jsonis an array of objects as defined in the variables API.jsonis the default output key but may be changed by setting theoutputKeyproperty.
Example output:
json
[
{
"key": "a",
"response": {
"object": "variable",
"id": "12345",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-05-17T10:30:00.000Z",
"key": "MY_COUNTER",
"name": "My Counter",
"status": "ACTIVE",
"value": "11",
"isSecret": false
}
}
]1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Error handling
| Scenario | Behavior |
|---|---|
Variable value is not a number (e.g. "abc") | Task fails immediately with error message |
Variable value is empty ("") or null | Treated as 0, then incremented |
incrementBy is not a valid number | Task fails immediately with error message |
Limits and additional notes
When the
outputMode=INLINEis selected, the maximum number of elements returned by this task is limited to1000. If more elements are to be returned, the task ends with an error. To export up to the maximum of elements, use thelimitinput parameter to limit the number of elements return.The variable value must be numeric (integer or decimal). Non-numeric values will cause the task to fail.
Operations in a batch are executed sequentially. Multiple increments on the same variable in a single batch are supported and will be applied one after another.
Additional examples
Increment variable with dynamic variableId
job.json
json
{
"name": "data-variable-increment",
"taskReferenceName": "increment_counter",
"description": "Increment a counter variable",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"failOnError": true,
"request": {
"method": "INLINE",
"contentType": "application/json",
"model": "default",
"json": {
"operations": [
{
"key": "a",
"type": "increment",
"context": {
"variableId": "${find_variable.output.json[0].id}"
},
"valueField": "value",
"incrementBy": 1
}
]
}
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Expected output:
json
[
{
"key": "a",
"response": {
"object": "variable",
"id": "12345",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-05-17T10:30:00.000Z",
"key": "MY_COUNTER",
"name": "My Counter",
"status": "ACTIVE",
"value": "11",
"isSecret": false
}
}
]1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Increment multiple variables in a batch
job.json
json
{
"name": "data-variable-increment",
"taskReferenceName": "increment_counters",
"description": "Increment multiple counters",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"request": {
"method": "INLINE",
"contentType": "application/json",
"model": "default",
"json": {
"operations": [
{
"key": "a",
"type": "increment",
"context": {
"variableId": "12345"
},
"valueField": "value",
"incrementBy": 1
},
{
"key": "b",
"type": "increment",
"context": {
"variableId": "12346"
},
"valueField": "value",
"incrementBy": 5
}
]
}
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Expected output:
json
[
{
"key": "a",
"response": {
"object": "variable",
"id": "12345",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-05-17T10:30:00.000Z",
"key": "MY_COUNTER_A",
"name": "My Counter A",
"status": "ACTIVE",
"value": "11",
"isSecret": false
}
},
{
"key": "b",
"response": {
"object": "variable",
"id": "12346",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-05-17T10:30:00.000Z",
"key": "MY_COUNTER_B",
"name": "My Counter B",
"status": "ACTIVE",
"value": "15",
"isSecret": false
}
}
]1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Increment the same variable multiple times in a batch
Operations are executed sequentially. Each increment reads the latest value before updating.
job.json
json
{
"name": "data-variable-increment",
"taskReferenceName": "increment_same_variable_3_times",
"description": "Increment the same variable 3 times (+5, +3, +2 = +10 total)",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"failOnError": true,
"request": {
"method": "INLINE",
"contentType": "application/json",
"model": "default",
"json": {
"operations": [
{
"key": "a",
"type": "increment",
"context": {
"variableId": "12345"
},
"valueField": "value",
"incrementBy": 5
},
{
"key": "b",
"type": "increment",
"context": {
"variableId": "12345"
},
"valueField": "value",
"incrementBy": 3
},
{
"key": "c",
"type": "increment",
"context": {
"variableId": "12345"
},
"valueField": "value",
"incrementBy": 2
}
]
}
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Expected output:
json
[
{
"key": "a",
"response": {
"object": "variable",
"id": "12345",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-05-17T10:30:00.000Z",
"key": "MY_COUNTER",
"name": "My Counter",
"status": "ACTIVE",
"value": "5",
"isSecret": false
}
},
{
"key": "b",
"response": {
"object": "variable",
"id": "12345",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-05-17T10:30:00.000Z",
"key": "MY_COUNTER",
"name": "My Counter",
"status": "ACTIVE",
"value": "8",
"isSecret": false
}
},
{
"key": "c",
"response": {
"object": "variable",
"id": "12345",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-05-17T10:30:00.000Z",
"key": "MY_COUNTER",
"name": "My Counter",
"status": "ACTIVE",
"value": "10",
"isSecret": false
}
}
]1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Decrement a variable
Use a negative incrementBy value to decrement.
job.json
json
{
"name": "data-variable-increment",
"taskReferenceName": "decrement_variable",
"description": "Decrement a counter by 1",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"failOnError": true,
"request": {
"method": "INLINE",
"contentType": "application/json",
"model": "default",
"json": {
"operations": [
{
"key": "a",
"type": "increment",
"context": {
"variableId": "12345"
},
"valueField": "value",
"incrementBy": -1
}
]
}
}
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Expected output:
json
[
{
"key": "a",
"response": {
"object": "variable",
"id": "12345",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-05-17T10:30:00.000Z",
"key": "MY_COUNTER",
"name": "My Counter",
"status": "ACTIVE",
"value": "9",
"isSecret": false
}
}
]1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16