Through the API, you are able to upload subform records, but there are a couple things to note before you start.
1. Parent records subform count will not auto-update when create or delete subform records. For example, if you've collected 2 subform records on a device, the subform count will say 2. However, when you create 3 more subform records, the count will still remain 2 until you update the parent record.
2. When creating a subform, these fields are required, parent_record_id, parent_page_id and parent_element_id. parent_element_id is the id of the subform element on the parent form you want to tie together. If any of these fields are missing, the record will still be created, but it will not be tied to any parent record.
Let's create some subform records.
First, just like CSV upload, we have to prepare the parent record. This can be a brand new record or editing an existing record. The important part to remember is that the subform count needs to equal the total number of subforms records after adding/deleting them. In this example, we will be creating a new record via API 6.0
URL: https://servername.iformbuilder.com/exzact/api/v60/profiles/10978/pages/290739352/records
{
"fields": [
{
"element_name": "subform_widget",
"value": 2
}
]
}
Response
{
"id": 962
}
Now that we have a parent record, we can now tie them together. Since I entered a value of 2 in the json above, I can now add 2 subform records. This is where you must of parent record id, page id and element id.
[
{
"parent_record_id":962,
"parent_page_id":290739352,
"parent_element_id":120657883,
"fields": [
{
"element_name": "text_data",
"value": "Data Entry 1"
}
]
},{
"parent_record_id":962,
"parent_page_id":290739352,
"parent_element_id":120657883,
"fields": [
{
"element_name": "text_data",
"value": "Data Entry 2"
}
]
}
]
Response
[
{
"id": 989
},
{
"id": 992
}
]
Comments
0 comments
Please sign in to leave a comment.