Lookup Tables : Automatically delete from lookup table once selected


(Peggy Wanza) #1

Hi,

I have a question regarding Lookup tables.

How can one set lookup tables such that, once a user selects something, it gets deleted and they can’t see it the next time they’re using that lookup table?

Am creating some temporary IDs and I’d like to avoid duplication at all cost.

Kindly assist


(Peggy Wanza) #2

A quick follow up to my question above,

Changing the option under the ‘Delete’ column to Y didn’t work.
Thought this is meant to do the job?


(Mazen AlAli) #3

Perhaps the guys from Dimagi can express other options, but as far as i know, you cannot directly manipulate look up data from inside forms.

what you can do to achieve a similar functionality to what you’re asking however might get a little complicated.
the easiest way i can think of is to use a filter on the lookup table data with two functions, selected() and join().

basically, you want to join all the strings from all the cases that have selected a value from the lookup table using the casedb. something like “join(instance(‘casedb’)/casedb/case…casetype etc…)”, and then use not(selected(joined string “join(instance(‘casedb’)/casedb/case…casetype etc…)”, lookup field where unique value is taken from) to make sure that the options you see loaded from the lookup table have not been selected in another case. it’s a longer query, and has many potential failure points, but, might be worth a try.

Mazz


(Peggy Wanza) #4

Thank You,

This seems quite complicated but I’ll try it.

Regards,

Peggy.


(Clayton Sims) #5

Hi Peggy,

I can confirm that lookup tables can’t be manipulated on-device.

It sounds like you may be trying to generate unique IDs on device, have you read this guide from our wiki? It may be a good starting point

-Clayton


(Peggy Wanza) #6

This is helpful Clayton,

Thanks alot.

Regards,

Peggy