re: Out filter of item in select-one question depending on previous question

74 views
Skip to first unread message

Clayton Sims

unread,
Oct 16, 2012, 11:59:01 AM10/16/12
to Peter D Lubambi, commcare-users
Peter,

It is possible to lay out the questions you're describing with an <itemset> construct in CommCare.

It's a somewhat advanced setup currently, but the process is documented at


Please let me know if you have any questions
-Clayton

-----Original Message-----
From: "Peter D Lubambi" <plub...@gmail.com>
Reply-To: "Peter D Lubambi" <plub...@gmail.com>
Date: Tue, 16 Oct 2012 16:48:32 +0300
Subject: Out filter of item in select-one question depending on previous question

>Hello,
>In my application I want to be able to register routes (origin location and
>destination) and price for the route, then to use this information to auto
>fill the price on the other form just after filling or selecting route. Is
>this something can be supported by commcare?, Is it possible to populate
>the single-select list in the other form with the list of routes registered?
>
>Also- I want to be able to filter the list depending on the answer on the
>previous question, for example first question is the district name and next
>is village name (all are single select), on the second question i want to
>see only list of villages belong to the district selected on the first
>question.
>
>Thanks.
>-- 
>Peter Dotto Lubambi,
>Information Technology Officer,
>D-tree International,
>Tanzania.

Peter D Lubambi

unread,
Jan 2, 2013, 5:03:10 AM1/2/13
to Clayton Sims, commcar...@googlegroups.com
Hi Clayton,
I have tried to follow the instruction on this link https://bitbucket.org/commcare/commcare/wiki/casedb you provided. It sound unclear to me on how implement this on my from.
Few questions to help me get started.....
1. I have added this node withing the instance, at the bottom just before </instance>.... Is this the right place?
 
<casedb>
 <case case_id="route" case_type="route" owner_id="D-Tree tester" status="open">
                               <!-- case_id: The unique GUID of this case -->
                               <!-- case_type: The id of this case's type -->
                               <!-- owner_id: The GUID of the case or group which owns this case -->
                               <!-- status: 'open' if the case has not been closed. 'closed' if the case has -->
        <case_name/>           <!-- The name of the case-->
        <date_opened/>         <!-- The date this case was opened -->
        <last_modified/>       <!-- The date of the case's last transaction -->
        <*/>                   <!-- An arbitrary data value set in this case -->
        <index>
            <* case_type=""/>  <!-- An index to another case of the given type -->
        </index>
 </case>
    ...
</casedb>

2. Is there any difference between case_type and case_id, because on the page where we define case we only have case type field and for this is "route". Is it correct to refer to this as case_id?
3. owner_id="D-Tree tester", this is group name. Is this correct to refer to it as owner_id?
4. index node-  what is this for ? how is this affect the functioning on the case db? Tying to figure out if I need this?

Have someone done something similar to what I am trying to do? will be very helpful if I could get the form which have this implementation!

thanks.


On Fri, Dec 21, 2012 at 10:05 AM, Clayton Sims <cs...@dimagi.com> wrote:
Peter,

You can create a module to register routes as cases, and then use the itemset construct in the other module to select from that list of cases using the casedb connector documented here


-Clayton


On Thu, Dec 20, 2012 at 3:23 PM, Peter D Lubambi <plub...@gmail.com> wrote:
Hi Clayton,
I have followed the instruction on the link you directed me, which answered my second question.

Left with the first question:- I want to register routes on one form and load those routes as options(item select) in one of the questions in another form, see more description on my original email.
Thanks.



--
Peter Dotto Lubambi,
Information Technology Officer,
D-tree International,
Tanzania.
+255 786 087 087

Clayton Sims

unread,
Jan 2, 2013, 11:49:31 AM1/2/13
to Peter D Lubambi, commcar...@googlegroups.com
Peter,

So the casedb connector is an External Instance in XForms, which you link to by specifying an additional <instance> with the proper source and then referencing with the instance() nodeset method.

Please read up on artificial external instances from the page linked at the top of the casedb page: https://bitbucket.org/javarosa/javarosa/wiki/externalinstances

You shouldn't need to add any instance nodes to your form, you can reference the instance nodes for the existing cases using the syntax covered on the commcare wiki (NOTE you can ignore everything on this page other than the "Create a Select List Based on a Fixture" section, which outlines the syntax for referencing a nodeset from an external instance): https://confluence.dimagi.com/display/commcarepublic/Conditional+Select+Options

-Clayton

Peter D Lubambi

unread,
Jan 9, 2013, 8:25:32 AM1/9/13
to Clayton Sims, commcar...@googlegroups.com
Hi Clayton,
Thanks for the reference you provided. It was helpful!
I have tried to implement the functionality in my form attached, though I have not been able to test as the validator throw this error wherever I upload the form.

Any help will be appreciated
Thanks,

Validation Error:
  Warning: 1 Unrecognized attributes found in Element [data] and will be ignored: [name] Location:
  Problem found at nodeset: /html/head/model/instance/data
  With element <data uiVersion="1" version="1" name="Anzisha rufaa ya mama"><reason_for_referral/>
  java.lang.NullPointerException
  at java.util.Hashtable.put(Hashtable.java:399)
  at org.javarosa.xform.schema.InstanceSchema.processSelectChoices(InstanceSchema.java:174)
  at org.javarosa.xform.schema.InstanceSchema.processSelectChoices(InstanceSchema.java:179)
  at org.javarosa.xform.schema.InstanceSchema.processSelectChoices(InstanceSchema.java:179)
  at org.javarosa.xform.schema.InstanceSchema.generateInstanceSchema(InstanceSchema.java:60)
  at org.javarosa.xform.schema.Harness.main(Harness.java:138)
Anzisha-rufaa.xml

Clayton Sims

unread,
Jan 10, 2013, 11:30:37 AM1/10/13
to Peter D Lubambi, commcar...@googlegroups.com
Peter,

Is this due to the problem that you sent earlier where HQ was mangling the XForm markup? That seems like it's a fit for the error you're experience here.

-Clayton
Reply all
Reply to author
Forward
0 new messages