Hyperledger Composer Playground error Instance org acme securebox Order 1234 missing required field customer

0 votes

securebox.cto

/**
 * securebox tracking
 */

namespace org.acme.securebox


/**
 * The types of BOX that could be moved
 */
enum BoxType {
  o SecureBox
  o NORMALBOX
  o OTHERS
}

/**
 * Status of an order
 */
enum OrderStatus {
  o ORDER_PLACED
  o IN_FIELD
  o IN_TRANSIT
  o DELIVERED
}

/**
 * The production type associated with a Box
 */
enum ProductionType {
  o SUGAR_MEDICINE
  o BLOODPRESSURE_MEDICINE
  o OTHER
}

/**
 * The Lock status associated with a Box
 */
enum BoxStatusType {
  o LOCK
  o UNLOCK
}

/**
 * A Person participant
 */
abstract participant User identified by email {
  o String email 
  o String firstName
  o String lastName
}

participant Customer identified by custId extends User {
    o String custId
    o String address1 optional
    o String address2 optional
    o String county   optional
}

/**
 * A manufacturer of medicine
 */
participant Manufacturer identified by companyName  {
  o String companyName
}

/**
 * An order for a medicine/others to be fulfilled by a manufacturer
 * and dispatched to an orderer (Person).
 */
asset Order identified by orderId {
  o String orderId
  o ProductionType productiontype
  o OrderStatus orderStatus
  --> Customer customer
  --> Manufacturer manufacturer
}

/**
 * An Medicine asset, which is related to a order
 */
asset Medicine identified by medicineName {
    o String medicineName
    o BoxType box
    o OrderStatus movementStatus
    o ProductionType productionType
    --> Manufacturer owner
}

/**
 * An order for a medicine/others to be fulfilled by a manufacturer
 * and dispatched to an orderer (Person).
 */
asset SecureBox identified by secureBoxId {
  o String secureBoxId
  o BoxStatusType statustype
}

/**
 * Transaction to create an order
 */
transaction PlaceOrder {
  o String orderId
  --> Customer customer
  --> Manufacturer manufacturer
}

event PlaceOrderEvent {
  o String orderId
}

securebox.js
--------------
'use strict';
/**
 *
 * @param {org.acme.securebox.PlaceOrder}  placeOrder - the placeOrder transaction
 * @transaction
 */
function PlaceOrder(placeOrder) {
    console.log('placeOrder');
    var factory = getFactory();
    var NS_M = 'org.acme.securebox';
    var NS   = 'org.acme'; 
    var order = factory.newResource(NS_M, 'Order', placeOrder.orderId);
    order.productiontype = 'SUGAR_MEDICINE';
    order.orderStatus = 'ORDER_PLACED';
    order.manufacturer = placeOrder.manufacturer;

    // save the order
    return getAssetRegistry(order.getFullyQualifiedType())
        .then(function (registry) {
            return registry.add(order);
        })
        .then(function(){
            var placeOrderEvent = factory.newEvent(NS_M, 'PlaceOrderEvent');
            placeOrderEvent.orderId = order.orderId;
            emit(placeOrderEvent);
        });

}

while submit the transaction Getting the error 

# Instance org.acme.securebox.Order#1234 missing required field customer

Can someone tell me the solution?

Nov 2, 2018 in Blockchain by slayer
• 29,350 points
844 views

1 answer to this question.

0 votes

All you have to do is add this line:

order.customer = placeOrder.customer;

Hope this works..

answered Nov 2, 2018 by Omkar
• 69,210 points

Related Questions In Blockchain

0 votes
1 answer

Error: t: Instance org.acme.seller.Car#HW7722 missing required field oldOwner

This error occurs if you have added a ...READ MORE

answered Jun 21, 2018 in Blockchain by Christine
• 15,790 points

edited Jun 21, 2018 by Christine 1,180 views
0 votes
1 answer

How should I set my mac for Installing Hyperledger Composer Playground?

Use the following link to install the ...READ MORE

answered Jun 27, 2018 in Blockchain by Perry
• 17,100 points
328 views
0 votes
1 answer

Error while trying to create dir if missing: mkdir /var/hyperledger: permission denied

The following commands should help: sudo mkdir -p ...READ MORE

answered Jul 6, 2018 in Blockchain by Christine
• 15,790 points
1,553 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,211 views
+1 vote
1 answer

I am unable to change port of composer-rest-server. Please help!

Use full format for running a business ...READ MORE

answered Mar 27, 2018 in Blockchain by Christine
• 15,790 points
947 views
+1 vote
1 answer
0 votes
1 answer

Hyperledger Composer: Error: Object with ID 'assetID:0138' in collection with ID 'Asset:org.acme.mynetwork.Sensor'

Remove 'assetID:' from your test string. For example, 'org.acme.mynetwork#assetID:0138' ...READ MORE

answered Nov 14, 2018 in Blockchain by Omkar
• 69,210 points
742 views
0 votes
1 answer

Hyperledger Composer: Error: Chaincode already installed - Composer-playground

You get this error because composer-playground saves ...READ MORE

answered Nov 12, 2018 in Blockchain by Omkar
• 69,210 points
1,213 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP