How to update the descriptive values or selectable options for a field.
When you create Fields in Risk Cloud, you have the ability to name them, label them, add selectable options, among many other configuration options. In this article, we will walk through the following:
-
Updating a Field's Label using the Risk Cloud API
-
Updating a Field's Select Values using the Risk Cloud API
Obtaining proper API authentication
Prior to any interaction with Risk Cloud’s APIs we will need to set the authorization header. Instructions on how this can be accomplished can be found here.
Updating a Field's Label
We will start with a Field named "Severity." Severity has selectable values of "Low," "Medium," and "High."
Currently, the label for this Field is also "Severity," but let's say we want to update that to "Severity Level." To do this, we need to send a PATCH request to the "field" endpoint, which will update the field's label. Before we are able to send this PATCH request, we need to determine what our "field_id" is with a GET request.
Request Type: GET
URL: http://your-company.logicgate.com/api/v1/fields/workflow/WORKFLOW_ID/values
Response:
[
...,
{
"fieldType": "SELECT",
"id": "41g5OQaU",
"name": "Severity",
"label": "Severity",
"tooltip": null,
"currentValues": [
{
"discriminator": "Common",
"id": "00wJG4sm",
"valueType": "Common",
"discriminator": "Common",
"textValue": "Low",
"numericValue": 1.0,
"isDefault": false,
"archived": false,
"priority": 1,
"empty": false,
"fieldId": "41g5OQaU"
},
{
"discriminator": "Common",
"id": "PkdY2hpR",
"valueType": "Common",
"discriminator": "Common",
"textValue": "Medium",
"numericValue": 2.0,
"isDefault": false,
"archived": false,
"priority": 2,
"empty": false,
"fieldId": "41g5OQaU"
},
{
"discriminator": "Common",
"id": "lLt8ZWoS",
"valueType": "Common",
"discriminator": "Common",
"textValue": "High",
"numericValue": 1.0,
"isDefault": false,
"archived": false,
"priority": 3,
"empty": false,
"fieldId": "41g5OQaU"
}
],
"operators": [
"NULL",
"NOT_NULL",
"EQUALS",
"NOT_EQUALS"
],
"convertibleTo": [
"CHECKBOX",
"MULTI_SELECT",
"RADIO"
],
"fieldType": "SELECT",
"valueType": "Common",
"validTypeForCalculationInput": true,
"global": false,
"discrete": true
}
]
From this response, we are able to find the specific field_id that we would like to update. In our case we will use "41g5OQaU" as the field_id in the following PATCH request.
Request Type: PATCH
URL: http://your-company.logicgate.com/api/v1/fields/FIELD_ID_HERE?access_token=YOUR_TOKEN_HERE
Request:
{
"fieldType":"SELECT",
"name":"Severity",
"label":"Severity Level",
"id":"41g5OQaU",
"tooltip":null
}
This PATCH request updates the field label from “Severity” to “Severity Level.” Upon submission of the request we will get a response object of the updated field
Response:
{
"fieldType": "SELECT",
"id": "41g5OQaU",
"name": "Severity",
"label": "Severity Level",
"tooltip": null,
"operators": [
"NULL",
"NOT_NULL",
"EQUALS",
"NOT_EQUALS"
],
"convertibleTo": [
"CHECKBOX",
"MULTI_SELECT",
"RADIO"
],
"valueType": "Common",
"discrete": true,
"global": false
}
We can see that our field's label has been updated.
Updating a Field's Selectable Value
In another scenario, we may want to update the text/numeric value for one of the selectable options. For example, let's assume we want to change the "High" selectable value in our Severity field to have a numeric value of 10 instead of 1.
To accomplish this, we first need to get the current values (selectable values) of the field that we want to edit. We will use the following GET request.
Request Type: GET
URL: http://your-company.logicgate.com/api/v1/fields/FIELD_ID
Response:
{
"fieldType": "SELECT",
"id": "41g5OQaU",
"name": "Severity",
"label": "Severity Level",
"tooltip": null,
"currentValues": [
{
"discriminator": "Common",
"id": "IXxbj7uk",
"valueType": "Common",
"textValue": "Low",
"numericValue": 1,
"isDefault": false,
"archived": false,
"priority": 3,
"empty": false,
"default": false,
"fieldId": "41g5OQaU"
},
{
"discriminator": "Common",
"id": "ziJtKBiZ",
"valueType": "Common",
"textValue": "Medium",
"numericValue": 1,
"isDefault": false,
"archived": false,
"priority": 2,
"empty": false,
"default": false,
"fieldId": "41g5OQaU"
},
{
"discriminator": "Common",
"id": "fwy1ntpD",
"valueType": "Common",
"textValue": "High",
"numericValue": 1,
"isDefault": false,
"archived": false,
"priority": 1,
"empty": false,
"default": false,
"fieldId": "41g5OQaU"
}
],
...
}
The most important part of this response is the currentValues array, as it contains all of the selectable options for our select field named "Severity." From this response, we will take the relevant object out of the currentValues array and modify it. Notice below we have taken the object containing the textValue of "High," and we have updated numericValue from 1 to 10.
{
"discriminator": "Common",
"id": "fwy1ntpD",
"valueType": "Common",
"textValue": "High",
"numericValue": 10,
"isDefault": false,
"archived": false,
"priority": 1,
"empty": false,
"default": false,
"fieldId": "41g5OQaU"
}
Now we will send a POST request with an array containing the above object, and this will update our field. Note: If you would like to update multiple field values at once, simply include an object in your array for every field update you would like to make.
Request Type: POST
URL: https://your-company.logicgate.com/api/v1/currentValues/fwy1ntpD
Request:
[
{
"discriminator": "Common",
"id": "fwy1ntpD",
"valueType": "Common",
"textValue": "High",
"numericValue": 10,
"isDefault": false,
"archived": false,
"priority": 1,
"empty": false,
"default": false,
"fieldId": "41g5OQaU"
}
]
Response:
[
{
"discriminator": "Common",
"id": "fwy1ntpD",
"valueType": "Common",
"textValue": "High",
"numericValue": 10,
"isDefault": false,
"archived": false,
"priority": 1,
"empty": false,
"default": false,
"fieldId": "41g5OQaU"
}
]
This response confirms that we have updated the numericValue from 1 to 10, and we can confirm that the numeric value has been updated in field.
For more information about the Risk Cloud API you can read our Developer Center.
Get Risk Cloud API Updates in Your Inbox
A new Postman Workspace, new API-first endpoints, and detailed API usage guides are just a few ways we’ve enhanced the Risk Cloud Open API in 2023. Subscribe to our new Developer Relations newsletter for easy access to these new resources, API updates, endpoint deprecation notices, and more!
Not an API user? Explore the Developer Portal or share this link with your development team to learn more.
Comments
0 comments
Please sign in to leave a comment.