In this post, we will see how to add an expression for event filter in OIC app-driven orchestration processes. The event filter expression helps to filter the payload coming to OIC from fusion. the filtered payload will be smaller and faster to process and reduce load.
Table of Contents
Business Events Filter Expression in OIC
Business events are a feature in oracle fusion applications that can be subscribed to fetch some payload related to a certain type of transaction. For e.g If a purchase order is created and an internal event will be raised with data of that PO. This event can be subscribed by Oracle integration cloud.
Once you have the PO data in OIC you can do further processing.
The use case
Suppose You need to Subscribe only to PO’s of a certain Vendor and do some processing, For that you can subscribe to the PO Event and add an event filter expression to fetch the payload for only that vendor.
Another example If you want to Process only PO Number’s starting with ‘xx……’ you can add event filter for that expression.
So let’s do for PO’s starting with ‘US’ as an example.
When you create an app-driven orchestration you have a filter criteria box where you can add your expressions.
The challenge is how to create that expression.
The logic: Filter expressions start from the result node and use the XPath for the element you want to check for the condition.
The above is the PO event payload received in OIC.
- Format the xml payload so that you have the namespaces in a single line and easily identifiable
- Track your field (OrderNumber)
- Traverse up the xml nodes and note each node till you reach result node.
- Here we get Ordernumber > Value > result
- Now get the namespaces for each node from ns0 to ns2
xmlns:ns0=”http://xmlns.oracle.com/apps/prc/po/editDocument/purchaseOrderServiceV2/”
xmlns:ns1=”http://xmlns.oracle.com/adf/svc/types/”
xmlns:ns2=”http://xmlns.oracle.com/apps/prc/po/editDocument/purchaseOrderServiceV2/types/”
The event payload is contained in variable $eventPayload
so the xpath of the element OrderNumber becomes $eventPayload/ns2:result/ns0:Value/ns0:OrderNumber
Enclose the namespace and xpath expression withing the xpathExpr tag. So the final expression is
Add a string expression to filter PO’s like US only
starts-with($eventPayload/ns2:result/ns0:Value/ns0:OrderNumber, “US”)= true
There is a certain type of relation with how the OIC adapter treats the Fusion Event Payload for any transaction.
The Xpath expression Filter
With the above namespace logic you get the below filter expression.
<xpathExpr
xmlns:ns0="http://xmlns.oracle.com/apps/prc/po/editDocument/purchaseOrderServiceV2/"
xmlns:ns1="http://xmlns.oracle.com/adf/svc/types/"
xmlns:ns2="http://xmlns.oracle.com/apps/prc/po/editDocument/purchaseOrderServiceV2/types/">
starts-with($eventPayload/ns2:result/ns0:Value/ns0:OrderNumber, "US")= true
</xpathExpr>
Identifying the namespaces correctly
If the filter doesn’t work you will need to analyze the namespaces with pattern logic as below.
XPath Filter expression not working?
If the xpath filter expression are not filtering use the below mapping for namespaces
The Second Method
For Value node, use the namespace of /svc/types/
For the XML tag element for which condition has to be checked, use the /(service)/ namespace.
With this logic you get the xpath for the OrderNumber as /ns2:result/ns1:Value/ns0:OrderNumber
Note ns1 namespace for Value instead of ns0 from previous logic.
The string filter becomes
starts-with($eventPayload/ns2:result/ns1:Value/ns0:OrderNumber, “US”)= true
Xpath Filter Expression with mapping Logic
So below is the xpath filter expression with the second method of mapping logic
<xpathExpr
xmlns:ns0="http://xmlns.oracle.com/apps/prc/po/editDocument/purchaseOrderServiceV2/"
xmlns:ns1="http://xmlns.oracle.com/adf/svc/types/"
xmlns:ns2="http://xmlns.oracle.com/apps/prc/po/editDocument/purchaseOrderServiceV2/types/">
starts-with($eventPayload/ns2:result/ns1:Value/ns0:OrderNumber, "US")= true
</xpathExpr>
Once applied successfully the event filter can be seen in the subscription url
https://(yourdomain).com/soa-infra/PublicEvent/subscriptions
Have checked with both the filter expression, and it works. Hope this helps in creating an Event Filter in OIC.
for e.g Xpath of PoLine id is
/nssrcmpr:onEvent/inp1:getPurchaseOrderResponse/inp1:result/ns28:Value/ns28:PurchaseOrderLine/ns28:LineFlexfield/ns27:PoLineId
so namespace of Value, PurchaseOrderLine and LineFlexfield would be same.
Suggested Readings
- Adding Wait in App driven process in OIC
- more OIC articles
- Creating App driven orchestrations Oracle doc
FAQs
What is the difference between a filter expression inside the process and a filter expression at the Event Level?
With the Event filter your OIC process will not trigger at all if the filter criteria is satisfied, Saving resources and having more control.
Where can I see the event filter is applied or not?
Check the subscriptions url
https://(yourdomain).com/soa-infra/PublicEvent/subscriptions
Hi,
Can a value from lookupValue used in the filter?
Thanks