Save part of data locally which can be used by other application within ODK

I searched the forum but didn't find anything about it. Is it possible
to save part of that data (or all of it) locally in such a format that
values of certain fields can be fetched to feed into other application
within ODK? To be specific, I have a form with several fields
including id, date, color among others. I want to use camera to
capture image (media field) and save that image file with a unique
name which should be a combination of ID-Date-Color.jpg. Now, since
all this data (id, date, color) is in the very same form as the image
capture, I have no idea how this can be achieved. Can anyone please
help or guide me in the right direction?

You can have your application launch ODK Collect via an intent.

The returned intent holds the URI that can be sent to the InstanceProvider
within ODK Collect to retrieve information about the filled-in form
instance (see InstanceColumns).
The INSTANCE_FILE_PATH in that table identifies where the filled-in
instance is stored.

e.g., in FormEntryActivity, the finishReturnInstance() sets the Intent
result as follows:

            Uri instance =

Uri.withAppendedPath(InstanceColumns.CONTENT_URI, id);
setResult(RESULT_OK, new Intent().setData(instance));

The filled-in form is saved as an XML file. You would have to parse that
to get at the fields you want. The filename of the captured media file is
stored in this XML file, so you don't need to construct specially-named
files -- just extract the filename from this XML file.

I would strongly encourage you to not seek to have these captured media
files to have a specific structure for their filename. That would likely
involve modifications to Javarosa to allow formatted names to be defined.

Mitch

··· On Wed, Apr 4, 2012 at 4:17 AM, Basant wrote:

I searched the forum but didn't find anything about it. Is it possible
to save part of that data (or all of it) locally in such a format that
values of certain fields can be fetched to feed into other application
within ODK? To be specific, I have a form with several fields
including id, date, color among others. I want to use camera to
capture image (media field) and save that image file with a unique
name which should be a combination of ID-Date-Color.jpg. Now, since
all this data (id, date, color) is in the very same form as the image
capture, I have no idea how this can be achieved. Can anyone please
help or guide me in the right direction?

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Thanks for your reply. I will look into it. It sounds like it won't be
easy.
Btw, I think I didn't make myself clear. In other words, is there a
way to automatically create a value based on combined values of 2-3
fields filled previously?

Thanks!
Basant

··· On Apr 4, 10:26 pm, Mitch S wrote: > You can have your application launch ODK Collect via an intent. > > The returned intent holds the URI that can be sent to the InstanceProvider > within ODK Collect to retrieve information about the filled-in form > instance (see InstanceColumns). > The INSTANCE_FILE_PATH in that table identifies where the filled-in > instance is stored. > > e.g., in FormEntryActivity, the finishReturnInstance() sets the Intent > result as follows: > > Uri instance = > Uri.withAppendedPath(InstanceColumns.CONTENT_URI, id); > setResult(RESULT_OK, new Intent().setData(instance)); > > The filled-in form is saved as an XML file. You would have to parse that > to get at the fields you want. The filename of the captured media file is > stored in this XML file, so you don't need to construct specially-named > files -- just extract the filename from this XML file. > > I would strongly encourage you to not seek to have these captured media > files to have a specific structure for their filename. That would likely > involve modifications to Javarosa to allow formatted names to be defined. > > Mitch > > On Wed, Apr 4, 2012 at 4:17 AM, Basant wrote: > > I searched the forum but didn't find anything about it. Is it possible > > to save part of that data (or all of it) locally in such a format that > > values of certain fields can be fetched to feed into other application > > within ODK? To be specific, I have a form with several fields > > including id, date, color among others. I want to use camera to > > capture image (media field) and save that image file with a unique > > name which should be a combination of ID-Date-Color.jpg. Now, since > > all this data (id, date, color) is in the very same form as the image > > capture, I have no idea how this can be achieved. Can anyone please > > help or guide me in the right direction? > > -- > Mitch Sundt > Software Engineer > University of Washington > mitchellsu...@gmail.com

Yes, in the you can specify a 'calculate' attribute. E.g., in the
Widgets form on opendatakit.appspot.com, we have:

which tests the /widgets/int field and sets a string value accordingly.

The functions available are very poorly documented.

Generally, anything that is in a relevance or validate expression is legal
(e.g., arithmetic and logical operations, conditionals, references to
selected values).
Beyond that, I always reference the code for what the functions are. The
functions like concat(a,b) (to concatenate two strings) are in a big
if-then chain here:

