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
已發問 約 4 個月前
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?

7月1日上午6:11
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+).

7月1日上午6:14
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.

7月1日上午6:15
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" } } } ] } ] } }

7月1日上午6:24
已選擇的回答
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

7月1日上午7:06
Evgenii