0

I have a transaction placeorder which takes list of supplier as input and creates an order.

transaction PlaceOrder 

    {
        o String orderId
        --> Consumer consumer
        o OrderDetails orderDetails
        --> Supplier[] supplier
        --> Commodity commodity
    }

The order is an asset having list of suppliers

asset Order identified by orderId {
    o String orderId
    o String orderName optional
    o OrderState state
    o OrderDetails orderDetails
    --> SupplyOrder[] supplyOrder
    --> Trader owner 
    --> Commodity commodity
    --> Consumer consumer
    --> Supplier[] supplier
    o Rating rating optional
}

This order is created when placeOrder transaction is called and that should create relationship between the list of suppliers.

For a single supplier I was using

order.supplier = factory.newRelationship(namespace, 'Supplier', placedOrder.supplier.getIdentifier());

but the above code is failing for list of suppliers.

Vishal
  • 55
  • 3

1 Answers1

1

two things may help

  1. Is your transaction actually called 'placedOrder' (in your code) when you wrote "This order is created when placeOrder transaction is called " (just to check, it may well be).

  2. because you've defined an array of relationships to Supplier, the `factory' statement should probably be:

     order.supplier = factory.newRelationship(namespace, 'Supplier', placedOrder.supplier[0].getIdentifier());
Paul O'Mahony
  • 6,740
  • 1
  • 10
  • 15
  • Yes the transaction is called placeOrder and placedOrder is the variable in which I get the values from the transaction. I was trying to create a relation between array of Supplier in the order with array of Supplier in the transaction. I changed the array of Suppliers in the order to just Supplier and wrote the piece of code you provided in a loop. It worked for me. Thank you for your help. – Vishal Mar 12 '18 at 14:06