Skip to main content

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

ParamTypeDescription
formDataObjectForm 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.

ParamTypeDescription
reportIdStringAPI name of the report.
paramsObjectQuery params, incl: limit, offset, and custom report filters.
postUrlStringUrl to which the response object will be posted.

Example

fetchReportData(reportId, params, postUrl)

submit

submit(formData) ⇒ Operation

Submit form data

ParamTypeDescription
formDataObjectObject 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.

ParamTypeDescription
formDataObjectObject including form data.
paramsObjectRequest params including case type and external id.

Example

submitXls(
[
{name: 'Mamadou', phone: '000000'},
],
{
case_type: 'student',
search_field: 'external_id',
create_new_cases: 'on',
}
)