The forms module allows integrations with 3rd party systems, including CRMs and payment gateways.
Custom form submission
It is now possible to configure a form built with the Contensis forms module to post its data to a custom URL. The default behaviour is to continue to post data to the Contensis forms service, which will create the form post and any other processes such as file uploading and notifications.
By posting the data to a custom URL, you can handle the form submission any way you choose. This gives you all the flexibility and ease of use of our form builder, but the scope to perform any custom behaviour you would like.
The Post to Custom URL option is available on the Form Settings tab of each form allowing you to customise it on a per-form basis.
When selecting the Post to Custom URL option, you are then presented with options to enter the URL and to also indicate whether you also want the form responses saved to Contensis.
Accepted URL Types
The Post to Custom URL option can be set to an absolute URL where the post will be routed to the absolute URL you have specified e.g.
Convention based routing
Alternatively, you could use Convention Based Routing and supply the name of an Api Controller that exists within your website, such as:
Post to Custom URL
|Post to Custom URL
This means that if we were to create a Contensis form and we would like to post the results to our MicrosoftDynamicsCRM Controller, then we would set the Post to Custom URL setting to /MicrosoftDynamicsCRM/ and create an ApiController looking like this:
You can see the class has the name you have specified in the Post to Custom URL set in the Form, but with a ‘Controller’ suffix. This is a standard convention within MVC so will be familiar to developers.
Handling form posts - ContensisFormsApiController
Contensis now ships with a specific implementation of an ASP.NET WebAPI 2 Controller called ContensisFormsApiController. We recommend that when you are extending a Contensis form in this way, that you always inherit from this ApiController as it handles some of the heavy lifting for you.
The ContensisFormsApiController itself fulfils the following functions:
- Uses the Convention Based Routing to make it easy for you to hook it up the Custom URL specified in the Form Settings for your form.
- Allows you to suppress the creation of a Form Post for a given Form - useful for initial development and debugging.
- Allows you to update a form post with new data.
- Gives access to the created form post via the FormPost property.
An example empty template ContensisFormsApiController is shown below:
Updating form posts
As seen in the previous example, you can also update form posts. Any fields within your form can be updated.
Another potential use for this facility is having a form on your website which is used to collect personal information from your users and what products or course they may be interested in.
Using the UpdateFormPost method, you will be able to collect that information, create a form record within Contensis, add a record in to a CRM system marked as being a lead or potential student, then update the Contensis Form Post information with the CRM ID of the lead.
The UpdateFormPost method exists in the Base Class ContensisFormsApiController and it is this where the update to the form data is performed.