Select to view content in your preferred language

pulldata("@layer") returning datetime in web app instead of true/false

582
2
Jump to solution
08-02-2023 10:10 AM
mikAMD
by
Occasional Contributor III

I'm using pulldata("@layer") to get a datetime based on another field in the survey and I wish to compare it to another value and show true/false.

so my field "test1" has the pulldata function and "test2" has the pulldata function with a comparison "> 10" at then end, like so: pulldata("@layer", "getValue", "attributes.inspection_date", "service_url/FeatureServer/14?orderbyfields=inspection_date desc", concat("field1 =", ${field1}, " and field2 = '1'")) > 10

in survey123 connect (and android app) I get :

mikAMD_0-1690995958077.png

which is correct, but in the web app, I get:

mikAMD_1-1690996009049.png

where "test2" should also return "true".

I tried putting int() around my pulldata() but doesn't work. I also tried "field2 = 1" and "field2 = 'yes'", doesn't work either.

What am I doing wrong here?

Thanks!

 

 

 

0 Kudos
1 Solution

Accepted Solutions
mikAMD
by
Occasional Contributor III

I guess I didn't explain my problem correctly. Basically I wanted to only show a field if the last inspection date was older than X days (4 in this case). I tried your suggestion @DougBrowning but then my field was a date, which was not what I wanted.

I ended up going back to the old Dates and Time in Survey123 and noticed this:

mikAMD_0-1691069160590.png

So I checked the documentation for decimal-date-time().

After plenty of trial and error, I got it working. I had to divide the calculations in multiple fields, for some reason doing it as a one liner didn't work (field3_tf).

typenamelabelappearancecalculationbind::esri:fieldTypebody::esri::visible
integertoday_ddttodat_ddthiddendecimal-date-time(today())null 
integerfield3_ddtfield3_ddthiddendecimal-date-time(int(pulldata("@layer", "getValue", "attributes.inspection_date", "https://service_url/14?orderbyfields=inspection_date desc", concat("field1 =", ${field1}, " and field2 = '1'"))))null 
textfield3_tffield3_tfhidden${today_ddt} - ${field3_ddt} > int(decimal-date-time(4))null

 

 

select_one blablafield3field 3  esriFieldTypeInteger

${field3_tf} = true

 

 

View solution in original post

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

Try setting the bind::type column to date or datetime.  That usually does it for numbers so I think it may work for this also.  All items in 123 are treated like strings when using calculate unless you set this column.  Other newer way is to set the type to date then set appearance to hidden.  

Hope that does it

mikAMD
by
Occasional Contributor III

I guess I didn't explain my problem correctly. Basically I wanted to only show a field if the last inspection date was older than X days (4 in this case). I tried your suggestion @DougBrowning but then my field was a date, which was not what I wanted.

I ended up going back to the old Dates and Time in Survey123 and noticed this:

mikAMD_0-1691069160590.png

So I checked the documentation for decimal-date-time().

After plenty of trial and error, I got it working. I had to divide the calculations in multiple fields, for some reason doing it as a one liner didn't work (field3_tf).

typenamelabelappearancecalculationbind::esri:fieldTypebody::esri::visible
integertoday_ddttodat_ddthiddendecimal-date-time(today())null 
integerfield3_ddtfield3_ddthiddendecimal-date-time(int(pulldata("@layer", "getValue", "attributes.inspection_date", "https://service_url/14?orderbyfields=inspection_date desc", concat("field1 =", ${field1}, " and field2 = '1'"))))null 
textfield3_tffield3_tfhidden${today_ddt} - ${field3_ddt} > int(decimal-date-time(4))null

 

 

select_one blablafield3field 3  esriFieldTypeInteger

${field3_tf} = true

 

 

0 Kudos