Creating and editing forms that contain Yes/no lists fields using the API

On the previous part, we showed how yes/no lists are structured in the JSON sent by the RPM API. On this part, we’ll show how to add forms and edit the values in a yes/no lists field.

ProcFormAdd

The API endpoint to add a form to a process is ProcFormAdd, we’ll add a new form to the process created on the previous part:

POST http://localhost/rpm/Api2.svc/ProcFormAdd HTTP/1.1
host: localhost

{
    "Key": "7c2c1037-b6fd-4b0a-b403-9ed39062ad76",
    "ProcessID": "2781",
    "Form": {
        "Fields": [
            {
                "Field": "Yes/No List field",
                "Value": "{\"Values\":[{\"OptionID\":14321195,\"Value\":1,\"Comment\":\"Comment for this option\"},{\"OptionID\":14321196,\"Value\":2,\"Comment\":\"\"},{\"OptionID\":14321198,\"Value\":1,\"Comment\":\"\"}]}"
            }
        ]
    }
}

Note: The response from the request to ProcFormAdd will contain the internal FormID for the new form. This is useful if you need to be able to edit the form afterwards.

The field on the new form:
ProcFormAdd

ProcFormEdit

To edit a form, we use the ProcFormEdit API endpoint:

POST http://localhost/rpm/Api2.svc/ProcFormEdit HTTP/1.1
host: localhost

{
    "Key": "7c2c1037-b6fd-4b0a-b403-9ed39062ad76",
    "ProcessID": "2781",
    "Form": {
        "FormID": 221498,
        "Fields": [
            {
                "Field": "Yes/No List field",
                "Value": "{\"Values\":[{\"OptionID\":14321195,\"Value\":1,\"Comment\":\"Updated comment for this option\"},{\"OptionID\":14321196,\"Value\":1,\"Comment\":\"\"},{\"OptionID\":14321198,\"Value\":2,\"Comment\":\"\"}]}"
            }
        ]
    }
}

The field on the updated form:
ProcFormEdit

Posted in API Usage Examples
%d bloggers like this: