Setting E-form Field Values Dynamically
E-forms are great for collecting data from internal and external users. You can use them to present easy-to-use fillable forms that make entry simple and elegant. Even so, there are times when you may want to automatically fill in information to make the user’s task even easier. In this article – “Setting E-form Field Values Dynamically” – we will explore a few ways you can make a good E-form even better with automation.
Simple Example
A simple example of setting E-form field values dynamically is a form where the user is given a choice of buttons to click. Each button will set a field on the form to a different value. This might be useful if you have a survey form where each button is a star rating. Each button would save its rating value to a field that is saved when the form is submitted.
To do that, you can set each button’s action type to “Set Field Value”, select the field to set then enter the value to set it to. This screen shot shows a typical configuration to do this. The field we are setting is called “Rating” and the value we are setting it to is “1”.
This example is available for download at the end of this article. Unzip it and import it into the E-forms list.
Intermediate Example
A more complex example of Setting E-form Field Values Dynamically may be that one button click sets multiple fields’ values. A button cannot do that directly, but we have a Multi-Action Field that is very useful for this task.
Let’s expand on the previous example a bit. Instead of just setting a star rating, we also want to know if the user would recommend our product or service. For this we will add another hidden field named “Recommendation”. We will have 8 buttons on this form – 4 for 1 thru 4 rating with a YES for recommending and 4 for 1 thru 4 rating with a NO for recommending. Each button click will now use a “Trigger Multi-Action Field” action which will call its own Multi-Action field that sets both values.
The Mult-Action fields will have 2 actions in them – 1 to set the star rating field and 1 to set the recommendation field.
This example is available for download at the end of this article. Unzip it and import it into the E-forms list.
Advanced Example
An even more complex example may require calling the server to get data to use for setting field values. Another action type that is available is “Run Action Set.” this action type will send data from the E-form to the server and will accept data back to update field values.
In this example, let’s start by building an E-form that allows a user to click a button to return values from the server to fill in fields on the form automatically. We will have 2 fields – Company Name and Company Address. To pull this off we will need to add an Action Set into our solution.
Our Action Set will simply return values to the calling E-form using the “Set Return Data” action. This action will return the Company Name and Company Address values. The secret to making this work as easy as possible is to set the Field Names in the “Set Return Data” action to the exact names used in the E-form fields. Any values sent back to the E-form will update the field that has the same name as the values returned.
For our example, we have 2 fields in the E-form we want to update. The actual NAMES of the fields are “CompanyName” and “CompanyAddress”.
Therefore, we need to be sure our “Set Return Data” action uses the exact same names.
When the Action Set is called from our E-form, the CompanyName and CompanyAddress values will be sent back to the E-form and our values will be placed into those fields by their name. But HOW do we call the action set? We use the “Run Action Set” action type in a button or Multi-Action field or another event.
When the above button is clicked, it will call that Action Set and the returned data will come back into the form. In this example, the returned values are static – i.e. we typed them into the action. In most real-world uses, those values would be looked up from other Records. You can add into the Action Set things like Search and Updates which will look up values and send them back to the E-form using the “Set Return Data” action.
Also, if you notice, there is a “Fields To Use” field in the configuration above. You can enter fields from the form whose values you want to send into the Action Set. Those values can be used to look up matching return values. You might have the user select an option from the E-form and send that option value into the Action Set. The Action Set looks up data corresponding to the selected option and sends other values back. One scenario where this might happen is when selecting a Vendor from a list. Once selected, the E-form calls the server and pulls back the vendor’s address, city, state, Zip, etc. for display in read-only form fields.
This example is available for download at the end of this article. Unzip the sample then import the E-form into the E-forms list and the Action Set into the Action Set list. Then edit the E-form and set the button’s action to call the “Article – Complex Example” Action Set.
Setting E-form Field Values Dynamically Samples
Simple – Eform-SetFieldValue-StarRating
Intermediate – Eform-SetFieldValue-StarRatingRecommendation
Advanced – Eform-SetFieldValue-ComplexExample
Related Articles