Link

Update Estimate

Sample Requests and Responses

The following is an example request which can be used while using ‘updateEstimate’ action.

Request

//  Create a Map to store all the data of an Estimate
Map<String, Object> nsEstimate = new Map<String, Object>();
    nsEstimate.put('internalId', '38310');
    nsEstimate.put('entityStatus', new Map<String,Object>{'internalId'=>'11'});
    nsEstimate.put('expectedCloseDate', DateTime.newInstance(2020, 10, 31).getTime()/1000);

//  Initializing the Estimate Line Items
List<Object> lineItemList = new List<Object>();
Map<String, Object> lineItem = new Map<String, Object>();
    lineItem.put('line', 1); // updates the existing line item with line number as 1.
    lineItem.put('quantity', 2);
    lineItemList.add(lineItem);
    
//  Adding Another Line Item
    lineItem = new Map<String, Object>();
    lineItem.put('item', new Map<String, Object>{'internalId'=>'444'});
    lineItem.put('quantity', 4);
    lineItem.put('price', new Map<String, Object>{'internalId'=>'2'});
    lineItemList.add(lineItem);

//  Adding the Line Items to Estimate
Map<String, Object> estimateLineitemList = new Map<String, Object>();
    estimateLineitemList.put('item', lineItemList);
    estimateLineitemList.put('replaceAll', false); // setting this as false, would create a new, or update, the line items passed in the Request based on the Line Number.

    nsEstimate.put('itemList',estimateLineitemList);

//  Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
    requestJSONMap.put('estimates', new List<Object>{nsEstimate});
    String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
    reqObj.put('version','1.0');
    reqObj.put('action','updateEstimate');
    reqObj.put('requestJSON',reqJSON);

//  Placing a request to Breadwinner Global API
Map<String,Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);

Response

{
	action=updateEstimate,
	timestamp=1599493152274, 
	validRequest=true, 
	version=1.0, 
	responseJSON={
	  "errors": [],
	  "status": "200",
	  "estimates": [
	    {
	      "tranId": "98",
	      "tranDate": 1599417000,
	      "total": 2019,
	      "title": "SF Estimate",
	      "taxTotal": 0,
	      "subTotal": 2034,
	      "subsidiary": {
	        "type": null,
	        "name": "Parent Company",
	        "internalId": "1",
	        "externalId": null
	      },
	      "status": "Open",
	      "shippingCost": null,
	      "salesRep": null,
	      "salesforceID": "a042v00002e7WeKAAU",
	      "probability": 75,
	      "otherRefNum": "4343399",
	      "nullFieldList": null,
	      "memo": "Database order 25",
	      "lastModifiedDate": 1599493149,
	      "itemList": {
	        "item": [
	          {
	            "taxRate1": 0,
	            "taxCode": {
	              "type": null,
	              "name": "VAT_IN:UNDEF-IN",
	              "internalId": "5",
	              "externalId": null
	            },
	            "tax1Amt": 0,
	            "revRecStartDate": null,
	            "revRecSchedule": null,
	            "revRecEndDate": null,
	            "rate": "999.00",
	            "quantity": 2,
	            "price": {
	              "type": null,
	              "name": null,
	              "internalId": "-1",
	              "externalId": null
	            },
	            "location": null,
	            "line": 1,
	            "item": {
	              "type": null,
	              "name": "Bow",
	              "internalId": "239",
	              "externalId": null
	            },
	            "grossAmt": 1998,
	            "description": "A weapon for shooting arrows",
	            "department": null,
	            "customFieldList": {
	              "customField": [
	                {
	                  "valueLookup": null,
	                  "value": "false",
	                  "scriptId": "custcol_checkbox",
	                  "internalId": "443",
	                  "fieldType": null
	                }
	              ]
	            },
	            "classification": null,
	            "amount": 1998
	          },
	          {
	            "taxRate1": 0,
	            "taxCode": {
	              "type": null,
	              "name": "VAT_IN:UNDEF-IN",
	              "internalId": "5",
	              "externalId": null
	            },
	            "tax1Amt": 0,
	            "revRecStartDate": null,
	            "revRecSchedule": null,
	            "revRecEndDate": null,
	            "rate": "9.00",
	            "quantity": 4,
	            "price": {
	              "type": null,
	              "name": "Alternate Price 1",
	              "internalId": "2",
	              "externalId": null
	            },
	            "location": null,
	            "line": 4,
	            "item": {
	              "type": null,
	              "name": "Apple",
	              "internalId": "444",
	              "externalId": null
	            },
	            "grossAmt": 36,
	            "description": null,
	            "department": null,
	            "customFieldList": {
	              "customField": [
	                {
	                  "valueLookup": null,
	                  "value": "false",
	                  "scriptId": "custcol_checkbox",
	                  "internalId": "443",
	                  "fieldType": null
	                }
	              ]
	            },
	            "classification": null,
	            "amount": 36
	          }
	        ]
	      },
	      "internalId": "38310",
	      "handlingCost": null,
	      "externalId": "SFId: a012w00000Oyssh",
	      "expectedCloseDate": 1604082600,
	      "exchangeRate": 1,
	      "entityStatus": {
	        "type": null,
	        "name": "In Negotiation",
	        "internalId": "11",
	        "externalId": null
	      },
	      "entity": {
	        "type": null,
	        "name": "21 Atherton Grocery",
	        "internalId": "362",
	        "externalId": null
	      },
	      "dueDate": 1609353000,
	      "discountTotal": -15,
	      "discountRate": "-15.00",
	      "discountItem": {
	        "type": null,
	        "name": "Partner Discount",
	        "internalId": "-6",
	        "externalId": null
	      },
	      "department": {
	        "type": null,
	        "name": "Sales",
	        "internalId": "2",
	        "externalId": null
	      },
	      "customForm": {
	        "type": null,
	        "name": "Custom Estimate 2",
	        "internalId": "124",
	        "externalId": null
	      },
	      "customFieldList": {
	        "customField": [
	          {
	            "valueLookup": {
	              "type": null,
	              "name": "B",
	              "internalId": "2",
	              "externalId": null
	            },
	            "value": null,
	            "scriptId": "custbody_customlist",
	            "internalId": "458",
	            "fieldType": null
	          },
	          {
	            "valueLookup": null,
	            "value": "false",
	            "scriptId": "custbody_checkbox",
	            "internalId": "272",
	            "fieldType": null
	          }
	        ]
	      },
	      "currencyRecord": null,
	      "currencyName": "US Dollars",
	      "createdDate": 1599492192,
	      "classification": {
	        "type": null,
	        "name": "Corporate Sales",
	        "internalId": "5",
	        "externalId": null
	      }
	    }
	  ]
	}
}