Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


 
Info

This is a page to show how to use ConfiForms Filters by example

ConfiForms filters is the core component of the app and is used absolutely everywhere where you need to describe a condition, filter the dataset or setup the behaviour (field and IFTTT rules)

In this example we will be more focused on filtering the data, but will also touch the basics of a conditionally applied rules

Let's consider these forms that will, logically, build the bookshelf. Each book can be taken for reading and returned when ready. We will have a form for storing this state and couple of forms to store the data about the book and the author(s)


ConfiForms Form Definition
formNamebookshelf
registrationFormTitleBookshelf

bookBook[52626037|books|title|true||]smartselect2

statusStatusfalse[avail=Available|taken=Taken|lost=Lost|]select

takeBookTake bookstatus=taken&takenBy=[entry._user]action_buttonPlease dont forget to return the book after you read it

returnBookReturn bookstatus=avail&takenBy=action_buttonThank you for returning the book

takenByTaken Byuser

*takenByHide field

bookshelfstatus=availRegister book at bookshelfINLINE


ConfiForms Form Definition
formNamebooks

titleTitletexttrue

authorsAuthors[52626037|author|lastName|true|false|[entry.lastName], [entry.firstName]]smartmultiselect

booksRegister bookINLINE


Create ConfiForms EntryonCreatedbook=[entry.id]&status=availbookshelf:@self


ConfiForms Form Definition
formNameauthor
registrationFormTitleAuthors

firstNameFirst nametexttrue

lastNameLast nametexttrue

dobDate of Birthsimpledatetrue

authorRegister authorINLINE






To show all books, we will leave filter property empty

ConfiForms TableView
messageToShowWhenEmptyNo books registered yet
formNamebookshelf
showRecordsCountLabelBooks registered in the bookshelf:

book

book.authors

status



Code Block
No filter, showing all books in the bookshelf

To show only available books we should use for filter expression: status:avail, where status is the field name of bookshelf form and avail is the id of one of the status values in dropdown list

ConfiForms TableView
filterstatus:avail
messageToShowWhenEmptyYou have not took any books yet
formNamebookshelf

book

status

takeBook



Code Block
status:avail

To show books taken only by current user, we should use for filter expression: takenBy:[entry._user], where takenBy is the field name and _user is built-in property of form to get value of current user

ConfiForms TableView
filtertakenBy:[entry._user]
messageToShowWhenEmptyYou have not took any books yet
formNamebookshelf

book

book.authors

status

returnBook



Code Block
takenBy:[entry._user]

To find books which title starts from word "The", we should use for filter expression: The* 

ConfiForms TableView
filterbook.title:The*
messageToShowWhenEmptyNo books found
formNamebookshelf
showRecordsCountLabelBooks found:

book

status



Code Block
book.title:The*



To find books which any field starts from word "Bridget'', we should use for filter expression: Bridget* 

ConfiForms TableView
enhanceFreeTextSearchtrue
filterBridget*
messageToShowWhenEmptyNo books found
formNamebookshelf
showRecordsCountLabelBooks found:

book

Authorsbook.authors.transform(lastName.append([entry.firstName.prepend(, )]))true

status



Code Block
Bridget*

Transformation of authors:  book.authors.transform(lastName.append([entry.firstName.prepend(, )]))

To find books which any field ends with word "love", we should use for filter expression: *love

ConfiForms TableView
filter*love
messageToShowWhenEmptyNo books found
formNamebookshelf
showRecordsCountLabelBooks found:

book

status



Code Block
*love



To find books which any field contains word "and", we should use for filter expression: *and*

ConfiForms TableView
filter*and*
messageToShowWhenEmptyNo books found
formNamebookshelf
showRecordsCountLabelBooks found:

book

status



Code Block
*and*

To find books which authors born before 01.01.1950, we should use for filter expression: book.authors.dob.formatDate(yyyyMMdd):<19500101 , where book. is the bookshelf form's field of Smart Dropdown type, which is reference to books form record and authors. in its turn is the books form's field of Smart Multiselect type, which is reference to author form record and dob is the field name of author form, which is transformed by virtual function formatDate.

ConfiForms TableView
filterbook.authors.dob.formatDate(yyyyMMdd):<19500101
messageToShowWhenEmptyNo books found
formNamebookshelf
showRecordsCountLabelBooks found:

book

status



Code Block
book.authors.dob.formatDate(yyyyMMdd):<19500101

To find books which status is Available and title starts with word 'The', we should use for filter expression logical operations: 

book.title:The* AND status:avail

ConfiForms TableView
filterbook.title:The* AND status:avail
messageToShowWhenEmptyNo books found
formNamebookshelf
showRecordsCountLabelBooks found:

book

book.authors

status



Code Block
book.title:The* AND status:avail

To find books which title starts with word 'The' or available books of Jojo Moyes, we should use for filter expression logical operations: 

book.title:The* OR book.authors.lastName:Moyes AND status:avail

ConfiForms TableView
filterbook.title:The* OR book.authors.lastName:Moyes AND status:avail
messageToShowWhenEmptyNo books found
formNamebookshelf
showRecordsCounttrue
showRecordsCountLabelBooks found:

book

book.authors

status



Code Block
book.title:The* OR book.authors.lastName:Moyes AND status:avail

To find books that were registered without authors, we should use for filter expression: book.authors:[empty]

ConfiForms TableView
filterbook.authors:[empty]
messageToShowWhenEmptyYou have not took any books yet
formNamebookshelf

book

book.authors

status




Code Block
book.authors:[empty]

To find books that were registered today, we should use for filter expression: created:[today]

ConfiForms TableView
filtercreated:[today]
messageToShowWhenEmptyYou have not took any books yet
formNamebookshelf

book

book.authors

status




Code Block
created:[today]

To find books with more than one author, we should use virtual function asCount in filter expression: book.authors.asCount:>1

ConfiForms TableView
filterbook.authors.asCount:>1
messageToShowWhenEmptyYou have not took any books yet
formNamebookshelf

book

book.authors

status




Code Block
book.authors.asCount:>1

To find books with only single author, we will use symbol ! to reverse the previous expression in filter: !book.authors.asCount:>1

ConfiForms TableView
filter!book.authors.asCount:>1
messageToShowWhenEmptyYou have not took any books yet
formNamebookshelf
showRecordsCounttrue
showRecordsCountLabelBooks found:

book

book.authors

status




Code Block
!book.authors.asCount:>1

Show taken books only for logged in users

ConfiForms TableView
filterstatus:taken AND !_user:""
messageToShowWhenEmptyYou have not took any books yet
formNamebookshelf
showRecordsCounttrue
showRecordsCountLabelBooks found:

book

book.authors

status


Code Block
status:taken AND !_user:""