Can we pass a data block for the refresh_on_back property? How to set default values for input fields from API response using init_values or any other effective method?
1

Function related to refresh_on_back and init_values with some exampled

Anoud
Asked about 4 months ago
Bar

I don't fully understand what you are trying to do - can you please add more information about what you are trying to build, and what you have tried so far?

July 1 at 6:11 AM
Bar

In the meantime, you can also check out the examples under this documentation: https://developers.facebook.com/docs/whatsapp/flows/reference/flowjson#form-configuration

It shows how to use the init-values properties on a Form level, or component-specific level (for Flow JSON v4.0+).

July 1 at 6:14 AM
Anoud

I want to send the data of the form values when the user clicks the back button of flow. Is it possible using refresh_on_back.? From API response I need to default the values for text input, date field, etc. If possible please share the structure of API response.

July 1 at 6:15 AM
Anoud

Below Code is my sample JSON, { "id": "TRAVELLER_DETAILS", "title": "Traveller Details", "refresh_on_back": true, "data": { "nationality": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "title": { "type": "string" } } }, "__example__": [ { "id": "1", "title": "Qatar" }, { "id": "2", "title": "Doha" } ] }, "relation": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "title": { "type": "string" } } }, "__example__": [ { "id": "1", "title": "Qatar" }, { "id": "2", "title": "Doha" } ] }, "error_messages": { "type": "object", "__example__": {} } }, "layout": { "type": "SingleColumnLayout", "children": [ { "type": "Form", "name": "traveller_details_form", "error-messages": "${data.error_messages}", "children": [ { "type": "TextInput", "input-type": "text", "label": "Passenger Name", "name": "passenger_name", "required": true }, { "type": "Dropdown", "label": "Nationality", "required": true, "name": "nationality", "data-source": "${data.nationality}" }, { "type": "DatePicker", "label": "Date of Birth", "name": "dob", "required": true }, { "type": "Footer", "label": "Submit", "on-click-action": { "name": "data_exchange", "payload": { "component_action": "TRAVELLER_CONTINUE_FORM" } } } ] } ] } }

July 1 at 6:24 AM
Selected Answer
1

Anoud, you can use "Global data access" feature that allows you to reference the data globally without passing it to action payload. See the docs (Global dynamic and form data):

https://developers.facebook.com/docs/whatsapp/flows/reference/flowjson

July 1 at 7:06 AM
Evgenii