Policy Automation for B2C Service

Get Involved. Join the Conversation.


    Scott Heidenreich
    Quickest way to copy a complete instance from one entity to...
    Topic posted April 18, 2018 by Scott HeidenreichBronze Trophy: 5,000+ Points 
    143 Views, 7 Comments
    Quickest way to copy a complete instance from one entity to another?


    What is the quickest way to copy a complete instance from one entity to another?  This is needed, for example, if an entity is used to provide a list to a customer and the customer picks only 3 out of 10 items in the entity.  Only the 3 items need to be submitted to Oracle Service Cloud, so to make sure only the three selected instances are sent to Oracle Service Cloud, they have to be copied to another identical entity that is mapped to OSvC.

    Is there a way to copy all the attributes at once from one entity to another rather than inferring a number of blank instances in the second entity and then copying each attribute one at a time using the InstanceValueIf function?

    Thank you.




    • Jasmine Lee
    • Scott Heidenreich

      I attempted to use those instructions to do this, but was unsuccessful - mostly I think because I only have to get the order part copied, not the order line item part and I was having a hard time figuring out how to simplify that example.  I'll try following it again and see if I can figure it out.


    • Scott Heidenreich

      I recreated the example you suggested verbatim in OPM and it throws an error - OPA-000678 Inferred relationship must be a relationship from the updated order.  and another for the update order line item.  If I reverse the relationship, then it hits me for an error of wrong direction.  So, I'm either missing something, or the example in the documentation does not work.​  If that is the case, then no wonder my struggle! I attached the model that replicates the instructions that you linked.  

      What am I doing wrong?

    • Fiona Guy

      You had some extra relationships and some relationship text reversed. 

      I opened your project side by side with the example policy model mentioned in the doco (retail discounts), corrected your relationships to match and it worked (attached).



    • Scott Heidenreich

      Thank you.  I now see where my confusion is.  The diagram is not consistent with how OPA sets up relationships.  It looked to me, like "the line item's order" (based on the diagram) was supposed to be on the order's side of the relationship, and "the order line items" (based on the diagram) was supposed to be on the order line item side of the relationship in OPA. Please see attached.

      So, if I understand correctly, in the diagrams, then, the relationship name always goes on the side opposite of the entity named in the relationship, even if it is shown in the diagram under or over the opposite entity?

      The form in OPA should always be:

      • Relationship: B's A
      • From: A
      • to many instances of: B
      • Reverse relationship: A's B
    • Scott Heidenreich

      In this example, all it is doing is structuring the updated order and updated order line item instances but it isn't transferring any values from the orders to the update orders or the line items to the updated line items.

      My original question was how to copy all the matching attributes from one to another instances.  Is there no way to do this, but one attribute at a time with the instanceValue or InstanceValueIf function?

      If a person orders the same item, but one is blue and one is red, for example model #123, how does OPA keep the two different instances separated? For example:

      Instance 1:

      • The order line item = Model 123
      • the order line item color = red

      Instance 2:

      • the order line item = model 123
      • the order line item color = blue


    • Fiona Guy

      HI Scott

      Typically to refer to a subset of entities you would use a relationship, not copy across the data into a new entity, but I understand that's not feasible here.

      OPA requires a unique identifier to create entities in rules so you either need to (1) load in the record ID with the line item data, and create the entity from the unique ID for the line items you want to copy or (2) concatenate data in OPA and create line items from each unique concatenation.

      Then yes copy the value of each attribute into a new attribute in the new entity, either through the functions you're familiar with or by extracting the data from the concatenated string itself (which can be more efficient, but perhaps not the prettiest option).

      If you don't like any of these options you could possibly use a RuleScript to do the duplication but you lose some transparency and maintainability with this. 

      We will fix up the documentation - thanks for the feedback.