Zoho Deluge - Store and repopulate a multi lookup list in Creator

What?
A quick reminder on how I got a working snippet of code to store the entries in the lookup already selected, check against another table/form for valid options, repopulate the list with the selected item and filtering the options available for selection.

Why?
This was for a multi lookup with staff as the list entries. The lookup needed to filter against various forms such as Staff Rotas, Leave Requests, Qualifications and some others.

How?
The aim/objective is the following:
  1. Store what was already selected in the lookups
  2. Clear the lookups list
  3. Restore what was originally selected as selected.
  4. Repopulate with a filter list of options (not selected but available)
// *************************************************************
// store already selected entries
//
if(!isnull(input.myLookup))
{
    // remember remember the 5th of november
    l_RememberLookup = List();
    if(input.myLookup.size()>0)
    {
        for each  v_SelectedLookup in input.myLookup
        {
            l_RememberLookup.add(v_SelectedLookup);
        }
    }
}
//
// clear lookup
clear myLookup;
//
// get list of all valid entries 
l_AllowedEntries = {};
for each  v_AllowedID in myForm[ID != 0]
{
    v_thisID = v_AllowedID.ID;
    l_AllowedEntries.add(v_thisID);
}
//
// restore item in lookup
input.myLookup = l_RememberLookup;
//
// repopulate lookup options (not selected items)
for each  r_EntryID in l_AllowedEntries
{
    input.myLookup:ui.add(r_EntryID);
}

Additional Note(s):
  • If removing elements, even if you are using Creator v5, use removeElement() and NOT remove() which got me stuck for a while. This is for error
    ...datatype {0} is not the same as list datatype {1}...

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.