Select to view content in your preferred language

Lock a calculated field after first submission, so it doesn't change with edits?

521
6
Jump to solution
07-08-2024 12:26 PM
RylieMacdonald
Emerging Contributor

Hey all, I developed a Survey123 app to do the sea turtle nesting survey for the beach I work on, and everything was running smoothly until I made a recent update. 

We are a high density nesting beach, so we mark a subsample of nests (i.e. every 15th loggerhead nest). The way our survey previously worked, is that it would calculate the nest total by 15 to create a nest ID. So Cc1 is really our 15th nest, Cc2 is 30, and so on. We adjust the marking scheme throughout the season based on activity, and changed the calculation for the nest ID field because at that point we had already marked 115 nests, and changing the scheme would throw off nest IDs and calculations. Instead, we changed the calculation to just add 1 to the number of marked nests when you get to the 15th nest of the day to keep the nest IDs sequential.

The issue I have now, is that the nest ID field want  s to recalculate every time I make an edit to a nest. We record fates such as predations, hatches, etc on existing marked nests from the inbox, but when adding these, it tried to update the nest ID. i.e.... CC5 hatched, now we have 119 marked, and when trying to update the hatch field on CC5 it tried to change it to CC120. Is there a way to lock this field so it's only calculated on the first entry? 

Some things I've tried: 

I tried the once function, but it may not be the correct syntax. 

The read_only would not do the correct calculation

I tried all the different calculation modes for the "bind::esri:parameters" column and those did not work either. 

 

If anyone has any advice I would greatly appreciate it! I can attach my XLS file if needed. 

0 Kudos
1 Solution

Accepted Solutions
6 Replies
abureaux
MVP Frequent Contributor

Have you tried calculationMode=whenEmpty

0 Kudos
abureaux
MVP Frequent Contributor

May be worth adding your XLSX file.

0 Kudos
RylieMacdonald
Emerging Contributor

I attached my XLS form. I just tried whenEmpty, but it's still doing the same thing 😕 

0 Kudos
abureaux
MVP Frequent Contributor

This one?

abureaux_1-1720723059827.png

whenEmpty won't work for that. Your IF() statement is based on ${marked} and immediately results in either A or B. If you don't need to retroactively go back and change something from A to B, then a simple nested IF() statement will do the trick:

if(selected(${marking},'marked'), 'A',if(selected(${marking},'unmarked'),'B',''))

or

if(selected(${marking},'marked'), concat(${species}, pulldata("@layer", "getValue", "attributes.MarkedCountForSpecies", concat(concat('URL/FeatureServer/0', '?outStatistics=[{"statisticType": "count", "onStatisticField": "OBJECTID", "outStatisticFieldName": "MarkedCountForSpecies"}]'),if(selected(${marking},'unmarked'),concat("&t=", now())), concat("SPECIES = '", ${species}, "' AND MARKING = 'marked'")) +1), concat(${Marking},'_',${species},'_',${Crawl_Type}),''))

This way, the calculate is empty until a selection is made.

EDIT: Also, notes aren't the best thing to use for... most tasks that aren't simply displaying text. If you want to show the Nest ID and do so in a single step, I'd recommend changing to a text field set to read only. E.g.,

abureaux_5-1720724471619.png

 

0 Kudos
RylieMacdonald
Emerging Contributor

I think the issue here, is that we want it to change with each selection, i.e. our default is an unmarked loggerhead false crawl, but if we change species or crawl type, it needs to change the ID with each of those clicks... I've tried a few other things, it's still recalculating the nest ID with most updated totals every time an entry is opened from the inbox. I tried adding a different field for marked totals and changing the nest ID to concat marked totals with species. Is there something with the once() function that would work or the t = now?

0 Kudos
RylieMacdonald
Emerging Contributor