The sender will pass the data in JSON format without converting it to XML format. We need to read the particular field to check the condition of the router using the Groovy script.
Input:
{
"Enquiry_Request": {
"Enquiry": {
"Enquiry_Type": "General",
"First_Name": "Christopher",
"Last_Name": "Rath",
"Phone": "9988998877",
"Email": "chris@gmail.com.dummy",
"Note": "Hi, I am looking for the details of the product being launched",
"Language": "EN"
}
}
}
Groovy Scripts:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.*;
def Message processData(Message message) {
def json = message.getBody(java.io.Reader);
def data = new JsonSlurper().parse(json);
message.setProperty("EnquiryType", data.Enquiry_Request.Enquiry.Enquiry_Type);
return message;
}
Implementation Design: