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.
- // Get the Sales Orders from Zoho CRM
- salesOrders = zoho.crm.searchRecords("SalesOrders", "(Status|=|Asignado)");
- // Add the Sales Orders records in the Orders table
- for each saleOrderDet in salesOrders
- {
- // DEBUG info "Order: " + saleOrderDet.get("SO Number"); // DEBUG
- // Get the Products from every Sale Order record
- productOrders = saleOrderDet.get("product").toJSONList();
- for each productOrdersDet in productOrders
- {
- productOrdersDetList = productOrdersDet.toList();
- productIDDet = productOrdersDetList.get(9).subString(14,32);
- productNameDet = productOrdersDetList.get(0).subString(17,(productOrdersDetList.get(0).length()-1));
- productQuantityDet = productOrdersDetList.get(1).subString(12,(productOrdersDetList.get(1).length()-1));
- productListPriceDet = productOrdersDetList.get(2).subString(14,(productOrdersDetList.get(2).length()-1));
- productTaxDet = productOrdersDetList.get(6).subString(7,(productOrdersDetList.get(6).length()-1));
- productDiscountDet = productOrdersDetList.get(8).subString(12,(productOrdersDetList.get(8).length()-1));
- productNetTotalDet = productOrdersDetList.get(7).subString(13,(productOrdersDetList.get(7).length()-1));
- // Add the Products in the Productos table
- insert into Productos
- [
- SO_ID = saleOrderDet.get("SALESORDERID")
- Product_ID = productIDDet.toLong()
- Product_Name = productNameDet
- Quantity = productQuantityDet.toDecimal()
- List_Price = productListPriceDet.toDecimal()
- Tax = productTaxDet.toDecimal()
- Discount = productDiscountDet.toDecimal()
- Net_Total = productNetTotalDet.toDecimal()
- ]
- }
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,