# Knack Blog

The Knack team on web applications, online databases, and beautifully designed products.

## Upgrading our Text Combo to Text Formula

We just gave our text combo field so many new super-powers we had to rename it.

Introducing the new Text Formula: it’s a magical combination of our old Text Combo field and the recent equation updates.

You can combine any text values like before but now you can also include a great library of text-based functions.

## Better Data with Validation Rules

Your database is only as good as the data it contains.

In most cases this is obvious. If you are calculating order totals, you’l need each order to have a number that can be added together. If you are running monthly reports you’ll need some valid dates to group by month.

Other cases are more subtle. You may want to only accept dates that are in the future, or define allowable ranges for a number.

Data that breaks these types of rules may not crash your database, but getting those values right can be just as critical to ensuring your data is meaningful and correct.

Knack has always helped by ensuring field types and providing options for values to be required or unique.

We recently added a feature that dramatically expands Knack’s validation capabilities: validation rules.

## All the Math Functions!

When we first launched our equation editor we were pretty excited: the ability to use field values in mathematical (and date-driven) equations opened up exciting functionality.

We considered adding more advanced equations like rounding or exponents, but decided to keep it easy with basic arithmetic. We figured our users would appreciate the simplicity and how well it worked.

Boy were we wrong.

We immediately started seeing demands for all sorts of functions (is a hyperbolic tangent function really needed? yes, yes it is).

Many of these opened up major features like mortgage amortization and equipment depreciation. It quickly became a no-brainer decision: we had to completely redesign our equation editor.

We recently released this upgraded equation editor, complete with a whole new library of functions:

A major change is simply how it works. Instead of a largely point and click approach we’ve opted for a typing-based approach:

• As you type a dropdown menu of fields and functions becomes available to autocomplete.
• Each field or function in the menu provides some additional contextual info about how to use it.
• As you construct your equation you’ll get instant feedback on how it works and whether it’s valid above the editor.

## New functions

We included a whole slew of mathematical functions that are now available to integrate with your equations.

Some highlights include:

• ceil – Round a value up to the nearest integer. Example: ceil(4.2) = 5
• factorial – Compute the factorial of a number. Example: factorial(5) = 120
• max – Get the maximum of a list of values. Example: max(1,6,9) = 9
• mean – Compute the mean of a list of values. Example: mean(1,6,8) = 5
• median – Compute the median of a list of values. Example: median(8,9,1) = 8
• min – Get the minimum of a list of values. Example: min(42, 100, 3) = 3
• pow – Calculate the base to the exponent power. Example: pow(7,2) = 49
• randomInt – Get a random integer between two values. Example: random(1,42) = 36
• std – Compute the standard deviation of a list of values. Example: std(1,5,42,78) = 36.07861785970558
• sqrt – Calculate the square root of a number. Example: sqrt(81) = 9
You can view the full list of functions here.

## Conditional Equations

You could always use conditional rules to include logic with field values an equation uses, or to choose from multiple equations.

You can now include logic right in the equation to create conditional equations.

It’s called a ternary operator and works like this: (condition ? equation_1 : equation_2)

This means if your condition is true, Knack will use the equation followed by the ? symbol. If your condition is false, Knack will use the second equation followed by the : symbol.

## Search Upgrades: Find More Needles

Searches and filters are critical components to any online database application.

They’re what help you find the needles in the haystack of your data and turn it into something actionable. If you can’t find it, you can’t learn anything from it.

We’re making a big effort in improving our search and filters, starting with some recent upgrades to our search view.

This includes new features that enable more flexible search layouts:

• Display filters into up to 3 columns
• Control label placement
• Group filters together and add titles and instructions

This also includes a big search improvement for how multiple choice and connection fields work:

• Allow a single option or many options to be selected.
• Display as dropdowns or checkboxes and radio buttons.
• Determine to show results for ANY match or ALL matches.

This provides a lot of flexibility for creating AND/OR type searches with multiple options.

For example, this is perfect for searches that are common in real estate apps, where you may want to find properties with any match from the list of house types but match all of the selected features.

Stay tuned for more updates on and/or searches and more improved filters.

Connections are at the heart of any database. Being able to connect one record to another record is what separates a spreadsheet from a database.

