Reputation: 55
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.
Upvotes: 0
Views: 135
Reputation: 6740
two things may help
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).
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());
Upvotes: 1