How to use a profile variable to store and set values in a data object - kwantu/platformconfiguration GitHub Wiki
Created by Rob Worthington on Aug 16, 2018. Copied from Kwantu Wiki on 2018-12-18.
This article explains how to use profile variables. This allows us to set values as a profile variable in one workflow and read it in another workflow.
In the example below we read a taxonomy label and code from one process and use that to set the same value in another workflow process into a data object.
1. Storing a value as a variable
In the example below a value is read from a data object:
Parameter | Example | Meaning |
---|---|---|
indicatorSetId |
wwfEcoregion |
The set ID of the data object from which you want to read a value that will be set as a profile variable |
status |
pending |
Read from the pending or approved model |
elementId |
ecoregion/code |
The element ID that you want to read from. In this case it is an elSelect , so we include the code |
name |
projectVariable |
The name for the variable that you are setting |
scope |
profile |
The scope at which the variable is set. Could be profile or subProfileSubProcessInstance |
variableType |
adhoc |
Is the variable adhoc or periodic. If periodic then variables are stored in sequences to match the periodic nature of the DO (data object) |
This action is repeated twice to set a different variable for the taxonomy label and code.
Code example 1.
{
"_seq": 7,
"method": {
"variables": {
"setVariable": {
"data": {
"indicator": {
"indicatorSetId": "wwfEcoregion",
"context": "",
"status": "pending",
"elementId": "ecoregion/code"
}
},
"name": "projectVariable",
"scope": "profile",
"variableType": "adhoc"
}
}
},
"_id": "setVariableActionProjects",
"description": {
"i18n": {
"en": "English",
"_id": "uuid"
}
}
},
{
"_seq": 8,
"method": {
"variables": {
"setVariable": {
"data": {
"indicator": {
"indicatorSetId": "wwfEcoregion",
"context": "",
"status": "pending",
"elementId": "ecoregion/label"
}
},
"name": "projectVariable2",
"scope": "profile",
"variableType": "adhoc"
}
}
},
"_id": "setVariableActionProjects2",
"description": {
"i18n": {
"en": "English",
"_id": "uuid"
}
}
}
2. Reading a variable and setting it in a data object
In this example, we are reading the variable and using it to set the value in a different data object and workflow.
Parameter | Example | Meaning |
---|---|---|
profile |
projectVariable |
The name given to the variable in the action where you set it |
path |
WWFIUCNPartnerDetails.region.code |
The path for where the value is to be set |
This action is also repeated twice to set the variable for both the taxonomy label and code.
Code example 2:
{
"_id": "getNodeValue",
"_seq": 2,
"description": {
"i18n": {
"_id": "uuid",
"en": "Used to set the profile variable as the eco region"
}
},
"method": {
"indicator": {
"setValue": {
"data": {
"variable": {
"profile": "projectVariable"
}
},
"path": "WWFIUCNPartnerDetails.region.code"
}
}
}
},
{
"_id": "getNodeValue2",
"_seq": 3,
"description": {
"i18n": {
"_id": "uuid",
"en": "Used to set the profile variable as the eco region"
}
},
"method": {
"indicator": {
"setValue": {
"data": {
"variable": {
"profile": "projectVariable2"
}
},
"path": "WWFIUCNPartnerDetails.region.label"
}
}
}
}