Solved

How I Update value of Radio and Select via API??

  • 31 August 2020
  • 1 reply
  • 363 views

Userlevel 5

"Hello guys, can anybody help me?

I am not able to modify values ​​of a radio and a select. Would anyone give me an example of how I change the values via API.

 

icon

Best answer by Marcos Carvalho 3 September 2020, 16:03

View original

1 reply

Userlevel 6
Badge +6

Hey Paulo, 

 

First you need to query the pipe fields to know the fields ids and the options available.

{
pipe(id: 301418657) {
start_form_fields {
id
type
options
}
}
}

Payload:

 

{
"data": {
"pipe": {
"start_form_fields": [
{
"id": "is_this_a_radio",
"type": "radio_vertical",
"options": [
"Yes ",
"No"
]
},
{
"id": "select",
"type": "select",
"options": [
"first option",
"second option",
"third option"
]
}
]
}
}
}

 

 

Then you can fetch the data from a specific card:

 

{
card(id: 383518002) {
fields {
name
value
}
}
}

 

Payload:

{
"data": {
"card": {
"fields": [
{
"name": "Select",
"value": "second option"
},
{
"name": "Is this a radio? ",
"value": "Yes "
}
]
}
}
}

 

 

With this mutation you can change the card value with some other option you searched before: 

 

 

mutation {
updateFieldsValues(input:
{nodeId: 383518002, values: [
{fieldId: "is_this_a_radio", value:"No"},
{fieldId: "select", value: "third option"}
]}) {
clientMutationId
success
}
}

 

 

And now you have the card values changed: 

 

{
card(id: 383518002) {
fields {
name
value
}
}
}


Payload:

{
"data": {
"card": {
"fields": [
{
"name": "Select",
"value": "third option"
},
{
"name": "Is this a radio? ",
"value": "No"
}
]
}
}
}

 

Reply