Home > Forum > Tips&Tricks > Filling choice field using only name via REST API

Filling choice field using only name via REST API
0

Hi,
I'm trying to update an existing instance or create a new instance with REST API. I'm using api version 3.0 and Postman. I want to put data to choice field, but I know only name from data source. It's possible at all?
I tried to put a value in two ways:

"formFields": [
{
"guid": "c2e37260-5d57-410e-997c-1f19bb12a4c0",
"svalue": "USD"
}
]
System always trying to fit value "USD" to Id, but ID is different, 3 for example.

and

"formFields": [
{
"guid": "c2e37260-5d57-410e-997c-1f19bb12a4c0",
"value":
{"name": "USD" }
}
]
System always trying to search data source with empty ID.
Changing the data source type (fixed value list, SP list) and choice field operation mode doesn't help.
I have problem with choice field, but person field works fine, and I can send well.

I have the same problem after upgrade to new wersion of webcon.

If the field type is picker then is ok, but when is autocomplete then for example import from Excel to itemlist dosn't work, becouse in excel i have only name but no id. If in filed configuration I will select only name to search then import is working, but when you try choose value by hand in field only id apear. This behavior is only when we use DataSource and as Id i choose other column than ID (System ID).

Webcon broke soething.

WEBCON

Hi Bartek

The value of choice fields always requires an ID value in the REST API.
This is because only the ID column is unique - this ensures an unambiguous match of the passed value.

If the value of the field is 3#USD,you can put it in two ways
- set value: "3" - then the id will be verified and the value 3#USD will be selected from the data source
- set value "3#USD" - then the value will be searched in the data source and the given value of the name will be compared, e.g. for the value "3#PLN" will be a name mismatch error.

If you don't have ID value, you currently have two options:
- call endpoint /api/data/v4.0/db/{dbId}/elements/resolveFieldValue/{idguid} and match your name with available values
- send name value using technical text field and on the transtion path set choose field by "change value of single field" action.


Adding set choice field by other values ​​other than ID is planned in the next version of BPS

In reply to: Marcin

I have the same problem after upgrade to new wersion of webcon.

If the field type is picker then is ok, but when is autocomplete then for example import from Excel to itemlist dosn't work, becouse in excel i have only name but no id. If in filed configuration I will select only name to search then import is working, but when you try choose value by hand in field only id apear. This behavior is only when we use DataSource and as Id i choose other column than ID (System ID).

Webcon broke soething.

My case is on 2021.1.4.55. I have dictionary process as source without any filter now. ID in choice field is different column than standard (guid from dictionary). I have created my own in WFD_AttInt1.
Choice field with behavior:
-dropdown - error: Value with id: 'USD' does not exist\r\n\r\n,
-autocomplete with seraching based on name only - Value with id: 'PLN' does not exist\r\n\r\n\r\n,
-popup search window with seraching based on name only - Value with id: 'PLN' does not exist\r\n\r\n\r\n.