All Collections
Form Builder
Form Scripting & Calculations
Pulling data from a contact form into an activity/assessment form
Pulling data from a contact form into an activity/assessment form

How to use our cross-form Lua scripting language to access contact form data from an activity or assessment form

Angela Lim avatar
Written by Angela Lim
Updated over a week ago

With our Lua scripting feature, you can easily access data entered into a Contact Form from an Activity or Assessment form.

For example, you could look at information collected in a "Client" contact form about a client's insurance to make decisions about their level of need, and save that information in an Intake Assessment form. 

The first step to using the Lua script across forms is to make sure you have slugs added to everything you need to reference. This includes:

1. The Contact Form slug

2. Slugs on the fields inside the Contact form

3. Slugs on the fields inside the Activity/Assessment form

Once you have slugs set up, you can begin writing the Lua script needed in the Activity/Assessment form's Script box. 

To reference a field inside of the activity/assessment form, use the regular syntax of answers.field_slug 

To reference a field inside of the contact form, use the syntax:
contact.cst.cst_slug.field_slug 

...where cst_slug  is the slug of the Contact Form and field_slug  is the slug of the field inside the Contact Form.

In the example above, we want to know, based on the selection in the Insurance field in a Client's contact form, if the contact is High Need or Low Need.

In our Assessment form script, we could write:

if contact.cst.client.insurance.private then 
answers.level_of_need = "Low Need"
else
answers.level_of_need = "High Need"
end

With this script, if a Client was created and the Insurance option for "Private" was selected, when we started a new Intake Assessment form, the "Level of Need" field would auto-populate with "Low Need". 

Field Mapping

You can also use this cross-form Lua feature to map fields from your Contact Form directly into an Activity or Assessment form. 

If you would like to pull a contact's age into an Activity or Assessment form, but it has already been entered in a Contact Form - there is no need to re-type the age over and over again!

Simply reference it from the Script box:

answers.age = contact.cst.client.age 

This looks at the field with the slug called age , in a contact form with the slug client . It takes whatever is in that value, and adds it to the Activity/Assessment form field with the slug age .

This does not currently work with Address, Phone Number, Time, Single Select/Multi-Select, Relationships or Likert fields - but we will be adding those as improvements to this feature!

Did this answer your question?