Formstack custom formulas can be used in a few different places within Formstack to generate custom values. Custom formulas are currently supported by the following Formstack features:

  • You can dynamically populate fields with custom formula results using the 'Populate' action in the rule editor.
  • You can set a custom file name for PDF copies of your form.
  • You can set a custom file name for files uploaded within a File Upload general field.
  • You can set a custom formula for a field's default value.

Custom formulas use basic Javascript syntax. To write custom Javascript for your populate action, simply wrap the Javascript in double braces. For example, to populate a field with today's date, you can use the following formula and enter it as the default value:




You can also include fields from your current form as part of your formula as well.


First, find the "Id" of the field you are working with, by right click + Inspecting the input field that you wish to reference. For example, if I wanted to Reference the "Last Name" field from the contact object:


You would write [[Contact.LastName]]


This can have several applications, for example if you want to populate an Account Name field with the First name and Last Name of the user filling out the form, you could create a rule like this:



You can also do basic arithmetic. Here's an example of a formula that outputs 10% of a contact's salary:




Wrap your formula in curly braces {{ }} for Javascript functions.


Here are some other useful formula samples you can try for yourself:  


Generate a timestamp

{{new Date().toISOString()}}

Get a contact's first initial and last name


Calculate sales tax


Generate a random number between 1 and 1000

{{Math.floor((Math.random() * 1000) + 1)}}

Call custom functions defined in Custom Javascript window


Output today's date



Note: Custom formulas will only work on your published forms, not when using the preview option.

Was this article helpful?
13 out of 28 found this helpful



Article is closed for comments.