Select to view content in your preferred language

How to Prevent Duplicate Submissions per Period Using Reference_FarmID in Survey123 Connect

468
10
Jump to solution
2 weeks ago
hmorgan
Emerging Contributor

Hello everyone,

I am creating a survey in Survey123 Connect where I need to prevent duplicate submissions for the same farm within the same quarter.

In my survey, I have the following fields:

  • Reference_FarmID (text input)

  • submission_quarter (calculate)

  • submission_year (calculate)

My goal is to ensure that each Reference_FarmID can only be submitted once per quarter. If a record for the same farm has already been submitted in the same quarter and year, the form should block the second

The issue is that no data exists yet in the feature layer, but the form is already restricting me and treating it as a duplicate. It will not allow the very first submission.

How can I correctly configure the duplicate check so that:

  • The first-ever submission is allowed

  • Only the second submission in the same quarter is blocked

submission.

type name label calculation constraint constraint_message

textReference_FarmIDFarm Reference ID count(pulldata("@layer", "Reference_FarmID", "Reference_FarmID", ., "submission_quarter", ${submission_quarter}, "submission_year", ${submission_year})) = 0This Farm ID already submitted in ${submission_quarter} ${submission_year}
calculatesubmission_quarter if(format-date(now(), '%m') <= 3, 'Q1', if(format-date(now(), '%m') <= 6, 'Q2', if(format-date(now(), '%m') <= 9, 'Q3', 'Q4')))  
calculatesubmission_year format-date(now(), '%Y')  
0 Kudos
1 Solution

Accepted Solutions
Neal_t_k
Frequent Contributor

Ok try the attached with your url.  I did a test publish and it was working for me.

The "getValue" in the pulldata was missing.

View solution in original post

0 Kudos
10 Replies
DougBrowning
MVP Esteemed Contributor

pulldata often does not like being nested in anything.  Make it its own field then use that in the count.  Known issue.  That could be it.

0 Kudos
Neal_t_k
Frequent Contributor

Your pulldata is not formatted correctly, besides what @DougBrowning said, it is not pulling any data from a url, and you would have to format 3 questions to pull each attribute separately.  I suspect because it is formatted wrong the constraint is returning something like Null = 0 and stopping you from submitting.

 

Try the attached out,  it should just need the url for your feature layer, and you will have to publish and do a couple test submissions before  the pulldata will work.

Here's some documentation on pulldata: 

https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-pulldata-quot-laye...

https://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformformulas.htm#ESRI_SECTION1_BB97985...

hmorgan
Emerging Contributor

It is still not blocking from submitting data that have already been collected 

0 Kudos
Neal_t_k
Frequent Contributor

If you used my example, I made a mistake in the constraint in the "Reference_FarmID" question

the constraint should be: ${RefCollate}!=${RefSubmintted}

Those two formats have to match, so as to make sure the field you are pulling does not match your collated field in the form.

0 Kudos
hmorgan
Emerging Contributor

I have set the constraint in the "Reference_FarmID" question to ${RefCollate}!=${RefSubmintted} but it still did not block the already collected data 

0 Kudos
Neal_t_k
Frequent Contributor

@hmorgan So something is still not matching, it appears your pulldata calculation is not working properly as it is blank in all your test submissions,  can you share what you have in you pulldata calculation for ${RefSubmitted} or your xlsx?

0 Kudos
hmorgan
Emerging Contributor

Alright 

Below is the xls form

0 Kudos
VAAVAA
by
Emerging Contributor

Thank you

0 Kudos
Neal_t_k
Frequent Contributor

Ok try the attached with your url.  I did a test publish and it was working for me.

The "getValue" in the pulldata was missing.

0 Kudos