To insert the current app "version number" into a hidden value?

Sorry, this might be super easy ...

if I wanted a hidden value in my form to contain the current "version
number" of the app... for example, 572 ...

what code do I put in to make it store that value?

thanks!
eric

Eric,

You can access this data in the session
https://github.com/dimagi/commcare/wiki/commcaresession, specifically
with the xpath "instance('commcaresession')/session/context/appversion"

This will give you a string like

CommCare Android, version "2.26"(412274). App v746. CommCare
Version 2.26. Build 412274, built on: 2016-02-0

From which you can parse the value you're looking for.

Best,
Will

··· On Tue, Feb 9, 2016 at 12:17 AM, Eric Stephan wrote:

Sorry, this might be super easy ...

if I wanted a hidden value in my form to contain the current "version
number" of the app... for example, 572 ...

what code do I put in to make it store that value?

thanks!
eric

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

great info, thank you!

Eric

··· On Tuesday, February 9, 2016 at 7:52:14 PM UTC+7, William Pride wrote: > > Eric, > > You can access this data in the session > , specifically > with the xpath "instance('commcaresession')/session/context/appversion" > > This will give you a string like > > CommCare Android, version "2.26"(412274). App v746. CommCare > Version 2.26. Build 412274, built on: 2016-02-0 > > From which you can parse the value you're looking for. > > Best, > Will > > On Tue, Feb 9, 2016 at 12:17 AM, Eric Stephan <estep...@gmail.com > wrote: > >> >> >> Sorry, this might be super easy ... >> >> if I wanted a hidden value in my form to contain the current "version >> number" of the app... for example, 572 ... >> >> what code do I put in to make it store that value? >> >> thanks! >> eric >> >> -- >> You received this message because you are subscribed to the Google Groups >> "commcare-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to commcare-user...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > >

Hey William, here is an additional question that I think is relevant to
"sessions."

I know that using sessions, I can have hidden value in a commcare form
retrieve a variable that is not stored in a form or case, but is in fact
stored in the custom variables I addded to a mobile user's account. That
is very handy.

--> But is there a place that I could create a custom variable that would
exist at the level not of a mobile user, but up *at the level of my
commcare project *or at least an application inside it?

That would be handy for me because I could make a some given steps inside a
form conditional upon the value of one of those project-wide variables, and
therefore, the day that I wanted to actually launch that function, I would
simply have to change a project-wide variable called something like
"turn-on-the-coupon-function," from 0 to 1, and then (once the user had
synced their phone to see the new variable value) the form would see that
variable and start carrying out those additional steps.
... That way I wouldn't have to get all users to update commcare in order
to launch that one process in their forms... They would just need to press
Sync.

Is there a place where I can embed a project-wide variable like that?

thanks!
Eric

Hey Eric,

You could potentially just use a lookup table available to all users for
this.

Cory

··· On Fri, Feb 12, 2016 at 7:35 AM, Eric Stephan wrote:

Hey William, here is an additional question that I think is relevant to
"sessions."

I know that using sessions, I can have hidden value in a commcare form
retrieve a variable that is not stored in a form or case, but is in fact
stored in the custom variables I addded to a mobile user's account. That
is very handy.

--> But is there a place that I could create a custom variable that would
exist at the level not of a mobile user, but up *at the level of my
commcare project *or at least an application inside it?

That would be handy for me because I could make a some given steps inside
a form conditional upon the value of one of those project-wide variables,
and therefore, the day that I wanted to actually launch that function, I
would simply have to change a project-wide variable called something like
"turn-on-the-coupon-function," from 0 to 1, and then (once the user had
synced their phone to see the new variable value) the form would see that
variable and start carrying out those additional steps.
... That way I wouldn't have to get all users to update commcare in
order to launch that one process in their forms... They would just need to
press Sync.

Is there a place where I can embed a project-wide variable like that?

thanks!
Eric

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ah ha... you are right! A very simple lookup table and I would just change
the data in that lookup table when I wanted the change to happen.

Good tip!

I'll think about it a bit and see if any questions or confusion arise...

Eric

Hi Cory -- I do have a follow up question about using the lookup table to
store my own small "app configuration" values, as we discussed...

-- for this purpose, I have made a new lookup table to store a few of these
variables that will allow me to change values to configure certain
behaviors in my app.

-- I have named the lookup table appconfig

-- the three fields in this appconfig table are item, value, and notes

-- I have placed data into the table so that the first item in the table
has these values:
item: 1
value: no
notes: should the sns functions activate, no or yes

