Hi all.
My company supplies TV equipment to TV stations. So we'll prepare a quote for a prospect which has several line items in it, which may come from several manufacturers. Once a customer agrees to the quote, I need to then issue purchase orders to my individual suppliers to have them ship their products to the customer (we don't hold inventory, we do "just in time" shipping direct from the supplier). We're using Zoho CRM.
I've written a function that will populate a Purchase Order Template based on the line items of the quote, which works perfectly, substituting my material cost for the list price we've quoted the customer. But it generates a single P.O. with all of the line items on it - I want to generate separate P.Os for each of my suppliers, with only their products listed on them. I expected that I could do this by modifying my function with a series of IF statements, that would only add a specific vendor's product to the P.O, ignoring the line items from the other vendors. But I'm hitting a significant snag.
The first attachment is generated from an "info" call, looking at a real, hand created P.O. You'll see that there are several key/value segments that have identical keys ("product"). These correspond to the individual line items on the P.O.
The second is the listing of the test function I've been using - it pulls information out of a quote using a series of sucessive getRecordByID statements, and then updates the list price to the price that my company pays for the item. I then use a "zoho.crm.createRecord() call to create a new P.O. This works exactly as I would expect, but creates a single P.O. with all of the line items on it. I thought I could use a series of IF statements, to stop the code from populating a section of the map for a specific line item if it's not from a specific vendor ID, but the system says my createRecord() call is invalid. If i try to use a .put() method on the local map, it just over-writes the first line item for that vendor, which is also not what I want. I've tried turning the local map into a string so I can manipulate it that way, but then I can't get that to work with createRecord(). How do I create a map/collection which has multiple items all of which have the same initial key, but with different values? It must be possible - zoho is doing it internally for the hand-crafted version....