Can I have the same field name in Parent and Repeat child?

238
8
03-06-2020 10:14 AM
DougBrowning
MVP Notable Contributor

In my forms I like to pass our PointID down to each repeat table for ease of viewing.   Since it is a separate repeat table using the same name should technically be ok.  But of course the excel form in Connect is yelling about it.

It seems like I can still publish but am I headed for disaster here?  I was going to change the repeat field to PointKey but I have a form with 3 repeats now so that would get weird.  PointKey1, PointKey2, etc.  It would be a mess when moving data to my backend SQL.

Then the other issue is if I have the repeat also use PointID with a calc of PointID from the parent it gives an error.  So I guess I need to use PlotKey no matter what?  But could I still use PlotKey in all 3 repeats?

Anyone try having a parent and child with the same field name?  Is there any official guidance on this?

Thanks a lot

0 Kudos
8 Replies
DougBrowning
MVP Notable Contributor

Adding to this I would also like to have 2 repeats that have identical field names.

We collect Plants on the left and right bank of a stream.  So both repeats should have the field Species.  Having one be called LeftSpecies and the other RightSpecies makes no sense.

thanks

0 Kudos
TL2
by
Occasional Contributor III

I support this idea.

PaulPetersen1
New Contributor III

@DougBrowning , I'm going up against this issue right now...did you ever find a sustainable solution? I've just been adding prefixes to shared fields names in the children to make them unique, but I really don't like doing that.

0 Kudos
DougBrowning
MVP Notable Contributor

No I am adding prefixes as well.  We have other transformations on the data to match the backend schema anyway so just another one to add.

What I do is in Python I load the feature class or table into memory, then do add field and copy the value over using calculate field.  Then run append and it all matches up.

Another idea is to add the field to the service directly after you publish.  Then run a script each night to copy the value over.

Hope that helps.

0 Kudos
PaulPetersen1
New Contributor III

@DougBrowning , thanks. Glad to know I'm not crazy at least. The only other thought I've had is that in my case I'll be launching Survey123 from Field Maps and thus can pass the attributes in question from Field Maps to Survey123 via URL. So I'm thinking I can create some temporary hidden fields (with null schema), load the attributes into the temp schema from the URL, and the calc the values into my field schema within the various repeats (thus avoiding using a duplicated field name within a calc, since the temp field name is unique). I haven't tried it yet, but think it should work...

0 Kudos
DougBrowning
MVP Notable Contributor

Note sure I get what you wrote but You cannot dup a field name anywhere in the form though.  The entire form and all repeats must not use the same field name twice.

0 Kudos
PaulPetersen1
New Contributor III

It seems that I can duplicate a field name in the form, as long as I don't reference that field name in calculations, defaults, relevant, etc. It highlights the field in pink, but doesn't actually stop me from publishing and collecting successfully. My prototype setup is in the screenshot below. Basically I write values to a null-bound temporary field and then use the temporary field to calculate the duplicate fields. It works in my testing so far...the method allows me to write the same value to duplicate field names within the form.

PaulPetersen1_0-1647279170482.png

 

0 Kudos
DougBrowning
MVP Notable Contributor

Calcs may not work right however.  Also uploading.  Maybe 123 can chime it but good chance something else will break.

0 Kudos