https://bitbucket.org/javarosa/javarosa/src/8acbd7900f03/core/src/org/javarosa/xpath/expr/XPathFuncExpr.java#cl-128

Mitch

··· On Wed, Apr 4, 2012 at 10:51 AM, Basant wrote:

Thanks for your reply. I will look into it. It sounds like it won't be
easy.
Btw, I think I didn't make myself clear. In other words, is there a
way to automatically create a value based on combined values of 2-3
fields filled previously?

Thanks!
Basant

On Apr 4, 10:26 pm, Mitch S mitchellsu...@gmail.com wrote:

You can have your application launch ODK Collect via an intent.

The returned intent holds the URI that can be sent to the
InstanceProvider
within ODK Collect to retrieve information about the filled-in form
instance (see InstanceColumns).
The INSTANCE_FILE_PATH in that table identifies where the filled-in
instance is stored.

e.g., in FormEntryActivity, the finishReturnInstance() sets the Intent
result as follows:

            Uri instance =

Uri.withAppendedPath(InstanceColumns.CONTENT_URI, id);
setResult(RESULT_OK, new Intent().setData(instance));

The filled-in form is saved as an XML file. You would have to parse that
to get at the fields you want. The filename of the captured media file
is
stored in this XML file, so you don't need to construct specially-named
files -- just extract the filename from this XML file.

I would strongly encourage you to not seek to have these captured media
files to have a specific structure for their filename. That would likely
involve modifications to Javarosa to allow formatted names to be defined.

Mitch

On Wed, Apr 4, 2012 at 4:17 AM, Basant basa...@gmail.com wrote:

I searched the forum but didn't find anything about it. Is it possible
to save part of that data (or all of it) locally in such a format that
values of certain fields can be fetched to feed into other application
within ODK? To be specific, I have a form with several fields
including id, date, color among others. I want to use camera to
capture image (media field) and save that image file with a unique
name which should be a combination of ID-Date-Color.jpg. Now, since
all this data (id, date, color) is in the very same form as the image
capture, I have no idea how this can be achieved. Can anyone please
help or guide me in the right direction?

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsu...@gmail.com

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Thanks. This is definitely useful.

··· On Apr 4, 11:19 pm, Mitch S wrote: > Yes, in the you can specify a 'calculate' attribute. E.g., in the > Widgets form on opendatakit.appspot.com, we have: > > > > which tests the /widgets/int field and sets a string value accordingly. > > The functions available are very poorly documented. > > Generally, anything that is in a relevance or validate expression is legal > (e.g., arithmetic and logical operations, conditionals, references to > selected values). > Beyond that, I always reference the code for what the functions are. The > functions like concat(a,b) (to concatenate two strings) are in a big > if-then chain here: > > https://bitbucket.org/javarosa/javarosa/src/8acbd7900f03/core/src/org... > > Mitch > > > > On Wed, Apr 4, 2012 at 10:51 AM, Basant wrote: > > Thanks for your reply. I will look into it. It sounds like it won't be > > easy. > > Btw, I think I didn't make myself clear. In other words, is there a > > way to automatically create a value based on combined values of 2-3 > > fields filled previously? > > > Thanks! > > Basant > > > On Apr 4, 10:26 pm, Mitch S wrote: > > > You can have your application launch ODK Collect via an intent. > > > > The returned intent holds the URI that can be sent to the > > InstanceProvider > > > within ODK Collect to retrieve information about the filled-in form > > > instance (see InstanceColumns). > > > The INSTANCE_FILE_PATH in that table identifies where the filled-in > > > instance is stored. > > > > e.g., in FormEntryActivity, the finishReturnInstance() sets the Intent > > > result as follows: > > > > Uri instance = > > > Uri.withAppendedPath(InstanceColumns.CONTENT_URI, id); > > > setResult(RESULT_OK, new Intent().setData(instance)); > > > > The filled-in form is saved as an XML file. You would have to parse that > > > to get at the fields you want. The filename of the captured media file > > is > > > stored in this XML file, so you don't need to construct specially-named > > > files -- just extract the filename from this XML file. > > > > I would strongly encourage you to not seek to have these captured media > > > files to have a specific structure for their filename. That would likely > > > involve modifications to Javarosa to allow formatted names to be defined. > > > > Mitch > > > > On Wed, Apr 4, 2012 at 4:17 AM, Basant wrote: > > > > I searched the forum but didn't find anything about it. Is it possible > > > > to save part of that data (or all of it) locally in such a format that > > > > values of certain fields can be fetched to feed into other application > > > > within ODK? To be specific, I have a form with several fields > > > > including id, date, color among others. I want to use camera to > > > > capture image (media field) and save that image file with a unique > > > > name which should be a combination of ID-Date-Color.jpg. Now, since > > > > all this data (id, date, color) is in the very same form as the image > > > > capture, I have no idea how this can be achieved. Can anyone please > > > > help or guide me in the right direction? > > > > -- > > > Mitch Sundt > > > Software Engineer > > > University of Washington > > > mitchellsu...@gmail.com > > -- > Mitch Sundt > Software Engineer > University of Washington > mitchellsu...@gmail.com

