Skip to content

Form Entry Workflow

wpride edited this page Apr 25, 2017 · 1 revision

Workflow Intent

Android applications can load CommCare to begin entering a form or selecting a case then a form by providing a serialized "session" to a CommCare intent containing the relevant details for the launch that is being processed.

Prerequisites

In order to use this API, you'll need

  • An application installed in CommCare
  • For CommCare to be currently logged in
  • Access to the suite.xml file for your application to provide the identifiers for constructing the session.

Intent Details

**Action: ** org.commcare.dalvik.action.CommCareSession

**Extras: ** ccodk_session_request, Format Listed Below

Session Structure

A CommCare session contains all of the data that is selected before a form is entered, including the menus selected and any cases chosen.

The current (this will change) format is a space separated list containing COMMAND_ID's and CASE_ID's. Note that CASE_ID is actually a legacy name for any datum collected for an <entry>'s <session> section.

Assuming your suite file contains the following structure

#!xml

...
    <entry>                   
        <form>http://myorg.com/module/myform</form>
        <command id="myform">
            <text><locale id="menu.module.myform"/></text>
        </command>
        <instance id="casedb" src="jr://instance/casedb"/>
        <session>
        	<datum id="case_id" nodeset="instance('casedb')/casedb/case[@case_type='cc_my_client'][@status='open']" value="./@case_id" detail-select="client_short" detail-confirm="client_long"/>
        </session>
    </entry>
...

    <menu id="my-module">
    	<text><locale id="menu.module"/></text>
    	<command id="myform"/>
    ```</menu>
...

The session structure for loading CommCare onto the form entry screen for a specific case (specified here as external_id_here and presumably loaded from an external application) would be

COMMAND_ID my-module CASE_ID case_id external_id_here COMMAND_ID myform

Which is akin to a virtual selection of the my-module menu, the case passed to the app, and then the form requested.

Once form entry is completed, CommCare will begin submitting the collected form.

It should be noted that since these are new API's, no error identification is performed on these inputs, so if command id's or case ID's are malformed or incorrectly chosen, the behavior is unspecified.