UPDATE: This tutorial is only applicable for Espo 5.9 and before
This is the continuation of the previous thread: https://forum.espocrm.com/forum/deve...ng-page-part-1
Due to the length of the additional scripts required, I opted for saving them in GitHub where they can be downloaded instead of posting them in this thread, and concentrate on explaining the functionality of each.
Steps cont'd:
5) Create js script client/custom/src/views/modals/registration-request.js copying the code from https://github.com/telecastg/espocrm...ion-request.js
This is the view class that will render a form in a modal window where the visitor can enter its information to request to be registered as a portal user.
The information required from the visitor is:
First Name
Last name
Email Address
Cell Phone Number
The view will use template client/custom/res/templates/modals/registration-request to render the form and when the visitor clicks on the "Submit" button, it will invoke the entry point anonymousRegistrationRequest.php which will initiate processing the request at the back end.
6) Create template script client/custom/res/templates/modals/registration-request.tpl copying the code from https://github.com/telecastg/espocrm-self-registration-tutorial-files/blob/master/client/custom/res/templates/modals/registration-request.tpl
This is the template called by the view script above.
7) Create php script custom/Espo/Custom/EntryPoints/AnonymousRegistrationRequest.php copying the code from https://github.com/telecastg/espocrm...ionRequest.php
The entry point will call the service RegistrationRequest.php function processAnonymousRegistrationRequest which will actually process the registration request and will provide a response message, which the entry point will send back to the front-end view to be displayed to the user at the registration request form.
8) Create php script custom/Espo/Custom/Services/RegistrationRequest.php copying the code from
https://github.com/telecastg/espocrm...ionRequest.php
The service will perform the following functions to process the request:
First it will execute the function processAnonymousRegistrationRequest invoked by the entry point. The goal of this function is to determine if the registration request is a duplicate by attempting to match the information provided by the visitor with an existing portal user, the parameters used for comparison are the ones entered by the visitor: first name, last name, email address and cell phone number.
If an existing portal user is matched, the system will send an email to the visitor informing it of the existing duplicate, providing the username in record and requesting that the visitor go back to the login page and request instead a change of password.
If no matching portal user is identified, then the system creates a new RegistrationRequest record with the data provided and notifies the administrator via email of the pending request for approval or rejection.
This tutorial does not cover possible automated actions after the Administrator has approved or rejected a request, such as sending a rejection email or automatically creating a new portal user. Such actions could be easily implemented using BPN or by coding them in a hook for the RegistrationRequest entity that is triggered when the entity status changes from "Received" to either "Approved" or "Rejected".
Another strong candidate for improvement is the processAnonymousRegistrationRequest function contained by the RegistrationRequest Service, which detects possible duplicates.
This function could be modified to perform more sophisticated comparisions, for example, in our business (Rentals Management), we include two additional fields in the request "Current Rent" and "Postal Code" and we use those fields to locate existing tenants that might have changed their cell phone number or email address.
This is the continuation of the previous thread: https://forum.espocrm.com/forum/deve...ng-page-part-1
Due to the length of the additional scripts required, I opted for saving them in GitHub where they can be downloaded instead of posting them in this thread, and concentrate on explaining the functionality of each.
Steps cont'd:
5) Create js script client/custom/src/views/modals/registration-request.js copying the code from https://github.com/telecastg/espocrm...ion-request.js
This is the view class that will render a form in a modal window where the visitor can enter its information to request to be registered as a portal user.
The information required from the visitor is:
First Name
Last name
Email Address
Cell Phone Number
The view will use template client/custom/res/templates/modals/registration-request to render the form and when the visitor clicks on the "Submit" button, it will invoke the entry point anonymousRegistrationRequest.php which will initiate processing the request at the back end.
6) Create template script client/custom/res/templates/modals/registration-request.tpl copying the code from https://github.com/telecastg/espocrm-self-registration-tutorial-files/blob/master/client/custom/res/templates/modals/registration-request.tpl
This is the template called by the view script above.
7) Create php script custom/Espo/Custom/EntryPoints/AnonymousRegistrationRequest.php copying the code from https://github.com/telecastg/espocrm...ionRequest.php
The entry point will call the service RegistrationRequest.php function processAnonymousRegistrationRequest which will actually process the registration request and will provide a response message, which the entry point will send back to the front-end view to be displayed to the user at the registration request form.
8) Create php script custom/Espo/Custom/Services/RegistrationRequest.php copying the code from
https://github.com/telecastg/espocrm...ionRequest.php
The service will perform the following functions to process the request:
First it will execute the function processAnonymousRegistrationRequest invoked by the entry point. The goal of this function is to determine if the registration request is a duplicate by attempting to match the information provided by the visitor with an existing portal user, the parameters used for comparison are the ones entered by the visitor: first name, last name, email address and cell phone number.
If an existing portal user is matched, the system will send an email to the visitor informing it of the existing duplicate, providing the username in record and requesting that the visitor go back to the login page and request instead a change of password.
If no matching portal user is identified, then the system creates a new RegistrationRequest record with the data provided and notifies the administrator via email of the pending request for approval or rejection.
This tutorial does not cover possible automated actions after the Administrator has approved or rejected a request, such as sending a rejection email or automatically creating a new portal user. Such actions could be easily implemented using BPN or by coding them in a hook for the RegistrationRequest entity that is triggered when the entity status changes from "Received" to either "Approved" or "Rejected".
Another strong candidate for improvement is the processAnonymousRegistrationRequest function contained by the RegistrationRequest Service, which detects possible duplicates.
This function could be modified to perform more sophisticated comparisions, for example, in our business (Rentals Management), we include two additional fields in the request "Current Rent" and "Postal Code" and we use those fields to locate existing tenants that might have changed their cell phone number or email address.
Comment