Creating P.Os to my suppliers, based on the line items in a quote

Creating P.Os to my suppliers, based on the line items in a quote

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....

      • Sticky Posts

      • Connect with Zoho users from your industry, virtually!

        A couple of years ago, we started setting up industry-wise channels for users with similar businesses to chat and discuss Zoho contextually. We started with Real Estate and E-commerce sectors, creating a chatroom and hosting regular meetups on niche areas
      • Feature update: Advanced security settings

        We've previously written about how using security policies could be beneficial for admins. To enable you to better protect your organization, we've come up with a few additional settings for security policies in Zoho One that can be used to regulate your users' web sessions. What are web sessions? A web session refers to the period of time you stay signed in to your Zoho One account. You create a new web session every time you sign in to Zoho One (or any of its included apps), and this session exists