Retrieving details from product details from Zoho CRM order

Retrieving details from product details from Zoho CRM order

Hello everyone,

In the application I am building on Zoho Creator, I need to retrieve product details from the Sales Orders which are in Zoho CRM.

  1. // Get the Sales Orders from Zoho CRM
  2. salesOrders = zoho.crm.searchRecords("SalesOrders", "(Status|=|Asignado)");
  3. // Add the Sales Orders records in the Orders table
  4. for each saleOrderDet in salesOrders
  5. {
  6.     // DEBUG info "Order: " + saleOrderDet.get("SO Number"); // DEBUG
  7. // Get the Products from every Sale Order record
  8. productOrders = saleOrderDet.get("product").toJSONList();
  9. for each productOrdersDet in productOrders
  10.     {
  11.         productOrdersDetList = productOrdersDet.toList();
  12. productIDDet = productOrdersDetList.get(9).subString(14,32);
  13. productNameDet = productOrdersDetList.get(0).subString(17,(productOrdersDetList.get(0).length()-1));
  14. productQuantityDet = productOrdersDetList.get(1).subString(12,(productOrdersDetList.get(1).length()-1));
  15. productListPriceDet = productOrdersDetList.get(2).subString(14,(productOrdersDetList.get(2).length()-1));
  16. productTaxDet = productOrdersDetList.get(6).subString(7,(productOrdersDetList.get(6).length()-1));
  17. productDiscountDet = productOrdersDetList.get(8).subString(12,(productOrdersDetList.get(8).length()-1));
  18. productNetTotalDet = productOrdersDetList.get(7).subString(13,(productOrdersDetList.get(7).length()-1));
  19. // Add the Products in the Productos table
  20. insert into Productos
  21.         [
  22.         SO_ID = saleOrderDet.get("SALESORDERID")
  23. Product_ID = productIDDet.toLong()
  24. Product_Name = productNameDet
  25.         Quantity = productQuantityDet.toDecimal()
  26. List_Price = productListPriceDet.toDecimal()
  27. Tax = productTaxDet.toDecimal()
  28. Discount = productDiscountDet.toDecimal()
  29. Net_Total = productNetTotalDet.toDecimal()
  30. ]
  31.     }

This is working but I do not like the fact that I need to manipulate strings to get what I need. I would prefer to be using a get from the  productOrdersDetList but this is not accepted.

Do you have any better idea?

Thanks a lot in advance!

Best regards,

Christophe Mendez | MZ Consultants - Zoho Alliance Partner