locked
Validate message multiple records in Business Rule RRS feed

  • Question

  • I have Order message as below:

    <Orders>
    <Order>
    <Header>
    <BillToID>001</BillToID>
    <ShipToID>002</ShipToID>
    <Id>Order001</Id>
    </Header>
    <OrderLine>
    <Id>Line001</Id>
    <Date>2015-01-01T00:00:00</Date>
    <Qty>10</Qty>
    <Status></Status>
    </OrderLine>
    <OrderLine>
    <Id>Line002</Id>
    <Date>2015-01-01T00:00:00</Date>
    <Qty>15</Qty>
    <Status></Status>
    </OrderLine>
    </Order>
    <Order>
    <Header>
    <BillToID>002</BillToID>
    <ShipToID>003</ShipToID>
    <Id>Order002</Id>
    </Header>
    <OrderLine>
    <Id>Line003</Id>
    <Date>2015-01-01T00:00:00</Date>
    <Qty>5</Qty>
    <Status></Status>
    </OrderLine>
    <OrderLine>
    <Id>Line004</Id>
    <Date>2015-01-01T00:00:00</Date>
    <Qty>65</Qty>
    <Status></Status>
    </OrderLine>
    </Order
    </Orders>

    I want to use Business rule to check Quantity value and update status for the order line, that if quantity < 10 set the status to Approved, if quantity between 10 to 50 then set status to Pending, if quantity > 50 need to set the status to Reject. The business is simple, if the Order message just have one record, but when the Order message that contain multiple record the business rule just get the first quantity and set the status value. 

    Anyone have any idea to implement with that requirement?

    Thanks in advance!

    Thursday, March 26, 2015 4:34 PM

Answers

  • Yes, it is absolutely possible.

    The explanation is actually pretty simple.  All you have to do is set the Selector to Order, then the Field to each Element relative to the Selector.

    You do have to use a Vocabulary for this to work and you have to be very careful that the Selector paths are identical, byte-by-byte.  That's how you tell the BRE to treat each Order as a separate Artifact.


    Thursday, March 26, 2015 5:55 PM
    Moderator

All replies