For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

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",NewItems);
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",NewItems)
  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 :: Article: 692

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: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used 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

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

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 - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.