' oicbasics: Develop an integration to get dynamic email notification | Oracle Integration Cloud
June 29, 2023

Develop an integration to get dynamic email notification | Oracle Integration Cloud

Knowledge :  ๐Ÿ‘€ 
Notification? : Enables you to send notification email to relevant users at specific points in the execution of an integration.



When we can use dynamic email notification ❓๐Ÿค”

suppose you want to send email notification that contain DATA in TABEL FORMAT which ROWS is not FIXED i.e. body of email notification is not fixed. Sometime it contain 2 rows , in next run it may need 50 rows etc. so table structure needs to be dynamic ---> to handle such use case we need code OF DYNAMIC EMAIL NOTIFICATION.


- Advertisement -




Now lets develop one end to end Integration to see how we can implement logic to get dynamic email notification :

Use Case :

Our requirement is to send the Input data (employee records) of the integration via Email Notification in Tabular Format.
Suppose we have one set of records the then the email table contain one row (as shown in below image)



Similarly if we pass two sets of record, we will get email notification having two sets of record.  
      




- Advertisement -


Lets see the development steps in detail :

STEP 1 :  
Create a new App Driven Orchestration :



Enter the below details and click Create:

*What do you want to call your Integration? : Write a meaningful name
  What does this Integration do? : write meaningful description
            

STEP 2 :  
Search for the REST Connection which we have created earlier and configure it as shown in below image
[ You can access this blog to know - how to Create REST Connection ]


- Advertisement -



Enter below details and click Next - as shown in below image:

*What do you want to call your endpoint ? : write meaningful name
*What is the endpoint's relative resource URI ? : 
 You can give any meaningful word with "/" 
 Example : /dynamicEmail

* What action do you want to perform on the endpoint ? : select POST 
            
   &
   select Configure a request payload for this endpoint


- Advertisement -



   ***Save this below Schema as Email.xsd

  download Email.xsd file from here - click to download

Choose the above saved schema " Email.xsd " in next window & click Next and then click done [as shown in below image]


  

STEP 3: 
Now add one Assign action


Knowledge :  ๐Ÿ‘€ 
Assign ? Enables you to assign variables to integrations.


- Advertisement -


         
Enter below details & click Create:

*Name : write a meaningful name
 Description : write small description
         
click on " + " icon to add variable 

      
Write variable name as vEmail (you can give any meaningful name) and click Edit button 
  

Write the below code in Expression box and click Validate & then click     
Close 

      "<table>
         <tr>
         <th>Name</th>
         <th>City</th>
         </tr>"



- Advertisement -


STEP 4 : 
Now add one For Each action 



Knowledge :  ๐Ÿ‘€ 
ForEach ?  Enables you to loop over a repeating element and execute one more actions within the scope of the for-each action.



Enter the below details and click Create :

*Name : write one meaningful name
*Repeating Element : drag and drop the Employee tag from Source side as shown in below image 
*Current Element Name : Current  (you can give any meaningful name but make a note of it because you need it later in this integration)
             

STEP 5: 
Now add one Assign inside For Each 


Enter below details & click Create :

*Name : write one meaningful name 
 Description : write some meaningful description


- Advertisement -



Click " + " Select the Existing Variable " vEmail " and then click Edit 


         
***configure the Expression using Concat function and by dragging and   
dropping the required fields form Source as shown in below image and then click Validate 
             
 use this HTML Code in Expression
 style='background-color:#C9CBCA;font-weight: lighter'
         

- Advertisement -


     
STEP 6:  
Now add one assign outside of foreach to close the table


Write one meaningful name and click Create


Click the " + " icon and select the existing variable " vEmail " and click Edit
   


Enter the below details inside Expression box to close the table and click Validate and then Click Close.

      concat($vEmail, "</table>")


- Advertisement -



STEP 7: 
Now the last part, add one Notification as shown in below image


                    
Enter the below details and then click Create :

*Name :write one meaningful name
 Description : write some description


Knowledge :  ๐Ÿ‘€ 
Notification? : You Enables you to send notification email to relevant users at specific points in the execution of an integration.

     
  Now configure the Notification Payload by entering below details :      

           1. Click on " + " icon and give 

ParameterName = body  (will use this in below HTML Body )& then click edit and provide the Parameter Value by dragging and dropping the vEmail variable form Source as shown in below images  



            2. Now enter the below details and click Validate and then click Close:

                       *From : Write from email address
                       *To : write the email address in which you want the Notifiaction

                       *Body : Enter the below HTML code as it is inside Body. This is 
                        a simple HTML code to define Email payload , you can use your  
                        own. 
                        **The important point is that inside the <div> tag ,the 
                        above defined parameter value {body} is added which contains 
                        our dynamic email values.


<html>

<head>
<style>
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
th, td {
  padding: 5px;
  text-align: left;
}

table th {
  background-color:#154668;
  color: white;
}
  p{
  margin : 0;
  padding : 0;
  }
</style>
</head>
<body>
<br>
<br>
<p>Hi There,</p>
<p> Below is the list of Employee details :</p>
<br>
<div>
{body}
</div>
<br>
<p>Thanks,</p>
<p>XYZ</p>
</body>
</html>

 


- Advertisement -


STEP 8:  
Last but not the least , enable the tracking as shown in below image

drag and drop the Name column and then click save.


Knowledge :  ๐Ÿ‘€ 
Assigning Business Identifiers for Tracking Fields ? : Business identifiers enable you to track payload fields in messages during runtime.You must assign business identifiers before you can activate an integration.

               
Done, you have successfully created the dynamic email notification service. Click SAVE and CLOSE the Integration. Please see NEXT blog to TEST this service. Thank You !


- Advertisement -


20 comments:

  1. Replies
    1. Hi Unknown :), I cross checked the blog, everything is fine. You may have did something wrong.Ping your error message then only I can help you better.

      Delete
  2. Thanks Amit for this blog. Truly you implemented a good logic for dynamic email notification.

    ReplyDelete
  3. Nice blog it is very help full to me

    ReplyDelete
  4. Thank you very much for this post, it helped me a lot

    ReplyDelete
  5. can we insert javascript in notification using SCRIPT tag?

    ReplyDelete
    Replies
    1. Yes You can write JavaScript code in OIC Notification Action but it's of no use because 'outlook don't support JavaScript' that's the problem. ๐Ÿ˜

      Delete
  6. May i know tbe use case of the dynamic email notifications

    ReplyDelete
    Replies
    1. The very first line of this Article is 'USE CASE' ๐Ÿ™‚
      but anyway let me explain you in detail - ' suppose you want to send email notification that contain DATA in TABEL FORMAT which ROWS is not FIXED. Sometime it contain 2 rows , in next run it may need 50 rows etc. so table structure needs to be dynamic --- to handle such use case we need we need code OF DYNAMIC EMAIL NOTIFICATION.

      I hope now its clear, if not please let me know. Thanks !

      Delete
  7. Excellent work sir , its really helpful

    ReplyDelete
  8. Very informative. Thanks for your efforts.

    ReplyDelete
    Replies
    1. welcome & thanks for appreciating my work ๐Ÿ™‚

      Delete
  9. This was extremely helpful and very easy to follow. An excellent blog.

    ReplyDelete

If you have any doubts, Please let me know.

Top