Auto-fill parent ref in child from inline table?

Steve
Platinum 4
Platinum 4

Has anyone figured out the conditions that prompt the app to auto-fill the parent link when adding a row from an inline table?

Solved Solved
2 13 2,246
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

After some experimentation, Iโ€™ve found that if REF_ROWS() is the entirety of the columnโ€™s App formula expression, the Add button in the related inline view will auto-fill the column referenced in the REF_ROWS() expression in the new row. To retain this magic, the REF_ROWS() results cannot be modified in any way, such as by list addition or subtraction, or with SORT() or ORDERBY().

Magic:

  • REF_ROWS(...)
  • (REF_ROWS(...))

Not magic:

  • REF_ROWS(...) + LIST(...)
  • REF_ROWS(...) - LIST(...)
  • SORT(REF_ROWS(...))
  • ORDERBY(REF_ROWS(...), ...)
  • FILTER(...)
  • SELECT(...)

IsPartOf, ON or OFF, appears to have no impact.

If you imagine an add-row operation is equivalent to an action of type App: link to another view within this app with a Target expression of LINKTOVIEW("form-view"), the magic REF_ROWS() expression appears to change the Target expression to LINKTOFORM("form-view", "parent-ref-column", [_THISROW]) (where parent-ref-column is the column named in the REF_ROWS() expression).

View solution in original post

13 REPLIES 13

What you mean with โ€ฆprompt the appโ€ฆ @Steve? Like a bubble for example or you mean some kinda auto-focus?

When I click the Add link/button in an inline table:
3X_6_8_68ea1e783cdc7642927fcdb05664766b2ee4022c.png

In some cases, the form that opens will have an appropriate column pre-filled with a Ref back to the row I hit Add from; in other cases, no column is pre-filled. I canโ€™t figure out why some auto-fill and some donโ€™t.

As per my experience; it directly fills the Ref value if thereโ€™s a reverse-reference (isPartOf) but it does not if thereโ€™s a direct reference. When thereโ€™s a direct reference, I generally use a de-ref in the initial value of the ref column of the child table to recall the key column value of the parent.

Steve
Platinum 4
Platinum 4

After some experimentation, Iโ€™ve found that if REF_ROWS() is the entirety of the columnโ€™s App formula expression, the Add button in the related inline view will auto-fill the column referenced in the REF_ROWS() expression in the new row. To retain this magic, the REF_ROWS() results cannot be modified in any way, such as by list addition or subtraction, or with SORT() or ORDERBY().

Magic:

  • REF_ROWS(...)
  • (REF_ROWS(...))

Not magic:

  • REF_ROWS(...) + LIST(...)
  • REF_ROWS(...) - LIST(...)
  • SORT(REF_ROWS(...))
  • ORDERBY(REF_ROWS(...), ...)
  • FILTER(...)
  • SELECT(...)

IsPartOf, ON or OFF, appears to have no impact.

If you imagine an add-row operation is equivalent to an action of type App: link to another view within this app with a Target expression of LINKTOVIEW("form-view"), the magic REF_ROWS() expression appears to change the Target expression to LINKTOFORM("form-view", "parent-ref-column", [_THISROW]) (where parent-ref-column is the column named in the REF_ROWS() expression).

Sweetโ€ฆ
Sorry for being so dumb, but I couldnโ€™t quite get why the ref column value is not auto-filled in the case of a direct reference but auto-filled in case of a reverse-reference on the contrary. Appreciate provided you can clarify the solution a bit more @Steve. Thnx.

I donโ€™t know why, unfortunately. Itโ€™s just my observation. I think AppSheet recognizes a REF_ROWS() expression and treats in in a special way.

This is great info, @Steve! Thanks for testing and providing your results.

Could we get this added to the REF_ROWS() doc?

Done!

3X_5_a_5a631c6a046971c713aa58be6c0b9f8ea5d2f18e.png

@Steve Iโ€™m not 100% sure, but I think I have found the other work around to keeping the magical effect. I have an EnumList of base Ref (mostly for back-end editing), and then a a VC of List base Ref with an AppFormula pointing to the EnumList (for front end inline display). Unless Iโ€™m forgetting about something else I did, I believe it keeps the automatic population.

This was working, despite the presence of Orderby(), for months in an app I have. It stopped working today and reverted back to this (I guess intended) behavior.

I have no explanation for any such change in behavior.

Very likely it was a bugโ€ฆ and itโ€™s been squeaking by because no one would think that behavior is a bug.

But if the intended behavior is for the โ€œMagicโ€ to only work when youโ€™ve got the system-standard Ref_Rows() - this is very limiting for data-schema design capabilities.

Iโ€™ll have to manage the standard-system inline view (so I can keep the magic), but Iโ€™ll have to create copies I may need (with OrderBy() and such) for calculation purposes - duplicating data.

Hi Steve,

I stumbled across this post after days of searching as I could not figure out why the auto fill on 2 of my inlines were working on, but the other one not. 2 have the refRow and work but the other one sadly has to reference an enum List so I had to use a filter instead. 

Is there anyway you now know of that supports the prefill in this circumstance? So far Iโ€™ve tried to tag the user with โ€œcurrently editing entry xxโ€ but could not find a trigger to change this value. 

any advice would be great

kind regards

matthew 

Top Labels in this Space