Complex Lookup field filtering

Hi, New to Kintone development.  I wonder if someone could give me a hint on this:

User Story :  Student checks out a book from the library, but only if the book is not currently checked out. (this is a contrived example to illustrate the problem)

So I need a lookup-ish field that only presents books that are not checked out.

Data Model:
[Students] <---- 0-n --[Checkouts]-- 0-n -----> [Books]

Possible Solutions

  1. One way might be to filter out books whose most recent checkout record doesn’t have a checkin date. I don’t see a way to do that with the standard lookup field.
  2. Another way might be to use js API to set an IsCheckedOut field on the book  record when the book is checked out and clear the field when the book is checked back in.  This is a bit awkward though from a data integrity standpoint as its  possible for the flag to drift from the checkout record.

I know how I’d do it in traditional web forms, but what’s the Kindone-esque way?

Thanks!
Jeff

Hello Jeff,

To make it simple, you could put a checkbox field or anything that can tell whether a book is checked out or not in the book app and use that as an indicator to filter the checked-out book in the lookup field.

So if I were to do it, I would use the Process Management feature in Kintone to create a check-in/check-out process on the form app. Then upon moving to a check-in/check-out process, the checkbox will be automatically checked or unchecked in the book app using a script.

Kintone - Basic Usage of Process Management
https://get.kintone.help/k/en/user/app_settings/process/set_process.html

Kintone Developer Program - Event Handling
https://developer.kintone.io/hc/en-us/articles/212494948-Event-Handling

Kintone Developer Program - Record Details - Proceed Process Event
https://developer.kintone.io/hc/en-us/articles/213149167-Record-Details-Event#ProcessProceedEvent

Kintone Developer Program - Kintone REST API Overview
https://developer.kintone.io/hc/en-us/articles/212495188