For Zoho services only


I'm currently part of a wider delivery team at Ascent Business Solutions, recognised as a leading Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions support organisations with everything from targeted technical fixes through to full Zoho CRM implementations and long-term platform adoption. Working as a team rather than a one-person consultancy allows projects to move forward consistently, with access to the right skills at each stage.

The team I manage specialises in API integrations between Zoho and third-party finance and commerce platforms such as Xero, Shopify, WooCommerce, and eBay. Much of our work involves solving integration challenges that fall outside standard documentation, supporting new ideas, new sectors, and evolving business models.

Success is measured through practical outcomes and return on investment, ranging from scaling small operations into high-turnover businesses to delivering rapid gains through online payments, automation, and streamlined digital workflows.

If you are looking for structured Zoho expertise backed by an established consultancy, you can contact Ascent Business Solutions on 0121 392 8140 (UK), email info@ascentbusiness.co.uk, or visit https://www.ascentbusiness.co.uk.

Zoho Deluge - Modify the product line items in an invoice module

What?
This is a reminder on how to swap out a product in an invoice.

Why?
A client wanted one of their products to be swapped out with another as they had a 3rd-party feed that kept creating a product that they didn't stock.

How?
So editing the product_details field of an invoice record seems straightforward but it isn't. Undocumented, the trick is to remove the existing ID of the line item and posting the map back to the record. In the following example, we are swapping out the product "123456789012345678" with the product "987654321098765432" and p_InvoiceID is the ID of the invoice record:
copyraw
v_Index = 0;
m_Update = Map();
l_ProductItems = List();
r_InvoiceDetails = Map();
r_InvoiceDetails = zoho.crm.getRecordById("Invoices",p_InvoiceID);
for each  r_ProductLineItem in r_InvoiceDetails.get("Product_Details")
{
    m_NewProduct = Map();
    m_NewProduct = r_ProductLineItem;
    if(r_ProductLineItem.get("product").get("id") == "123456789012345678")
    {
        m_NewProduct.remove("product");
        m_NewProduct.remove("id");
        m_NewProduct.remove("product_description");
        m_Mini = Map();
        m_Mini.put("id","987654321098765432");
        m_NewProduct.put("product",m_Mini);
    }
    l_ProductItems.add(m_NewProduct);
}
m_Update = Map();
m_Update.put("Product_Details",l_ProductItems);
r_Update = zoho.crm.updateRecord("Invoices",p_InvoiceID,m_Update);
  1.  v_Index = 0
  2.  m_Update = Map()
  3.  l_ProductItems = List()
  4.  r_InvoiceDetails = Map()
  5.  r_InvoiceDetails = zoho.crm.getRecordById("Invoices",p_InvoiceID)
  6.  for each  r_ProductLineItem in r_InvoiceDetails.get("Product_Details") 
  7.  { 
  8.      m_NewProduct = Map()
  9.      m_NewProduct = r_ProductLineItem; 
  10.      if(r_ProductLineItem.get("product").get("id") == "123456789012345678") 
  11.      { 
  12.          m_NewProduct.remove("product")
  13.          m_NewProduct.remove("id")
  14.          m_NewProduct.remove("product_description")
  15.          m_Mini = Map()
  16.          m_Mini.put("id","987654321098765432")
  17.          m_NewProduct.put("product",m_Mini)
  18.      } 
  19.      l_ProductItems.add(m_NewProduct)
  20.  } 
  21.  m_Update = Map()
  22.  m_Update.put("Product_Details",l_ProductItems)
  23.  r_Update = zoho.crm.updateRecord("Invoices",p_InvoiceID,m_Update)

Additional Note(s):
Just a list of fields to build up a Product Line Item:
copyraw
"Product_Details": [
    {
        "product": {
            "Product_Code": null,
            "Currency": "USD",
            "name": "Test Product",
            "id": "1642130000000104087"
        },
        "quantity": 1,
        "Discount": 0,
        "total_after_discount": 0,
        "net_total": 0,
        "book": null,
        "Tax": 0,
        "list_price": 0,
        "unit_price": 0,
        "quantity_in_stock": 0,
        "total": 0,
        "id": "1642130000047106029",
        "product_description": null,
        "line_tax": []
    }
],
  1.  "Product_Details": [ 
  2.      { 
  3.          "product": { 
  4.              "Product_Code": null, 
  5.              "Currency": "USD", 
  6.              "name": "Test Product", 
  7.              "id": "1642130000000104087" 
  8.          }, 
  9.          "quantity": 1, 
  10.          "Discount": 0, 
  11.          "total_after_discount": 0, 
  12.          "net_total": 0, 
  13.          "book": null, 
  14.          "Tax": 0, 
  15.          "list_price": 0, 
  16.          "unit_price": 0, 
  17.          "quantity_in_stock": 0, 
  18.          "total": 0, 
  19.          "id": "1642130000047106029", 
  20.          "product_description": null, 
  21.          "line_tax": [] 
  22.      } 
  23.  ], 
Category: Zoho Deluge :: Article: 245

Joes Word Cloud

Accreditation

Badge - Zoho Creator Certified Developer Associate
Badge - Zoho Deluge Certified Developer
Badge - Certified Zoho CRM Developer

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com