If statements + hidden values

Hi all,
I have a question about using an if statement to increment a hidden value.
A shopkeeper is making a sale to a customer, who is kept as a case. Every
time a shopkeeper makes a sale to a customer, the customer's outstanding
debt, which is a hidden value, should increase. This works well on my
survey right now- outstanding_debt is both a case property that is loaded
into the form and a case property that data is saved to.

However, I have an additional hidden value that I want to increment only if
the shopkeeper makes a sale to that customer on credit. This is set up the
same way as outstanding_debt, but does not seem to be working. I think it
is the if statement because coalesce_credit_outstanding_debt always
increases, no matter if the shopkeeper selects credit or not. Right now my
if statement is (3 is the value of credit):
if(/data/sales_questions/payment_method='3',
/data/prev/coalesce_credit_outstanding_debt + /data/calc/total_due_retail,
/data/prev/coalesce_credit_outstanding_debt)

Does anyone know what the issue could be?

Hey Emily,

Its hard to debug without seeing the complete form but to troubleshoot I'd
recommend looking at the submit history
https://confluence.dimagi.com/display/commcarepublic/Data+Inspection report
on HQ. You should track down a form that didn't behave as you expected and
look at the "Raw XML" tab in particular to see what values aren't being set
as you expect. In particular I'd validate that the three values in your
'if' statement are evaluating as you expect. If you can't tell from this,
its helpful to add the different components as separate hidden values to
debug IE having " /data/prev/coalesce_credit_outstanding_debt +
/data/calc/total_due_retail" as its own hidden value so that you can
examine it alone in the report.

Best,
Will

ยทยทยท On Tue, Feb 9, 2016 at 12:54 AM, wrote:

Hi all,
I have a question about using an if statement to increment a hidden value.
A shopkeeper is making a sale to a customer, who is kept as a case. Every
time a shopkeeper makes a sale to a customer, the customer's outstanding
debt, which is a hidden value, should increase. This works well on my
survey right now- outstanding_debt is both a case property that is loaded
into the form and a case property that data is saved to.

However, I have an additional hidden value that I want to increment only
if the shopkeeper makes a sale to that customer on credit. This is set up
the same way as outstanding_debt, but does not seem to be working. I think
it is the if statement because coalesce_credit_outstanding_debt always
increases, no matter if the shopkeeper selects credit or not. Right now my
if statement is (3 is the value of credit):
if(/data/sales_questions/payment_method='3',
/data/prev/coalesce_credit_outstanding_debt + /data/calc/total_due_retail,
/data/prev/coalesce_credit_outstanding_debt)

Does anyone know what the issue could be?

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