How do I create a relationship between list of suppliers and a single order in Hyperledger Composer

+1 vote

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

transaction OrderPlace 

        o String orderId
        --> Consumer consume
        o OrderDetails details
        --> Supplier[] supply
        --> Commodity com1

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 details
    --> SupplyOrder[] OrderSupply
    --> Trader owner 
    --> Commodity com1
    --> Consumer consume
    --> Supplier[] supplier1
    o Rating rating optional

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

I was trying the code below for a single supplier

order.supplier = factory.newRelationship(namespace, 'Supplier', OrderPlaced.supplier.getIdentifier());
Mar 28, 2018 in Blockchain by Shashank
• 10,330 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+1 vote
Best answer
  1. Is your transaction actually called 'OrderPlaced' (in your code) ?? In your code this order is created when placeOrder transaction is called.

  2. Also, 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());
answered Mar 28, 2018 by Johnathon
• 9,070 points

selected Aug 3, 2018 by Omkar

Related Questions In Blockchain

+4 votes
2 answers

How do I create a new block in Hyperledger Fabric?

This link might help you: ...READ MORE

answered Oct 11, 2018 in Blockchain by Sahu
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 16,450 points
+3 votes
4 answers

How do I add a new node on a Hyperledger network?

You can do this by generating the crypto ...READ MORE

answered Apr 6, 2018 in Blockchain by Christine
• 15,790 points
0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 27,620 points
0 votes
1 answer
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.