Calculate Condition to execute for first time

Hi,

I have created a household registration form and generated a household id
as "concat('Hhr-', uuid(7))" inside a hidden field

It works fine but this ID gets changed during edit form at web.

Please advise me how to implement logic in form so that it should generate
household id for the first time only, and once it has value it should use
same value like -

if(hidden_id = '', concat('Hhr-', uuid(7)), hidden_id = '') where hidden_id
is the id of hidden field.

Thanks,
Vipin

Hi Vipin,

Unfortunately this is expected behavior - the uuid() will re-calculate
during form edit. Further your empty checking logic won't work because
questions cannot reference themselves in their calculations.

Assuming that the form registers a case there might be a workaround you
could use. The case_id is itself a random string and is available at the
path 'instance('commcaresession')/session/data/case_id' so you could
reference this value and use the substring
https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-substr
function
to take only seven characters.

Cheers,
Will

Hi,

I have created a household registration form and generated a household id
as "concat('Hhr-', uuid(7))" inside a hidden field

It works fine but this ID gets changed during edit form at web.

Please advise me how to implement logic in form so that it should
generate household id for the first time only, and once it has value it
should use same value like -

if(hidden_id = '', concat('Hhr-', uuid(7)), hidden_id = '') where
hidden_id is the id of hidden field.

Thanks,
Vipin

--
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.

··· On Fri, Jul 21, 2017 at 5:28 AM, Vipin Gupta wrote: > For more options, visit https://groups.google.com/d/optout.

Hi Will,

Thanks for the reply - but we are not using case. Is there any way to get
id of that record, we get this id while exporting data to SQL database
using data export tool.

Thanks,
Vipin

··· On Friday, July 21, 2017 at 6:01:50 PM UTC+5:30, William Pride wrote: > > Hi Vipin, > > Unfortunately this is expected behavior - the uuid() will re-calculate > during form edit. Further your empty checking logic won't work because > questions cannot reference themselves in their calculations. > > Assuming that the form registers a case there might be a workaround you > could use. The case_id is itself a random string and is available at the > path 'instance('commcaresession')/session/data/case_id' so you could > reference this value and use the substring > function > to take only seven characters. > > Cheers, > Will > > On Fri, Jul 21, 2017 at 5:28 AM, Vipin Gupta <vipi...@gmail.com > wrote: > > > > Hi, > > > > I have created a household registration form and generated a household > id as "concat('Hhr-', uuid(7))" inside a hidden field > > > > It works fine but this ID gets changed during edit form at web. > > > > Please advise me how to implement logic in form so that it should > generate household id for the first time only, and once it has value it > should use same value like - > > > > if(hidden_id = '', concat('Hhr-', uuid(7)), hidden_id = '') where > hidden_id is the id of hidden field. > > > > Thanks, > > Vipin > > > > > > -- > > 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. >