Currency Conversion on a Table
- Create an asset type for the currencies and have within the asset the conversion rate
- Create a workflow
- Add an asset search and reference this asset type
- Add a table with two columns
- One for the expense in the native currency
- One for the calculated expense in USD
- On the asset search add in
- "onChange": "/api/v3/flow/execute/activity/{$.id}?refreshLayout=true",\
- On the table
- Copy the “dataPath” value and past it into the “defaultValue” property
- Add the dataPath of the asset search into the “recalculateDefaultValueWhenDataPathChange” property
- On the expense conversion to USD add in the “value” property and include the correct value calculation (see video for more details)
- Done!
- After publishing the workflow, you can start a new work item. When you select a currency in the asset selector and enter expense values in the native currency column of the table the system will automatically calculate and display the equivalent amount in USD in the corresponding column.
{
"name": "taskOneNativeCurrency",
"label": "Native Currency",
"description": "",
"defaultValue": "",
"dataPath": "$.taskOne.nativeCurrency",
"dataSource": "work",
"isRequired": false,
"isReadOnly": false,
"isHidden": false,
"width": "col-6",
"condition": "",
"onChange": "/api/v3/flow/execute/activity/{$.id}?refreshLayout=true",
"dataKey": "data",
"recalculateDefaultValueWhenDataPathChange": [],
"validation": [],
"dataPathUpdate": "Manual",
"properties": {
"multiSelect": "single",
"thingType": "knowledge-base-conversionRate",
"addNewItem": false
}
}
{
"name": "taskOneExpenses",
"label": "Expenses",
"description": "",
"defaultValue": "$.taskOne.expenses",
"dataPath": "$.taskOne.expenses",
"dataSource": "work",
"isRequired": false,
"isReadOnly": false,
"isHidden": false,
"width": "col-12",
"condition": "",
"dataKey": "data",
"recalculateDefaultValueWhenDataPathChange": [
"$.taskOne.NativeCurrency"
],
"validation": [],
"dataPathUpdate": "Manual",
"properties": {
"showTitle": true,
"autoHeight": true,
"addRows": true,
"rowActions": [
"delete",
"duplicate"
],
"reorderRows": true,
"reorderColumns": true,
"dataKey": "data",
"disableColumnMenu": false,
"disableColumnPinning": false,
"sortable": true,
"groupable": true,
"columns": [
{
"type": "number",
"name": "expenseInNativeCurrency",
"displayName": "Expense in Native Currency",
"required": false,
"addNewItem": false,
"withCreateRequest": false,
"columnWidth": 200,
"sortable": true,
"editable": true,
"groupable": true,
"headerAlign": "left"
},
{
"type": "number",
"name": "expenseInUsd",
"displayName": "Expense in USD",
"value": "= expenseInNativeCurrency / {$.taskOne.nativeCurrency.data.1UnitUsd}",
"required": false,
"addNewItem": false,
"withCreateRequest": false,
"columnWidth": 200,
"sortable": true,
"editable": true,
"groupable": true,
"headerAlign": "left"
}
]
}
}