Custom Function To Fetch Product Custom Field From Invoice Product Details Subform
Hello,
I am trying to fetch a custom field from a product and bring it into the corresponding line item in the Product Details subform of an invoice.
The product field which I am after has the API name Set_cost while the custom field in the Product Details subform is Net_Cost. I have looked across various posts on this forum and while many requirements are similar they mostly seem to involve adding a line to the invoice rather than updating a field in an existing one.
The current code which I am working from is below, though there have been many prior iterations and none have worked. Please can you advise?
- recordDetails = zoho.crm.getRecordById("Invoices", IoId);
- subformEntries = recordDetails.get("Product_Details");
- productList = subformEntries.toJSONList();
- statusList = list();
- for each entry in subformEntries
- {
- pSetCost = entry.get("product").get("Set_Cost");
- statusList.add(pSetCost);
- }
- mp = map();
- mp.put("Net_Cost", pSetCost);
- updateMainRecord = zoho.crm.updateRecord("Invoices",IoId, {"Product_Details" : mp});
- info updateMainRecord;
Many thanks