Adding Event Filter in OIC Business Events based Process

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.

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.

image 45 Event Filter in OIC 1

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.

image 46 Event Filter in OIC 2

The above is the PO event payload received in OIC.

  1. Format the xml payload so that you have the namespaces in a single line and easily identifiable
  2. Track your field (OrderNumber)
  3. Traverse up the xml nodes and note each node till you reach result node.
  4. Here we get Ordernumber > Value > result
  5. 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 Event payload from oracle fusion applications is mostly of a similar structure for any type of Business 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 result node, use the namespace of /(service)/types/
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.

image 47 Event Filter in OIC 3

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

image 48 Event Filter in OIC 4

Have checked with both the filter expression, and it works. Hope this helps in creating an Event Filter in OIC.

Sometimes there are namespace issues, to debug you can check the XPath from OIC mapper of the element of interest and make some intelligent guesses.
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.

OIC MasterClassTraining

Suggested Readings

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?

wpsadmin
1 Comment
  1. Hi,

    Can a value from lookupValue used in the filter?

    Thanks

Leave a reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO
Cloud Technologies Blog
Logo
Compare items
  • Total (0)
Compare
0
Shopping cart