How I Learned to Like It

By Jennifer Neighbors, Senior Consultant

When I first started coding in Ninox, which is not very long ago, I didn’t know much about the concept of “like”. I stuck to the standard constructs I had learned when first starting out and that worked well for me for a time. Then I discovered “like”. Now that I have a more experience, I use “like” quite often and that lets me do things I couldn’t do before. Let me explain. A very common code phrase is:

‘if a = b then …. Do this, else do that or the other thing’

Good. Now, what if b does not equal a, yet has some a in it? That is when b is “like” a, and you can write code around that! Here’s an example:

‘select “FRUIT” where Type like “berries”’

returns all the records in table Fruit where the field Type has a value that includes the word “berries”. Type might include other values, too, like bananas and mangos. It might be a text field or a multiple choice field. Doesn’t matter. As long as the text string “berries” is stored somewhere in that field named Type, the record will be included. You’d get all the strawberries, raspberries, and blackberries. You can also use this in reverse. For example, you might find yourself needing this bit of code:

‘if ‘First Name’ like “Tim” = “No“ then do this, else do that’

If you have a multiple choice field where more than one value is possible, and you want to display another field based on whether a particular selection has been made, you will absolutely have to use this method. Let’s say Type is a multiple choice field. Try placing this phrase in the “display field only if” function of another field:

‘text(Type) like “apples”’

Now select a few values in Type – but don’t select “apples”. Your field will disappear. Now select “apples”. Your field will appear, even if other items are also selected.

en_USEN