
In the previous blog, my colleague and Senior Architect for SAP BTP, @mohit_bansal3 (Linkedin), explained the business drivers and expectations, detailing end-to-end scenarios utilizing SAP Build Process Automation-based SMTP Inbound.
In this second blog post, I will walk you through the development steps in detail.
We have prepared the content for this series in three blogs, where we will be diving deep into Design, Development, and Testing.
As described in the previous blog post, we are using Google for external authentication. A similar approach is available for Microsoft 365-based development as well.
Now, let’s dive deep into the technical development process.
Development Process
Step 1: We have created an Action Project Workflow API which will be used to read workflow details and update the workflow status after approval or rejection.
SAP Build Process Automation: Action Project
Step 2
As the next step, we will be creating an SAP BPA Automation Project as follows:
SAP Build Process Automation Cockpit
Step 3: Dependency Injection
As the next step, enable Google Authentication in the settings of the Automation Project. This step will activate Google Authentication, allowing the project to search and read Google emails.
Dependency Injection
Additionally, add the dependency for the Action Project that we created earlier.
Dependency for the Action Project
Step 4
We have also created a datatype that will hold the data and bind the workflow API for posting purposes.
Datatype: hold the data and bind the workflow API
Step 5
We are now ready to invoke Google Authentication and proceed with the development of the “Inbound SMTP.” Please refer to the flow chart below, which outlines the corresponding steps for enabling the necessary dependencies for Google Authentication within the project.
Step 6 : Search Unread Gmail email with Specific Subject
One of the most important activities in the process flow is to search for unread emails. We perform this search based on the subject line “Please Approve Request ID:”. All matching emails are then collected into an array called messageIdentifier.
Step 7 : Iterating the Email and Validations
The next step involves looping through all unread emails with a valid subject line relevant for processing. Here are the detailed considerations and steps:
Loop Through Unread Emails
var Req_id = Subject.split(":")[1];
var processedBody = Body.split("On")[0];
if (Body.substring(0,2) =="ok" || Body.substring(0,8) =="Approved") {
return {
"Recipient": From,
"Content": "Your request has been approved automatically",
"approved": "yes"
};
}
else if (Body.substring(0,2) =="no" || Body.substring(0,8) =="Rejected") {
return {
"Recipient": From,
"Content": "Your request has been rejected automatically",
"approved": "yes"
};
}
else {
return {
"Recipient": From,
"Content": "Your request has been Rejected automatically",
"approved": "tbd"
};
}
Extract Workflow ID
Step 8
Now, fetch the workflow details using the valid Request ID. This step involves validating that the response is coming from a valid approver. This validation is crucial to ensure the integrity of the approval process. Below is a detailed explanation and a custom script to achieve this:
for (var i = 0; i < TaskRecipient.length; i++) {
if (From.includes(TaskRecipient[i])) {
return true;
}
}
return false;
Step 9
Handling Workflow Responses Now, we have a combination of three possible conditions to handle:Handling Workflow Responses
Complete Flow Chart :
Complete Flow Chart
Here is a complete flow that outlines the process for handling the three conditions mentioned above:
This flow ensures that each email is processed correctly based on the response and the validity of the approver. By following these steps, you can maintain the integrity of the workflow process and ensure that only authorized actions are taken.
Step 10: Final Step
The final step in the process is to send a response email to all the parties involved. This ensures that everyone is informed about the status of the workflow request. Here’s how you can do it in detail:
In the upcoming blog post, @mohit_bansal3 will delve into the Testing Process flow in detail and provide valuable insights with a logical completion of this series.
Stay tuned for a comprehensive guide that will enhance your understanding and streamline your testing process.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
5 | |
4 | |
4 | |
2 | |
2 | |
2 | |
2 | |
2 |