Hi Everyone. I used the approach suggested for the following question in the ESRI Survey123 Questions forum to calculate and populate a Note type field with a message notifying the inspectors completing a survey if any survey entry was previously submitted within the last 15 days for the specified “Site”. One modification I had to make to the suggested approach was to point the default value of the Survey_Lyr_Url hidden field to point to a read-only-view of the actual hosted feature layer behind the survey, instead of pointing directly to the original hosted feature layer. Pointing to the original hosted feature layer behind the survey threw and error at the survey entry submittal time saying that the survey hosted feature layer did not existed, when it really did. For this approach, pointing the default values of the Survey_Lyr_Url field to a read-only-view solved the error previously mentioned. While testing the approch further, I am now havnig and isssue with the calculate field not recognizing if a survey entry was submitted for the same “Site” in the previous 15 days, when I summit a survey entry for that same site, and do not completely close the Survey123 app and re-open it again and then re-open the specific survey. Below is a sample of the relevant code and settings I am using. For example: I submit a survey entry for site “A”, and then without totally closing Survey123, I try collecting another survey entry, while still online, for the same site “A”, and the calculation does not seem to recognize that a previous entry for that same site was entered just a short time
ago, but if instead I completely close the Survey123 app, even very quickly after submitting the first entry for site “A”, the calculate field recognizes the site was sent within the previous 15 day, as intended by the calculation. Any tips or advise is greatly appreciated.
type | name | label | appearance | required | default | calculation | relevant | bind::esri:fieldLength | bind::esri:parameters | body::esri:visible |
hidden | Survey_Lyr_Url | Survey Layer Url |
|
|
|
|
|
|
| |
calculate | Site_Recently_Inspected_Filter | Site Recently Inspected Filter |
|
|
| concat("Site_No=","'",${Site_No},"'"," and End_Time BETWEEN CURRENT_TIMESTAMP - 15 AND CURRENT_TIMESTAMP + 1") | string-length(${Site_No})>0 |
| calculationMode=always |
|
calculate | Site_Recently_Inspected | Site Recently Inspected | multiline |
| No' | if((string-length(pulldata("@layer","getValue","attributes.Site_No",${Survey_Lyr_Url},${Site_Recently_Inspected_Filter})) > 0), 'Yes', 'No') | string-length(${Site_No})>0 | 99999 | calculationMode=always |
|
note |
| <div style="text-align:left; color:red;">Site No. ${Site_No} has already been inspected in the last 15 days.</div> |
|
|
|
| string-length(${Site_No})>0 |
|
| ${Site_Recently_Inspected} = 'Yes' |
Thanks in advance,
Lemuel M.
Have you tried setting the calculation mode to always?