Good call, Mitch. I've added a link to the source at
http://opendatakit.org/help/form-design/binding/

··· On Wed, Apr 4, 2012 at 11:23, Basant wrote: > Thanks. This is definitely useful. > > On Apr 4, 11:19 pm, Mitch S wrote: >> Yes, in the you can specify a 'calculate' attribute. E.g., in the >> Widgets form on opendatakit.appspot.com, we have: >> >> >> >> which tests the /widgets/int field and sets a string value accordingly. >> >> The functions available are very poorly documented. >> >> Generally, anything that is in a relevance or validate expression is legal >> (e.g., arithmetic and logical operations, conditionals, references to >> selected values). >> Beyond that, I always reference the code for what the functions are. The >> functions like concat(a,b) (to concatenate two strings) are in a big >> if-then chain here: >> >> https://bitbucket.org/javarosa/javarosa/src/8acbd7900f03/core/src/org... >> >> Mitch >> >> >> >> On Wed, Apr 4, 2012 at 10:51 AM, Basant wrote: >> > Thanks for your reply. I will look into it. It sounds like it won't be >> > easy. >> > Btw, I think I didn't make myself clear. In other words, is there a >> > way to automatically create a value based on combined values of 2-3 >> > fields filled previously? >> >> > Thanks! >> > Basant >> >> > On Apr 4, 10:26 pm, Mitch S wrote: >> > > You can have your application launch ODK Collect via an intent. >> >> > > The returned intent holds the URI that can be sent to the >> > InstanceProvider >> > > within ODK Collect to retrieve information about the filled-in form >> > > instance (see InstanceColumns). >> > > The INSTANCE_FILE_PATH in that table identifies where the filled-in >> > > instance is stored. >> >> > > e.g., in FormEntryActivity, the finishReturnInstance() sets the Intent >> > > result as follows: >> >> > > Uri instance = >> > > Uri.withAppendedPath(InstanceColumns.CONTENT_URI, id); >> > > setResult(RESULT_OK, new Intent().setData(instance)); >> >> > > The filled-in form is saved as an XML file. You would have to parse that >> > > to get at the fields you want. The filename of the captured media file >> > is >> > > stored in this XML file, so you don't need to construct specially-named >> > > files -- just extract the filename from this XML file. >> >> > > I would strongly encourage you to not seek to have these captured media >> > > files to have a specific structure for their filename. That would likely >> > > involve modifications to Javarosa to allow formatted names to be defined. >> >> > > Mitch >> >> > > On Wed, Apr 4, 2012 at 4:17 AM, Basant wrote: >> > > > I searched the forum but didn't find anything about it. Is it possible >> > > > to save part of that data (or all of it) locally in such a format that >> > > > values of certain fields can be fetched to feed into other application >> > > > within ODK? To be specific, I have a form with several fields >> > > > including id, date, color among others. I want to use camera to >> > > > capture image (media field) and save that image file with a unique >> > > > name which should be a combination of ID-Date-Color.jpg. Now, since >> > > > all this data (id, date, color) is in the very same form as the image >> > > > capture, I have no idea how this can be achieved. Can anyone please >> > > > help or guide me in the right direction? >> >> > > -- >> > > Mitch Sundt >> > > Software Engineer >> > > University of Washington >> > > mitchellsu...@gmail.com >> >> -- >> Mitch Sundt >> Software Engineer >> University of Washington >> mitchellsu...@gmail.com