After creating a form and validating that the data put into it will flow through into the template document in the way you expect, you might start looking at how you want users to actually use it. You might want to embed the form in your website for unauthenticated users to be able to access, or share the form to internal users you have provisioned on the platform. You might even want to do a little of both and embed the form into an internal website where users log in to that site separately while all being authenticated under one Syntaq user.
An issue with any of these implementations is going to be access to records. In the case of an internal website, embedding a records page or using the record load option for embedding the form itself may be sufficient. However, for an unauthenticated user or where potential conflicts might arise from other users having access to the same records, embedding records is just not an option.
So where do you go from here? The answer is to create an email workflow to run on form save, to send a link to the user which grants access to the form and data record they have just saved.
Creating the App
You will then be required to name the App and add some data to use when testing the App. You can use an empty data set - {} - if you want to get this step done quickly.
- A document can be added to the flow, but this is not recommended.
- The record settings should be similar to (if not the same as) those for when you submit the form. This will allow admins to easily identify the records.
- An email address to send the link to will be required. This will need to be a value from the form itself which is either pulled in from a prior integration, or a required input field.
The link to your form will depend on your implementation, but should always be placed in the body of the email, and will take the following form:
<a href='https://[formurl]?AccessToken={AccessToken}&RecordMatterId={RecordMatterId}&RecordMatterItemId={RecordMatterItemId}&version=live'>Open Form</a>
Triggering the App to run On-Save
window.BeforeFormSave = function() {Form.data.AccessToken = Syntaq.Form.AnonAuthToken;Form.data.RecordId = Syntaq.Form.RecordId;Form.data.RecordMatterId = Syntaq.Form.RecordMatterId;Form.data.RecordMatterItemId = Syntaq.Form.RecordMatterItemId;Form.data.FormId = '[Your Form ID]';var data = JSON.stringify(Form.data);abp.appPath = _SyntaqBaseURI;abp.ajax({type: "POST",contentType: 'application/json',url: _SyntaqBaseURI + '/api/services/app/apps/run',data: '{"Id": "[Your App ID]", "FormId": "' + Syntaq.Form.FormId + '", "AnonAuthToken" : "' + Syntaq.Form.AnonAuthToken + '", "Data" : ' + data + ' }'}).done(function (response) {toastr.info('Your Form has been saved. Please check your email inbox.');});return false;}
Of Further Note
If the form is also used in a project and you don't want this functionality to be present when the form is used in that context you will also need to condition on whether or not the data for ProjectId exists.
If you have any questions, or some of the above is not clear, let me know,
Comments
0 comments
Article is closed for comments.