Skip to main content

commcare@1.5.1

Adaptor

Adaptor.execute

Kind: static class of Adaptor

new exports.execute(operations)

Execute a sequence of operations. Wraps language-common/execute, and prepends initial state for commcare.

ParamTypeDescription
operationsOperationsOperations to be performed.

Example

execute(
create('foo'),
delete('bar')
)(state)

Adaptor.submitXls

Kind: static class of Adaptor
Access: public

new exports.submitXls(formData, params)

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',
}
)

Adaptor.submit

Kind: static class of Adaptor
Access: public

new exports.submit(formData)

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.")
)
)

Adaptor.fetchReportData

Kind: static class of Adaptor
Access: public

new exports.fetchReportData(reportId, params, postUrl)

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)

Adaptor~clientPost

Kind: inner class of Adaptor

new clientPost(formData)

Performs a post request

ParamTypeDescription
formDataObjectForm Data with auth params and body

Example

clientPost(formData)