The scenario which I faced:
I want to filter the employees whose EmployeeId or personIdExternal is an integer. I want to filter while retrieving in the connector itself. I don’t want any of the employees who have their Id alphanumeric(for example test234,12testone etc.). Assume that you want only those employees who have only phone information or email information or address information. After pulling all the employees from the respective connectors who have only phone or email or address information, Out of all the retrieved employees, I want only the employees whose id is an integer. We can do this in numerous ways I believe. But here I am implementing this through the script and using the current Data facility provided by Boomi.
How I did it:
First of all my heartful thanks to all SAP Blog Posts. I have been learning a lot by these posts.Okay, coming to the point.
I thought of using the filter mechanism provided my Boomi Operation Component. But when I tried to use that I found the filter mechanism solely wouldn’t help me in achieving this. But ultimately I make use of the filter mechanism, but before using the filter technique I make use of the groovy script in achieving the desired employees to be picked. Later I have used those employees who are already filtered out by the groovy script and uses those employees as the parameter value to the filter applied. The filter applied was “EmpJob/userId in (filtered employees that came from the script)“.
Below are the screenshots in achieving the scenario:
The actual process:
Detailed Explanation:
First of all, I started with a No Data shape(A dummy start point for my process). Then I used one branch with 2 paths.
In the 1st path:
I retrieved all the employees who are having email information in the SF System, without applying any filters. Then I used one Groovy Script.
In the Groovy script:
Here I manipulated the data in such a way that I need only the employee Ids that are Integers and they are of the length less than or equal to 9 digits. Then after the script I have stored the filtered employees from the script in the Dynamic process Property “Filtered_Employees“. The value of this property is the current Data from the drop down of the Type.Then I stopped the path one.
Groovy Script:
import java.util.Properties;
import java.io.InputStream;
import org.jaxen.XPath
import org.jaxen.jdom.JDOMXPath
import org.jdom.Document
import org.jdom.Element
import org.jdom.input.SAXBuilder
import org.jdom.output.XMLOutputter
List list = []
int found = 0
for( int i = 0; i < dataContext.getDataCount(); i++ ) {
InputStream is = dataContext.getStream(i);
Properties props = dataContext.getProperties(i);
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(is);
Element root = doc.getRootElement()
def userId = root.getChild(“personIdExternal”).getText()
if(userId.isInteger() && (userId.length()<=9))
{
found = 1
if(i==0)
{
if(!list.contains(userId)) list.add(userId)
}
else
{
if(!list.contains(userId)) list.add(userId)
}
}
}
def userId_IN = new StringBuffer()
for(String key : list){
userId_IN.append(key).append(“,”)
}
InputStream os = new ByteArrayInputStream(userId_IN.toString().getBytes(“UTF-8”));
java.util.Properties newProps = new Properties()
dataContext.storeStream(os, newProps);
Setting Current Data as value for the Dynamic Process Property:
The first paths output data is:
In the 2nd Path:
Here I want to extract only those employees that came out from the 1st path. So, I used EmpJob entity from the OData APIs available in the SF EC Module. I configured the respective SF connection and Operation components required. While configuring the operation component I kade use of the filter functionality provided by Boomi.
The configuration of Operation Component’s Filter Functionality:
It is the test mode I am running the integration, So I used the Max rows: 100. We can set this as Max rows: -1 for all the employees while deploying to the cloud atom. For the time being, I only used 100. The above picture demonstrates the usage of the filter in the current process.
Giving Parameter value to the Filter Applied:
The below screenshots demonstrates the configuration of the parameter value to the filter applied. Place the mouse pointer on the connector. Click configure. Go to parameters. Click the plus(+) symbol.
Select the filter which was configured in the operation component from the Input. Then select the Dynamic Process Property from the drop down of the Type. Finally, enter the name of the Dynamic Process property(Filtered_Employees) in the Property Name. Give default employee ids if your process didn’t pick any id’s. In my case, I am leaving this as blank.Click OK.
Now Filter configuration and the parameter values were all set. Now I converted the data that was coming in the XML format to the JSON Format. Then I combined all the documents processed and that’s it, The Process was completed. I was able to get the desired results of having only the employee ids those were Integers and less than or equal to 9 digits.
Final Output: