---
title: Update
slug: quickbooks/Lowf-update
description: Learn how to update a credit memo in QuickBooks using API requests. This document provides a step-by-step example with code snippets to create a map, sync token, customer reference, and line items. Discover how to make a request to the Breadwinner Global 
docTags: 
createdAt: 2021-12-31T06:38:46.000Z
---

The following is an example of update Credit Memo. The QuickBooks Credit Memo Id (id) is required to update the Credit Memo(See [Credit Memo](docId\:X6Nlsr2VQhr25341RoqD0) for the available fields)

The request body must include all writable fields of the Credit Memo object. Writable fields omitted from the request body are set to NULL.&#x20;

:::hint{type="info"}
Note:  You can only update one record at a time.

- When you want to update specific fields of an entity without affecting others, use a sparse update operation by setting sparse= 'true' in your request. This approach is more efficient and less prone to unintended changes than a full update.
:::

:::CodeblockTabs
Request

```apex
//  Create a Map to store all the data of a Credit Memo
List<Object> creditMemoList = new List<Object>();
Map<String, Object> creditMemoMap = new Map<String, Object>();
    creditMemoMap.put('Id', '13');
	creditMemoMap.put('SyncToken','2');
	creditMemoMap.put('CustomerRef',new Map<String, Object>{'value' => '9'});

    //  Initializing the Invoice Line Items
    List<Object> lineItemList = new List<Object>();
        Map<String, Object> lineItemMap = new Map<String, Object>();
		lineItemMap.put('LineNum',1);
        lineItemMap.put('Amount',100);
        lineItemMap.put('Description','Description Updated');
		lineItemMap.put('DetailType', 'SalesItemLineDetail');
		Map<String, Object> salesLineItemDetailMap = new Map<String, Object>();
            salesLineItemDetailMap.put('Qty',2);
            salesLineItemDetailMap.put('UnitPrice',50);
			salesLineItemDetailMap.put('TaxCodeRef' , new Map<String, Object>{'value' => 'TAX'});
        
        lineItemMap.put('SalesItemLineDetail', salesLineItemDetailMap);
        lineItemList.add(lineItemMap);

    //  Adding the Line Items to Invoice
    creditMemoMap.put('Line',lineItemList);
    creditMemoList.add(creditMemoMap);

//  Initializing the RequestJSON Data to be passed.
    Map<String, Object> reqJSONMap = new Map<String, Object>(); 
    reqJSONMap.put('creditmemos' , creditMemoList); 
    String reqJSON = JSON.serialize(reqJSONMap); 

    Map<String, Object> finalReqMap = new Map<String, Object>(); 
    Map<String, Object> reqOptions = new Map<String, Object>(); 
    finalReqMap.put('options' , reqOptions); 
    finalReqMap.put('version' , '1.0'); 
    finalReqMap.put('action' , 'updateCreditMemo'); 
    finalReqMap.put('RequestJSON' , reqJSON); 
    finalReqMap.put('skipDML' , false);
    //Required, if QuickBooks Multi-Org is enabled in Breadwinner. 
    finalReqMap.put('qbOrgId', '4620816365285051610'); 
    System.debug('Request ::: ' + finalReqMap);

//  Placing a request to Breadwinner Global API
    Map<String, Object> respMap = breadwinner_qbo.BreadwinnerQBAPI.call(finalReqMap);
    System.debug('Response ::: ' + respMap);
```

Response

```json
{
  action=updateCreditMemo,
  responseJSON={
    "statusCode": 200,
    "creditMemos": [
      {
        "TxnTaxDetail": {
          "TotalTax": 0
        },
        "TxnDate": "2021-12-31",
        "TotalAmt": 100.00,
        "SyncToken": "2",
        "sparse": false,
        "ShipAddr": {
          "PostalCode": "94482",
          "Longitude": "-122.0642815",
          "Line1": "370 Easy St.",
          "Lat": "37.4031672",
          "Id": "9",
          "CountrySubDivisionCode": "CA",
          "City": "Middlefield"
        },
        "SFRecordID": "a0A5j000000vDppEAE",
        "salesforceRecordId": "a0A5j000000vDppEAE",
        "RemainingCredit": 100.00,
        "MetaData": {
          "LastUpdatedTime": "2021-12-31T02:46:20-08:00",
          "CreateTime": "2021-12-31T02:35:26-08:00"
        },
        "Line": [
          {
            "SalesItemLineDetail": {
              "UnitPrice": 50,
              "TaxCodeRef": {
                "value": "TAX"
              },
              "Qty": 2,
              "ItemRef": {
                "value": "1",
                "name": "Services"
              }
            },
            "LineNum": 1,
            "Id": "3",
            "DetailType": "SalesItemLineDetail",
            "Description": "Description Updated",
            "Amount": 100.00
          },
          {
            "DetailType": "SubTotalLineDetail",
            "Amount": 100.00
          }
        ],
        "Id": "187",
        "EmailStatus": "NotSet",
        "DocNumber": "1201",
        "CustomField": [
          {
            "Type": "StringType",
            "Name": "Crew #",
            "DefinitionId": "1"
          },
          {
            "Type": "StringType",
            "Name": "Test 2",
            "DefinitionId": "2"
          },
          {
            "Type": "StringType",
            "DefinitionId": "3"
          }
        ],
        "CustomerRef": {
          "value": "9",
          "name": "55 Twin Lane"
        },
        "CurrencyRef": {
          "value": "USD",
          "name": "United States Dollar"
        },
        "BillAddr": {
          "PostalCode": "94482",
          "Longitude": "-122.0642815",
          "Line1": "370 Easy St.",
          "Lat": "37.4031672",
          "Id": "9",
          "CountrySubDivisionCode": "CA",
          "City": "Middlefield"
        },
        "Balance": 100.00
      }
    ]
  },
  timestamp=1640947582773,
  validRequest=true,
  version=1.0
}
```
:::

