V3 Integration
From Frevvodocs
frevvo Live Forms™ v3
Integration
Email Integration
Form submissions can be emailed to a recipient when the user clicks the submit button. To configure the form to send an email upon submission, open the form designer and click the Form Action button in the toolbar. This will launch the wizard selector. Choose the Email Data to Specified Address wizard.
Each time the form is submitted, frevvo will send an email message with the form submission data, optionally a PDF attachment and if you are using the Professional Edition also an XML document containing the submitted data.
In v3.3 and prior, the email address is limited to a single address. If you require more than a single recipient, set the address to an email group. In v3.4 you can enter multiple comma separated addresses. The email address may either be a static address such as info@frevvo.com or a dynamic address by using template syntax such as {person}@frevvo.com if you want the name dynamic and the domain static or {emailAddress} to make the full email address dynamic.
Here is an example using the dynamic template {emailAddress}. You must name one of your form controls emailAddress.
Step 1: First name one of your controls. You do this by entering a string into the control's Name property as shown below.
Step 2: Next, open the Doc Action Email wizard. Replace jSmith@gmail.com with the template: {emailAddress}
Also you can specify an email address containing a template and static text such as: {customer}@frevvo.com. In this case the value in the form field named "customer" would replace {customer}. If the user enters "Joe" into the customer form field the submission would be emailed to Joe@frevvo.com.
Email Submission Formatting
The form submission data is formatted by default as shown in the image below. The formatting can be customized as required. Contact frevvo client services for more details on how to customize your email output. See the Google Documents Connector.
Print View
All frevvo forms are printable. By selecting a form's printable checkbox a print
icon will be displayed at the top of your form. When the form is used and the printer icon is clicked the form is rendered in a new browser tab in an HTML printable format.
PDF Integration
In v3.4 forms submission can be converted to PDF documents. The PDF document can saved in frevvo's Submission Repository, sent as an attachment to a submission email, or as an attachment to a POST to a back-end system such as a document management system.
The Form and Doc action wizards for email and post submission control whether or not the form is converted to a PDF document and attached to the submission. You can control which form fields are added to the PDF via the printable property on each field in your form.
Document Service
frevvo's built-in document service can be used for processing your form data prior to submission.
The document service is accessed via the Url /service. It supports the following parameters:
- method=POST -- required and should be left POST
- target=[url] -- [url] is the path to your servlet
The target will be passed name/value pairs of all of the controls in your form with their current values. The target will also be passed the collection of xml documents comprising the form's current data. The collection will include at least one document in the namespace 'form' which contains all the data in controls added to the form from palette. The collection will also include one xml document for each data source added to the form.
Custom Print View
One example use of frevvo's document service is to provide a print preview different from frevvo's default print view.
All forms by default are printable. To make a form printable edit the form and check the printable property. Sometimes form designer required a highly customized print view. By calling frevvo's document service you can pass all the form's xml documents to another target servlet that transforms the data into exactly the format you need and then returns html to another browser window.
To do this:
- Add a message control to your form
- Add the following html to your message control
<center>
<a href="javascript:void(0);" onClick="window.open(document.location.toString().split('?')[0] +
'/service?_method=POST&target=http://[myhost]:[myport]/Myservices/service/print/myForm')">Print</a>
</center>
Your transformation service should return html to the browser window. You can style the message control as a button by adding a border, background color and even dragging into a panel to size the "button".
Integrating with REST applications
From the point of view of the user interface, most web applications can be thought of simply as CRUD (Create, Retrieve, Update & Delete) operations on documents. In the diagram below, the form is being used to initially display a Customer and Order and then to update them. If you think in REST terms, the form is a View Resource that composes multiple Entity Resources (in this case a Customer Resource and an Order Resource), displays their current state and allows you to update them.
frevvo provides a very flexible and powerful mechanism for interacting with documents (and the web in general). You can download source code and forms for the discussion below. We strongly recommend that you download the example, study it and use it as a template for integrating with your own web applications.
Document URIs
For each Document Type that you add to your form, frevvo permits you to assign
- a document URI Template resolved either using query parameters or form fields.
- a Read method and
- a Write method.
This is best described using several examples. Consider the example above. Here are the interactions a Customer Resource supports:
| Resource | Method | Description | Returns |
|---|---|---|---|
| Customer List | GET | List of customers (may be criteria based) | XML list of customers |
| Customer List | POST | Create new customer | URI of newly created customer |
| Customer | GET | Get customer data | XML representation of cutsomer |
| Customer | PUT | Update customer | |
| Customer | DELETE | Remove customer |
Updating a document
Consider the case where a form is used to update a particular customer. To create the form:
- Upload your customer schema to the designer, add the customer element to the document types for the form and add the customer to the form (which automatically generates controls). See the section on Adding Controls from Schema for further details.
- Drag/drop, change labels etc. directly in the browser
- Specify URI template .../customers/{customer}, choose Read Method GET and Write Method PUT
- Specify a Form Action URI if desired (we'll get to this later).
That's it. As usual, you access the form using its URI. When the form is used (instantiated), you may specify one or more query parameters along with the URI. For this example, we might use a URI and query parameter:
.../form/1234?customer=02. frevvo will resolve the URI template above to: .../customers/02, GET the customer, and display the initialized form. When the form is submitted, frevvo will automatically PUT the customer document to the same URI thereby updating the customer. The diagram below shows the interactions.
Here's an example form that uses the Customer entity described above. In the example:
- We instantiate the form with a parameter customer=02. This causes the form to resolve the URI template and GET the customer data from: http://[server]/customers/02. The resulting XML document provides the initial state of the Customer and is used to initialize the form.
- Modify a value and click Submit. The form will automatically PUT to the correct resource and update the customer information.
- Finally, frevvo will store the generated document set and assign it a unique URI. The document set and the documents therein can be accessed at this URI.
Creating a new document
Consider the case where a form is used to create a new customer. Follow the same steps above, except use the appropriate URI template .../customers and change the Read method to POST. That's it. As usual, you access the form using its URI. When the form is used (instantiated), frevvo will perform the POST and create the customer. It will then follow the server redirect (to the URI of the newly customer) and display the form. When the user enters customer information and submits the form, frevvo will automatically PUT the resulting XML document to the URI of the newly created customer resource thereby updating it. The diagram below shows the interactions:
Here is an example form that creates a new customer using this method.
Dynamic documents
A document URI template can also be linked to a form control. To do this, use the Control Name. Consider the Updating a document example above and the sample form therein.
The form has a Customer document and we have specified URI template .../customers/{customer} and Read method GET. In this form, there is a control which has Type ID 'customer' as shown in the figure below.
If you enter a value in this control, frevvo will automatically resolve the URI template using the new value and attempt to GET a new document. If it succeeds, the form will be initialized with the new document and all relevant control values will automatically update. In the example above, try changing the value to 03 or 04. Notice how the customer information fields change to reflect the new document that is being edited by the form.
If you enter an ID that does not exist, the GET will fail (return an empty document or a 404 HTTP status code). In this case, frevvo will automatically revert back to the default document with default values as specified by the designer.
In either case, if you modify/fill in fields and submit the form, it will PUT (since we chose PUT as the Write Method, the form will send an HTTP PUT) the resulting XML document to the resolved URI.
For example, if you enter ID 03, frevvo will GET .../customers/03, display the form with fields initialized from the returned XML document and PUT the modified XML document to the same URI when the form is submitted. This PUT will update the customer with ID 03.
If you enter ID 99 (which does not exist), frevvo will GET .../customers/99, which returns an empty document. The form will be displayed with default values (as entered originally by the designer). When submitted, the resulting XML document will be PUT to .../customers/99. This PUT will create a new customer with ID 99 (the behaviour depends on the implementation on the server - in our example, the PUT creates the customer).
Example
This example is a good way to understand frevvo's handling of document URIs and the powerful capabilities of composing multiple document resources into view resources. You can download the entire example including source code and forms by clicking here.
This example follows the principles of REST and uses the Restlet framework but you can use any framework or server-side model that you like. As mentioned earlier, frevvo forms can be thought of as View Resources that compose one or more Entity Resources (documents). In this example we have entities Customer and List of Customers. Reproduced here are the methods that they support.
| Resource | Method | Description | Returns |
|---|---|---|---|
| Customer List | GET | List of customers (may be criteria based) | XML or JSON list of customers |
| Customer List | POST | Create new customer | URI of newly created customer |
| Customer | GET | Get customer data | XML representation of cutsomer |
| Customer | PUT | Update customer | |
| Customer | DELETE | Remove customer |
This is implemented in the two classes: com.frevvo.restlet.customer.CustomersResource and com.frevvo.restlet.customer.CustomerResource. These simply provide implementations of the above methods returning the desired representation of the resource for a GET, creating a new customer for a POST and updating an existing customer for a PUT. In general, the representation that is returned depends on content negotiation via the Accept headers.
Select Customer
There are three forms. The first one is the Select Customer form. This form allows you to search for a specific customer. It uses the first GET method from the table above, and populates a drop down with the list of customers returned according to the search criteria. This is done using a rule. Edit the form, click on the Rules tab and open the Get Customer List rule.
if (S.value.length > 0) {
eval('x=' + http.get('http://<hostname>/customers/?pattern=' + S.value));
C.options = x.customers;
ID.options = x.ids;
}
This rule populates the dropdown Customers based on the list of customers returned by the GET method that is invoked by the rule. When a rule invokes http.get(), it also sets the Accept header in the request to 'application/json'. This causes the implementation to provide the JSON representation of the customer list. In this example, we return two JSON arrays: an array of names and an array of IDs. These arrays are used to populate the two dropdowns in the example - the Customer Names dropdown and the hidden Customer IDs dropdown. Try typing a search string (e.g. A). This will return the list of customers whose names start with A. Select a customer from the list. The second rule in this form ensures that the hidden Customer ID field is in sync with the selected customer.
The Form action for this form is set to the URI template: http://<hostname>/frevvo/web/user/gallery/app/_73zHwep_EduZgK0BUzi1Ug/formtype/__AKE4PgqEdusGKt5_HoCDw?_method=POST&customer={ID}. As described in the Multi Page Forms section above, when the user clicks submit, the URI template above will be resolved based on the selected customer ID and the browser will be redirected to the resulting URI, which is simply that of the next form with a query parameter (customer=02, for example). This form is described below.
Customer Information
This form is described in the Updating a document section above. It GETs the XML representation for a specific customer using the third method in the table above, initializes the form with that information and displays it to the user. When submitted, the updated customer information is automaticlly PUT to the same [resolved] URI using the fourth method in the table above.
Create Customer
This form is described in the Creating a new document section above. When instantiated, it does a POST to the Read URI using the second method in the table above. This causes the server to create a new customer and return the URI of that customer. frevvo will automatically follow this URI, GET the representation of the customer and display the form (presumably with empty values). When the user enters all required fields and submits the form, frevvo will automatically PUT the resulting XML document to the URI for the newly created customer thereby updating the customer.
In this manner, the combination of URI templates, read/write methods and form parameters provides a very powerful and flexible way to interact with the web.
You can find further discussion of this example on the frevvo blog. The relevant articles are: Part 1 and Part 2. Other articles that may be of interest are How do I use my brand new WOA? and Ajax+REST: the next killer app?.
Google Connector
frevvo Live Forms supports direct connectivity with Google Documents and Spreadsheets. The Google Connector allows you to save submissions to Google Spreadsheets and format emails or confirmation receipts using an online Google Document.
Installation Instructions
If you are using Live Forms Online there is nothing to install. If you are using Live Forms In-house and have downloaded the Google Connector:
- rename the download file named connector-google-apps.zip to google.war
- copy google.war to c:\frevvo\tomcat\webapps
Tomcat will automatically expand the war file and start the connector running. If you are not using the frevvo tomcat-bundle or have not installed the bundle into c:\frevvo make the necessary path adjustments to step 2 above.
Google Documents
This feature is currently in alpha release. The syntax may change.
The Google Documents Connector can be used to format emailed form submissions and to echo a formated document back to the page that submitted the form. Here is a sample email formated using the Google Document template shown below.
To use the Google Connector Edit your form. In v3.3 Live Forms use the Form Action Wizard to echo a formatted document back to the page and/or use Doc Action Wizard to format an email message.
If you are using v3.2 or earlier versions of Live Forms you must configure the URL and parameters manually as described below. Open the form properties, set the Form Action to Post and the Url to:
http://www.frevvo.com/google/documents/u/[google username]/p/[google password]/did/[google document Id]
This Url supports the following parameters:
- action=(email/echo) -- This parameter is required. When set to email it emails the submission after formatting. When set to echo it returns the formatted submission back to the brower as the post's response
- email=[email address] -- Required when action=email, otherwise ignored. The formatted submission will be sent to this email address
- cc=[email address] -- Optional. The formatted submission will be cc'd to this email address
- bcc=[email address] -- Optional. The formatted submission will be bcc'd to this email address
- subject=[something] -- Optional. The email subject will be set to this string. Note that spaces are not allowed. They must be manually escaped with %20.
- attachments=(true/false) -- Any documents uploaded as attachments by the user to this form will be attached to the email when this is true. The default is true.
Here is an example Url. In this example your google account username is joe@gmail.com and your password is joe01, and the Google document we want to use to format the form submission, is accessible at this Url: http://docs.google.com/Doc?docid=ddchjczv_85chg7wcfw&hl=en. Note that the doc Id for this Document is: ddchjczv_85chg7wcfw. Make sure that you do not include the next Url paramenter &hl=en when copying the Doc Id from the Google Document Url into the frevvo Google Connector Url.
http://www.frevvo.com/google/documents/u/joe@gmail.com/p/joe01/did/xyzhjczv_85chg7wcfw?action=email &email=joe@mycompany.com&cc=info@mycompany.com&subject=Expense%20Report
In this example, rather than hard coding the To email address to joe@gmail.com we will use a form control template. We added an email control to the form and named that control YourEmail.
http://www.frevvo.com/google/documents/u/joe@gmail.com/p/joe01/did/xyzhjczv_85chg7wcfw?action=email
&email={YourEmail}&cc=info@mycompany.com&subject=Expense%20Report
Note: To determine your document's Id, edit your Google document and look in the brower's Url area.
You can both email the formatted submission AND echo it back to the user. To do both, set the Form Action Url the Google Connector with &action=echo and set the Doc Action Url to the same but with &action=email.
Google Document Template Syntax
This feature is currently in alpha release. The syntax may change.
The Google Document Connector uses a template syntax to insert values from a submitted form into the document. The syntax is ${form.[Name]}. Where [Name] is the name you gave to the particular form field in the frevvo Form Designer. Read more about naming form fields.
Here is a Google document using the template syntax:
Repeats
Repeat controls have a special syntax. Assume that your form contains a repeating section named Expense. First you must add a Repeat As tag to the document. ${repeat form.[Name] as [alias]}. For example: ${repeat form.Expense as exp}. Then use the alias to reference the controls inside the repeat. The Connector's template processor will add a row to the table for each repeating item in the form submission.
Sections
Form controls nested inside sections must be referenced using a nesting notation. If two text controls named Firstname and LastName are nested inside of a section named PersonalInfo then the templates in your google document must be written as:
${form.PersonalInfo.FirstName} ${form.PersonalInfo.LastName}
If you add another section to your form and name it MedicalHistory and drag/drop PersonalInfo into that section, then the templates must be updated and written as:
${form.MedicalHistory.PersonalInfo.FirstName} ${form.MedicalHistory.PersonalInfo.LastName}
Limitations
The connector currently supports only form controls from palette. It does not yet support form controls from XSD data sources.
Templates are case sensitive. If your form field is named Hours then your template must be written as ${form.Hours}. Using lower case as in ${form.hours} will result in no field data in the document.
- Do not try to change the font size, color, etc of the template strings in your document. See known issues.
Google Spreadsheets
This feature is currently in alpha release. The syntax may change.
Writing to a Google Spreadsheet
Forms submissions can be saved directly into Google Spreadsheets.
In v3.3 Live Forms edit you form and use the Doc Action Wizard to configure your form to save your submissions into a Google spreadsheet.
If you are using v3.2 or earlier versions of Live Forms you must configure the URL and parameters manually as described below. Edit your form's properties and set the Doc Action to Post and set the Url to:
http://www.frevvo.com/google/spreadsheets/u/[google username]/p/[google password]/key/[key]/w/[wname]
Where:
- [key] - This is the spreadsheet key (this is found in the URL of the spreadsheet in your browser)
- [wname] - Spreadsheet can have multiple worksheets. This the name of the workbook in the spreadsheet
The names of the fields in the form have to match the names of the columns in the spreadsheet. Read more about naming form fields.
Here is an example Url. In this example your google account username is joe@gmail.com and your password is joe01, and the Google spreadsheet we want to use is accessible at this Url: http://spreadsheets.google.com/ccc?key=pDQtQNgwug49pGw79kcCudw&hl=en. Note that the key for this Spreadsheet is: pDQtQNgwug49pGw79kcCudw. Make sure that you do not include the next Url paramenter &hl=en when copying the key from the Google Url into the frevvo Google Connector Url.
Note: To determine your spreadsheet's key, edit your Google spreadsheet and look in the brower's Url area.
http://www.frevvo.com/google/spreadsheets/u/joe@gmail.com/p/joe01/key/pDQtQNgwug49pGw79kcCudw/w/Sheet1
- A common mistake is to include &hl=en as part of the key string when constructing the frevvo Google Connector Url.
If your form contains multiple documents because one or more controls are from the palette while other controls are from one or more XSD data sources, you can write each document to a different Google Spreadsheet. To do this use the Google Connector Url in your form's Advanced Properties tab. Configure each Uri to a different spreadsheet or workbook within the spreadsheet.
This sample form updates the sample Google spreadsheet below. Note for instance that the form field labeled Birth Date is named in the control's property panel as Birthday. The name Birthday exactly matches one of the Google spreadsheet columns.
Each time someone uses and submits this form, a new row is added to this Google spreadsheet.
This example survey form described above is available click here, where it is embedded in a Google Sites page.
- This frevvo form is being served from a frevvo server as a Google Gadget
- It is embedded in a Google Sites page.
- When you Submit it, it updates two different sheets in this Google Spreadsheet
- frevvo sends you a confirmation email formatted using this Google Document.
Reading from a Google Spreadsheet
frevvo forms can be initialized with data from a Google Spreadsheet. This is done by accessing the Google Spreadsheet via a [Rule].
Here is an form that contains controls for each column in a Google Spreadsheet, plus two extra fields. A dropdown for selecting which row to retrieve from the speadsheet and Rowid.
The rule does an http.get to the Google Connector and passes it two Url Parameters:
- cn=lastname
- cv=LN.value
cn is the column name that will be searched to find a matching row to return to your form and cv is the value that the match is looking for.
cv is the column value being searched form. In this example, LN.value is the option the user selects from the dropdown labeled "To view an existing friend choose their name here:" which is named LN in this form.
The http.get returns all the values from the matched row in your Google SS to a varable named "x". Set each field in the form to the values from the spreadsheet row: ex: firstname.value = x.firstname. The variable x contains a member for each column name for example "firstname", "lastname", etc.. plus one extra member called "rowid".
if (LN.value.length > 0) {
var baseUrl = 'http://www.frevvo.com/google/spreadsheets/u/joe@gmail.com/p/joe01'
eval ('x=' + http.get (baseUrl + '/key/pDQtQNgwug49pGw79kcCudw/w/Sheet1
?cn=lastname&cv=' + LN.value));
if (x.firstname) {
firstname.value = x.firstname;
lastname.value = x.lastname;
birthday.value = x.birthday;
gift.value = x.gift;
RI.value = x.rowid;
}
}
- Currently the dropdown cannot be dynamically populated with values from the Google Spreadsheet. The options must be set statically in your form's dropdown control.
Google Connector Known Issues
The frevvo Google Connector is an alpha release. These are the known issues we are working to solve. Please report any issues or feedback to us here.
| Ticket | Description | Work-around |
|---|---|---|
| 3931 | Google Connector fails to replace templates with form field values |
Text formatting of the templates can possibly corrupt the underlying html document structure. If your document fails to produce results for certain templates, delete the template and re-add it to your document. Copy and pasting template tags can have the same effect. Both problems are due to the fact that the Google Docs is inserting html font tags into the middle of your templates. You can also fix this by cleaning up the document in the html view. But better to avoid the problem initially. |















