About Order Item Inter-Order Dependency XQuery Expressions

This topic describes how to use the Order Item Specification editor, Order Item Dependency tab, Order Item Selector area, XQuery tab to write an expression that creates dependencies between the order items on the follow-on order and the order items on the base order. It is the follow-on order that generates this dependency on the base order.

  • Context: The Order Item Selector XQuery input document is typically an order item on a follow-on order (the waiting order).

  • Prolog: You can declare the OSM namespace, the cartridge namespace for the target order (the base order), and the namespace of the query task that contains the order data you want to view. For example:

    declare namespace osm="http://xmlns.oracle.com/communications/ordermanagement/model";
    declare namespace im="CommunicationsSalesOrderFulfillmentPIP";
    declare namespace osmc="urn:oracle:names:ordermanagement:cartridge: CommunicationsSalesOrderFulfillmentPIP:1.0.0:view:CommunicationsSalesOrderQueryTask";
    
  • Body: The CRM that sends the follow-on order must specify the reference number that uniquely identifies the base order and also the order item line ID of the blocking order item. You can define a variable (such as $dependingLineId) that extracts the dependent line ID from the order item context. For example:

    let $dependingLineId := fn:normalize-space(osm:properties/im:DependingSalesOrderBaseLineId)
    

    You can configure a web service data instance provider that runs a FindOrder web service that searches for orders based on the reference value (osm:properties/prop:Ref/text())) in the follow-on order that generates a FindOrder response that includes the order ID of the base order. See OSM Developer's Guide for more information about configuring web service data instance providers. For example:

    <ord:FindOrder xmlns:ord="http://xmlns.oracle.com/communications/ordermanagement"
       xmlns:osm="http://xmlns.oracle.com/communications/ordermanagement/model"
       xmlns:prop="http://oracle.communications.ordermanagement.unsup.centralom">
       <ord:ViewBy>
          <ord:AmendmentFilter>
             <ord:LevelOfDetail>AmendmentsSummary</ord:LevelOfDetail>
          </ord:AmendmentFilter>
          <ord:LifecycleEventFilter>
             <ord:RetrieveLifecycleEvents>false</ord:RetrieveLifecycleEvents>
          </ord:LifecycleEventFilter>
       </ord:ViewBy>
       <ord:SelectBy>
          <ord:Reference>{fn:normalize-space(osm:properties/prop:Ref/text())} </ord:Reference>
       </ord:SelectBy>
    </ord:FindOrder>
    

    This data instance provider returns the order ID of the base order which you can capture in an XQuery variable (such as $parentOrderID). You can use this variable in a data instance provider that runs a GetOrder web service to obtain the order item details from the base order. For example, the following XQuery populates the GetOrder request message using the results from the "findOrder" data instance provider to provide the value for the order ID of the base order in the Order ID field:

    <ord:GetOrder xmlns:ord="http://xmlns.oracle.com/communications/ordermanagement"
        xmlns:osm="http://xmlns.oracle.com/communications/ordermanagement/model">
    	<ord:OrderId>{vf:instance("findOrder")/ord:Order[last()]/ord:Amendments/ord:AmendedOrderSummary/ord:Id/text()}</ord:OrderId> <ord:View>CommunicationsSalesOrderQueryTask</ord:View>
    </ord:GetOrder>
    

    This data instance provider returns all order item instances in the base order that you can then search through to find the blocking order item using the $dependingLineId variable. You can capture the results in an XQuery variable (such as $parentOrderItemId). For example:

    let $parentOrderItemId :=fn:normalize-space(vf:instance("getOrder") /ord:Data/osmc:_root/osmc:ControlData/osmc:OrderItem [osmc:BaseLineId=$dependingLineId]/@index)
    

    The XQuery body returns the order ID of the base order and the order item property that specifies the blocking order item on the base order:

     <osm:dependency fromOrderId="{$parentOrderId}" fromOrderItemId="{$parentOrderItemId}"/>
    

    where

    • <osm:dependency fromOrderId: Returns the base order ID.

    • fromOrderItemId: Returns the blocking order item property value that controls the dependency. OSM internally monitors the blocking order item until it is no longer being processed by any order component on the base order.

The following example shows an XQuery for an inter-order dependency.

declare namespace ord="http://xmlns.oracle.com/communications/ordermanagement";
declare namespace im="CommunicationsSalesOrderFulfillmentPIP";
declare namespace osmc="urn:oracle:names:ordermanagement:cartridge: CommunicationsSalesOrderFulfillmentPIP:1.0.0:view:CommunicationsSalesOrderQueryTask";
let $dependingLineId := fn:normalize-space(osm:properties /im:DependingSalesOrderBaseLineId)
return
   if(fn:not($dependingLineId = ''))
   then
(: Use the data instance behavior "findOrder" to find the base order:   :)
      let $parentOrderId := fn:normalize-space(vf:instance("findOrder")/ord:Order[last()]/ord:Amendments/ord:AmendedOrderSummary/ord:Id/text())
(: Use the data instance behavior "getOrder" to find the associated order item ID in the base order: :)
      let $parentOrderItemId :=
         fn:normalize-space(vf:instance("getOrder")/ord:Data/
         osmc:_root/osmc:ControlData/osmc:OrderItem[osmc:BaseLineId=$dependingLineId]/@index)
      return
         if(fn:not($parentOrderId = '') and fn:not($parentOrderItemId = ''))
      then
(: Return the dependency: :)
      <osm:dependency fromOrderId="{$parentOrderId}" fromOrderItemId="{$parentOrderItemId}"/>
      else()
   else()