Our goal for Knack has always been to enable unlimited flexibility with connections.

Need a one-to-one, one-to-many, or many-to-many relationship? No problem. Need more than one connection between the same objects? Can do.

Once your connections are set up we automate everything behind the scenes so they are simple to use and leverage throughout your application.

We recently released some new features that continue to improve this flexibility and automation.

## Moving and Copying

One benefit of having a passionate user base is that they don’t hesitate to let you know how you can improve your product.

A major refrain over the years have been variations on the need to copy and move different things:

• “Can I copy this form I just built to another page? I don’t want to create it again.”
• “I created a calendar but put it on the wrong page, can I move it?”
• “How can I copy the fields from this object into another object”.

We listened! We’ve now incorporated move and copy functions for objects and fields in the database and pages and views in the interface.

# Copy and Move Views

You can now drag any view in your interface to move and copy it to another page.

Simply drag it into the page from the left menu:

You can only copy a view to an eligible page: for child pages this means the page knows about the same object as the view you’re copying. For example, you can only copy an employee details view to another page that is displaying a specific employee record.

Once you drop it over a page you can confirm if you want to move or copy that view.

If you copy a view that links to child pages those pages will also be copied. For example, copying a menu linking to a new page or a table linking to a details page.

You can also copy views using the settings link in the top right when you are editing a specific view:

# Copy Pages

You can copy top level pages from the right menu:

This will create a new copy of that entire section: the top level page and any child pages.

If you need to copy specific child pages then you can copy the view that links to those page (see above).

# Copy Objects and Fields

You can copy objects and fields using the link in the right column:

You can choose to copy to an existing object or create a new object, and then choose which fields to copy:

Currently only fields will be copied. Future upgrades will include the ability to copy your records as well.

We’re constantly working on improving the builder experience and we hope these changes will make it easier and faster to work with your application. As always, let us know what else we should be working on!

Your tables are about to thank you. We’ve released some great new options for enhancing colors, icons, backgrounds, and more!

To access these new features, edit a column in any table in your interface. A new Layout tab let’s you control width and alignment:

The Display Rules tab let you create conditional rules for applying different colors, icons, and styles to each value in that column:

Here are some popular examples for enhancing your table:

• Display icons for different project statuses
• Display expiring dates in red
• Display high priority leads in bold
We’re excited to see some enhanced tables out there, and we have more options in the works!

## Accept Payments with your Knack App

When we first started brainstorming about the idea that would lead to Knack we always talked about including payments. It was a while ago, but I’m pretty sure that some dollar sign or credit card drawing was on one of those early whiteboards.

It made perfect sense: E-Commerce adds so much power and really opens up the potential for the types of apps that can be built with Knack:

• A customer portal can allow customer to pay invoices.
• A purchase order app can include payments for those orders.
• A donation management app can take live donations that plug right in.
After a lot of careful thought and development we’re thrilled to release our first round of E-Commerce features so you can now accept payments with Stripe or PayPal!

Please note that E-commerce features only available on our Pro plans and above.

## User Workflow

User logins are one of Knack’s most powerful features. They let you build applications where users can log in and have permissions to access specific records.

We recently converted two user attributes into database fields:

• User Roles: this controls which roles the user is assigned to. Each role can have access to different pages of the app and be connected to different records.
These two attributes used to be private settings that couldn’t be exposed in your app. By making them fields you can now use these in your apps just like any other field — including filters, form rules, and the API.

This opens up some powerful user workflow features:

User Paywalls

Form rules, tasks, and the API can be used to update the user status to “approved” or “inactive” when a certain transaction happens. If you start a user as “pending approval” then they won’t be able to login until the status is updated. You can even use Zapier to update this status when a payment is made from Stripe or Paypal.

Role Promotions

Likewise you can assign a user role with form rules or tasks. Conditions can be used to determine which user role to assign. For example, a user can be assigned a role when a certain amount of points are scored.

User Management

Because these attributes are now easily controlled from your app, you can create a specific page for “Admin” users to login and manage user rights and statuses without needing to access the builder.

We’re really excited about the possiblilties this opens up to add user workflow features to your online database. Let us know how you’re using these so we can share other great examples.