Function related to refresh_on_back and init_values with some exampled
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?
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+).
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.
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"
}
}
}
]
}
]
}
}
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