Hi Team,
I have a business scenario where let's say a user will first filter records for export(let's say export to excel) and if the records are more than 50 then before exporting the records user requires an approval from the department admin over email, Once the user receive an approval over email then only he/she will be able to export those records from system.
Note : Email for approval can be sent from the system, but approval email received will not come into the system.
Please suggest you solution how we can achieve this in Creatio.
Thank you for your time!
Like
Hi Akshit,
This task can be achieved using the following scenario:
1) Create two boolean columns in the "System administration object" (SysAdminUnit) object. One of them will be called "Was approval sent?" the second will be "Was approved?"
2) The preparation method that is called when clicking the export to excel action is called exportToExcel and located in the BaseDataView module that then calls the exportToExcel method from the GridUtilitiesV2 that then calls exportToExcelFile method from the DataUtilities module (all according to the call stack of calls, you can debug it on your end).
You need to add additional check if the "Was approved?" and "Was approval sent?" booleans are checked for the user that initiated the export. To get the current user info you can use the user session (can be received using Terrasoft.sessionId) and then you can perform an ESQ select query to SysUserSession object to get the UserId and then perform another ESQ select query to get information from the SysAdminUnit object directly (we are interested in two boolean columns and the SysAdminUnit Id column value).
3) If the "Was approved?" and "Was approval sent?" booleans are not checked then you need to trigger a business process that will send an email (using ProcessModuleUtilities). You need to pass the SysAdminUnit Id column value as a parameter of this process and use it inside the process to form a link to either Reject and Approve "Call to action" buttons.
4) To either approve or reject the possibility of export an email with two options "Approve" and "Reject" should be sent. The link should lead you to the webservice on the Creatio side. This webservice should update the specific SysAdminUnit record with an Id that will be passed as a parameter to this webservice (and the parameter will be specified as a part of the link).
As for the link itself it can be formed as a text parameter (based on the Id passed from the UI using ProcessModuleUtilities) and passed to the HTML body of the custom template in the "Send email" element as:
"<a href=" + [#LinkParameter#] + "><img alt= \"Accept\" src=\"link_to_the_image_here\" width=\"100\" height=\"100\" ></a>"
Before sending an email the "Was approval sent?" checkbox should be checked for the SysAdminUnit record (using modify data for example).
5) The webservice will update the boolean columns "Was approved?" and "Was approval sent?" using the following scenario:
5.1) If the approval was rejected - uncheck both "Was approved?" and "Was approval sent?" checkboxes for the user
5.2) If the approval was approved - check the "Was approved?" boolean and uncheck the "Was approval sent?".
6) On the section module also add additional check for both boolean columns (as in step 2): if the "Was approved?" is checked and the number of exported items is greater than 50 - permit the export and uncheck the "Was approved?" checkbox for the user.
Please study the scenario I described above and use it when implementing the logic on your end.
Best regards,
Oscar