commcare@1.6.10
Functions
- clientPost(formData)
- fetchReportData(reportId, params, postUrl)
- submit(formData)
- submitXls(formData, params)
The following functions are exported from the common adaptor:
- alterState()
- arrayToString()
- combine()
- dataPath()
- dataValue()
- each()
- field()
- fields()
- fn()
- http()
- lastReferenceValue()
- merge()
- sourceValue()
clientPost
clientPost(formData) ⇒ State
Performs a post request
Param | Type | Description |
---|---|---|
formData | Object | Form Data with auth params and body |
Example
clientPost(formData)
fetchReportData
fetchReportData(reportId, params, postUrl) ⇒ Operation
Make a GET request to CommCare's Reports API and POST the response to somewhere else.
Param | Type | Description |
---|---|---|
reportId | String | API name of the report. |
params | Object | Query params, incl: limit, offset, and custom report filters. |
postUrl | String | Url to which the response object will be posted. |
Example
fetchReportData(reportId, params, postUrl)
submit
submit(formData) ⇒ Operation
Submit form data
Param | Type | Description |
---|---|---|
formData | Object | Object including form data. |
Example
submit(
fields(
field("@", function(state) {
return {
"xmlns": "http://openrosa.org/formdesigner/form-id-here"
};
}),
field("question1", dataValue("answer1")),
field("question2", "Some answer here.")
)
)
submitXls
submitXls(formData, params) ⇒ Operation
Convert form data to xls then submit.
Param | Type | Description |
---|---|---|
formData | Object | Object including form data. |
params | Object | Request params including case type and external id. |
Example
submitXls(
[
{name: 'Mamadou', phone: '000000'},
],
{
case_type: 'student',
search_field: 'external_id',
create_new_cases: 'on',
}
)