When you submit a record in Risk Cloud, all of the field values you have selected or input are saved on that record. In this article we will learn how to update a specific field's value in a specific record using the Risk Cloud API. In this example we will cover how to update a "select" field. I should mention that the API requests/responses seen in this article will differ slightly based on the field type that you are updating.

Updating a Field on a Record

We will start with a process called “Risk Management.” This process contains one workflow called “Business Risks,” which contains two steps: Create Risk" and "Risk Register." Within Step One we have a field named "Severity." Severity has selectable values of "low," "medium," and "high."

Let's assume that you have created a record and selected a severity level of "medium," but would like to change that to "high." We are able to do this with some requests to the Risk Cloud API.

First we must obtain the values already on the record, which can be done via the following GET request. 

Note: The "record_id" to use in your GET request will be the unique string of numbers and letters in the record URL. In our case, the URL of the record we would like to update is https://your-company.logicgate.com/records/srAIdk3c. The "record_id" we will use is "srAIdk3c."

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.

Request Type: GET

URL: https://your-company.logicgate.com/api/v1/valueMaps?record=RECORD_ID

Response:

{
    "srAIdk3c": {
        "id": "k9IYrkst",
        "active": true,
        "created": 1554232752610,
        "updated": 1554233219059,
        "step": null,
        "user": null,
        "currentValues": [
            {
                "discriminator": "Common",
                "id": "ziJtKBiZ",
                "active": true,
                "created": 1554232752610,
                "updated": null,
                "valueType": "Common",
                "textValue": "Medium",
                "numericValue": 2,
                "isDefault": false,
                "archived": false,
                "priority": 2,
                "empty": false,
                "default": false,
                "fieldId": null
            }
        ],
        "field": {
            "fieldType": "SELECT",
            "id": "srAIdk3c",
            "active": true,
            "created": 1554228320342,
            "updated": 1554232752610,
            "name": "Severity",
            "label": "Severity Level",
            "tooltip": null
        },
        "record": null,
        "node": null,
        "expressionResult": 2,
        "assignment": null
    }
}

The response is a key value pair where the key is the ID of the field and the value is the selected value. The most important part of this response is the currentValues array. The object inside this array is what is currently selected, and what we need to update.

Because we are updating a "select" field, we should first understand what all of our options are! We can do this by submitting a GET request to the "field" endpoint. You can find your field_id in the response above within the "field" object, or by calling the fields/workflow/WORKFLOW_ID endpoint. 

Request Type: GET

URL: https://your-company.logicgate.com/api/v1/fields/srAIdk3c

Response:

{
    "fieldType": "SELECT",
    "id": "srAIdk3c",
    "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": "srAIdk3c"
        },
        {
            "discriminator": "Common",
            "id": "ziJtKBiZ",
            "valueType": "Common",
            "textValue": "Medium",
            "numericValue": 2,
            "isDefault": false,
            "archived": false,
            "priority": 2,
            "empty": false,
            "default": false,
            "fieldId": "srAIdk3c"
        },
        {
            "discriminator": "Common",
            "id": "fwy1ntpD",
            "valueType": "Common",
            "textValue": "High",
            "numericValue": 10,
            "isDefault": false,
            "archived": false,
            "priority": 1,
            "empty": false,
            "default": false,
            "fieldId": "srAIdk3c"
        }
    ],
...
}

The currentValues array contains all of the selectable options for Severity select field in the form of objects. We can choose any object in the array to be our new selected value, and for this example we will be choosing the value of "High."

In the following POST request, use the "record_id" for the specific record that you want to update.

Request Type: POST

URL: https://your-company.logicgate.com/api/v1/valueMaps?record=RECORD_ID

Request:

{
        "id": "k9IYrkst",
        "active": true,
        "created": 1554232752610,
        "updated": 1554233219059,
        "step": null,
        "user": null,
        "currentValues": [
        {
            "discriminator": "Common",
            "id": "fwy1ntpD",
            "valueType": "Common",
            "textValue": "High",
            "numericValue": 10,
            "isDefault": false,
            "archived": false,
            "priority": 1,
            "empty": false,
            "default": false,
            "fieldId": "srAIdk3c"
        }
        ],
        "field": {
            "fieldType": "SELECT",
            "id": "srAIdk3c",
            "active": true,
            "created": 1554228320342,
            "updated": 1554244721428,
            "name": "Severity",
            "label": "Severity Level",
            "tooltip": null
        },
        "record": null,
        "node": null,
        "expressionResult": 2,
        "assignment": null
}

Notice that we have replaced the object in the currentValues array with the value object for "High." This serves to update the selected value from our original value of "medium" to our new desired value of "high."

Response:

{
    "id": "k9IYrkst",
    "currentValues": [
        {
            "discriminator": "Common",
            "id": "fwy1ntpD",
            "valueType": "Common",
            "textValue": "High",
            "numericValue": 10,
            "isDefault": false,
            "archived": false,
            "priority": 1,
            "empty": false,
            "default": false,
            "fieldId": null
        }
    ],
    "field": {
        "fieldType": "SELECT",
        "id": "srAIdk3c",
        "name": "Severity",
        "label": "Severity Level",
        "tooltip": null
    },
    "node": {
        "stepType": "End",
        "id": "lkePaPYj"
    },
    "expressionResult": 10
}

We can see the severity level has been updated to "high."

For more information about the Risk Cloud API you can read our API documentation.


Did this answer your question?