• Hello,
    I have the following setup:
    Table 1 with the following:
    id|name|licenseid|other columns
    1|test|1|…
    2|test2|50|…

    Table 2 with the following:
    id|licensename
    1|1LIC
    2|2LIC
    …….
    50|50LIC

    I created a lookup rule on table 1 to show licesense name instead of licenseid, and also I have created a new view to only show the table2 entries that do not have anything associated in table 1.
    I have no idea how to acomplish the following:
    When you edit an entry from table 1 in the dropdown for licenseid you should only see the entries that are not associated to anything in table 1.
    I have tested the following cases:
    1. the lookup is done agains table2 – everything is ok in the “list table” view; in the “data entry” form I see all entries in the dropdown
    2. the lookup is done against the view – in the “list table” view I see the actual ID’s (since the licensenames are not matched to anything); in the “data entry” form I see only unassociated entries (this would be good), the problem in this case is that the entry initially shows up as blank and if I save it like this the entry will actually get updated with an empty value.
    3. I’ve added 2 lookups – one against the table and one against the view and somehow I managed to get the licensename in the “list table” but I still have the issue with updating a row (the current “licensename” does not show up in the dropdown, and if I edit any other cell and save the “licenseid” field is olso updated to empty).

    I hope I managed to explain the situation… can you think of another way to accomplish this ?

    Thanks,
    Stefan

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Stefan,

    Let me see if I understand your question correctly:
    (1) If you add a new row: you want the plugin to show only unassociated ids
    (2) When you update an existing row: you want the plugin to show the actual id + all unassociated ids

    Is this correct?

    Thanks,
    Peter

    Thread Starter siriwa

    (@siriwa)

    Hi,
    That is exactly right.

    Thanks,
    Stefan

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Stefan,

    Your requirement makes sense! Unfortunately the plugin does not support it. Sorry!

    An additional lookup could be a solution. Let me think about it…

    Alternatively, you could fix this yourself, maybe just temporarily:
    You can use hook wpda_after_simple_form to interact with your form data. The hook allows you to add your own php and javascript code to change the content of your listbox. If your tables are stored in your local WordPress database, you can access your table data with $wpdb. If your data is stored in a remote database, you can use:
    $rdb = \WPDataAccess\Connection\WPDADB::get_db_connection( ‘your-remote-database’ );
    WPDADB inherits wpdb which gives you access to all methods available from $wpdb.

    Another alternative would be to make the listbox selectable in insert mode only, and make disable it on update mode. You can use the same hook to achieve that result.

    Sorry, I have no better solution for now…

    Best regards,
    Peter

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Lookup filtering’ is closed to new replies.