--> here is my embarrassingly simple question. As far as I remember, I have
only used lookup tables to direct the function of multiple-choice questions
in the app. And the wiki documentation pages are all telling how to do
that.
But now, I want something much simpler. I simply want to know the code
I can use in a hidden value (I assume it will be a call to read a
"session") that will retrieve the following: In the lookup table called
appconfig, what is the current entry in the field called value for the
record whose field called item is 1?
... of course, when I put this code into a hidden value, the result
should be that the resulting hidden value will be "no" ....

Thanks much, sorry this is a bit brain-dead...

Eric

Note, my best guess that I just tried to answer for myself was that it
would be:
instance('appconfig')/appconfig_list/appconfig[item = 1]/value

but that returned an error that halted my app -- Could not find an
appropriate fixture for src: jr://fixture/item-list:appconfig

··· On Tuesday, February 16, 2016 at 2:29:40 PM UTC+7, Eric Stephan wrote: > > Hi Cory -- I do have a follow up question about using the lookup table to > store my own small "app configuration" values, as we discussed... > > -- for this purpose, I have made a new lookup table to store a few of > these variables that will allow me to change values to configure certain > behaviors in my app. > > -- I have named the lookup table *appconfig* > > -- the three fields in this appconfig table are *item*, *value*, and > *notes* > > -- I have placed data into the table so that the first item in the table > has these values: > item: 1 > value: no > notes: should the sns functions activate, no or yes > > --> here is my embarrassingly simple question. As far as I remember, I > have only used lookup tables to direct the function of multiple-choice > questions in the app. And the wiki documentation pages are all telling how > to do that. > But now, I want something much simpler. I simply want to know the > code I can use in a hidden value (I assume it will be a call to read a > "session") that will retrieve the following: In the lookup table called > appconfig, what is the current entry in the field called *value* for the > record whose field called *item* is 1? > ... of course, when I put this code into a hidden value, the result > should be that the resulting hidden value will be "no" .... > > Thanks much, sorry this is a bit brain-dead... > > Eric > >

Wait -- OK, now I have success!!!

I realized my previous attempt at the code needed some quotes around the
value that I was looking up.

The following worked for me now:

instance('appconfig')/appconfig_list/appconfig[item = '1']/value

I'm sorry to create all these emails which weren't needed...

BUT, If there's anything I should be wary of as I do this, please let me
know.

Eric

Hey Eric,

Ah, I'm afraid I may have directed you into "custom xml" territory. The
first step to fixing your issue would be to add the instance reference to
the form. Some of the advanced lookup table articles in the help site have
instructions for adding it (for example, this one
https://confluence.dimagi.com/display/commcarepublic/Setup+a+Form+to+Display+a+Random+Question+from+Lookup+Table
).

Off the top of my head I'm not 100% sure about the exact format would be
but your expression looks like a good start, I'm sure someone else on this
list could help once you get past the first wall if the expression you
currently are using doesn't work.

··· On Tue, Feb 16, 2016 at 9:45 AM, Eric Stephan wrote:

Note, my best guess that I just tried to answer for myself was that it
would be:
instance('appconfig')/appconfig_list/appconfig[item = 1]/value

but that returned an error that halted my app -- Could not find an
appropriate fixture for src: jr://fixture/item-list:appconfig

On Tuesday, February 16, 2016 at 2:29:40 PM UTC+7, Eric Stephan wrote:

Hi Cory -- I do have a follow up question about using the lookup table to
store my own small "app configuration" values, as we discussed...

-- for this purpose, I have made a new lookup table to store a few of
these variables that will allow me to change values to configure certain
behaviors in my app.

-- I have named the lookup table appconfig

-- the three fields in this appconfig table are item, value, and
notes

-- I have placed data into the table so that the first item in the table
has these values:
item: 1
value: no
notes: should the sns functions activate, no or yes

--> here is my embarrassingly simple question. As far as I remember, I
have only used lookup tables to direct the function of multiple-choice
questions in the app. And the wiki documentation pages are all telling how
to do that.
But now, I want something much simpler. I simply want to know the
code I can use in a hidden value (I assume it will be a call to read a
"session") that will retrieve the following: In the lookup table called
appconfig, what is the current entry in the field called value for the
record whose field called item is 1?
... of course, when I put this code into a hidden value, the result
should be that the resulting hidden value will be "no" ....

Thanks much, sorry this is a bit brain-dead...

Eric

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.