Dropdown on Ref Column

I have a list of keys (actual physical keys for locks). Each key has a unique identifier. I issue those keys to people. When issuing keys I have a dropdown on a ref column with a Valid_if constraint which only lists for me keys that have not already been issued; I do this by list subtraction (list of all keys minus list of used keys=list of unused keys). This all works peachy fine until I want to edit the record. Lets say a person returns their key and I want to enter a date to the โ€œDate Returnedโ€ column I find Iโ€™m getting an invalid entry warning on the key ref column. The key is now already issued and so thereโ€™s nothing available in the dropdown and the entry fails on Valid_If. Iโ€™m not creating a new record, just updating an old one. Any suggestions?

0 5 121
  • UX
5 REPLIES 5

Oh hi Mark (sorry couldnโ€™t resist), you could use the CONTEXT() function inside an if() like this:

IF(
Context(โ€œViewโ€)=โ€œThe view where you edit your recordsโ€,
TRUE,
Your actual Valid_if formula)

What this should accomplish is to only allow you to select any keys when editing a record, you could use list addition to make it only allow you to choose between the unused keys + the key in the record youโ€™re editing, but for the purpose of changing the โ€œDate Returnedโ€ field this should work.

Edit: forgot the 3X_d_5_d51363a862e7ab883241c312ac5d7f271579cdd3.gif

Thank you for the help. Iโ€™ll play with that tonight when Iโ€™m back home. In the meantime I gave the solution a quick whirl and came up with the error as attached.

My bad, based on the columns on your screenshot iโ€™ll correct the expression as follows:

IF(
Context(โ€œViewโ€)=โ€œIssue_Formโ€,
IKey[KeyID],
IKey[KeyID]-Issue[KeyID])

Steve
Platinum 4
Platinum 4

List subtraction is the right way to go, you just need to not subtract the current rowโ€™s value:

(
  IKey[KeyID]
  - SELECT(
    Issue[KeyID],
    ([_ROWNUMBER] <> [_THISROW].[_ROWNUMBER])
  )
)

Beautiful. 100%.

Top Labels in this Space