Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
submit(
fields(
field("@", function(state) {
return {
"name": "foo",
"uiVersion": "1",
"version": "148",
"xmlns": "http://openrosa.org/formdesigner/123",
"xmlns:jrm": "http://dev.commcarehq.org/jr/xforms"
};
}),
field("Module_Name", dataValue("trainingModuleName")),
field("Module_Number", dataValue("trainingModuleNumber")),
field("Training_Session_Name", function(state) {
return (
dataValue("trainingModuleNumber")(state)+' '+dataValue("trainingModuleName")(state)
);
}),
field("Current_Module", dataValue("currentModule")),
field("Case_Id", dataValue("sessionId")),
field("Parent_Id", dataValue("trainingGroupCommCareId")),
field("subcase_0", function(state) {
return {
"n0:case": {
"@": {
"case_id": dataValue("sessionId")(state),
"date_modified": new Date().toISOString(),
"user_id": "456",
"xmlns:n0": "http://commcarehq.org/case/transaction/v2"
},
"n0:create": {
"n0:case_name": dataValue("trainingModuleNumber")(state)+' '+dataValue("trainingModuleName")(state),
"n0:owner_id": dataValue("bar")(state),
"n0:case_type": "baz"
},
"n0:update": {
"n0:Case_Id": dataValue("sessionId")(state),
"n0:Date": new Date().toISOString(),
"n0:Module_Name": dataValue("trainingModuleName")(state),
"n0:Module_Number": dataValue("trainingModuleNumber")(state),
"n0:Current_Module": dataValue("currentModule")(state),
"n0:Parent_Id": dataValue("trainingGroupCommCareId")(state)
},
"n0:index": {
"n0:parent" : {
"@": {
"case_type": "baz"
},
"#": dataValue("trainingGroupCommCareId")(state)
}
}
}
};
}),
field("n1:case", function(state) {
return {
"@": {
"case_id": dataValue("sessionId")(state),
"date_modified": new Date().toISOString(),
"user_id": "qux",
"xmlns:n1": "http://commcarehq.org/case/transaction/v2"
}
};
}),
field("n2:meta", function(state) {
return {
"@": {
"xmlns:n2": "http://openrosa.org/jr/xforms"
},
"n2:deviceID": "789",
"n2:timeStart": new Date().toISOString(),
"n2:timeEnd": new Date().toISOString(),
"n2:username": "quux",
"n2:userID": "123"
};
})
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment