Copy from one field to another using Custom Functions

Copy from one field to another using Custom Functions

Hi, I have attempted to write the following function to copy the purchase price to sell price when the purchase price is updated on an Item. Once I have solved this I then need to draft a function to update the purchase price from the most recent purchase order, but that's down the line for now.

itemID = zoho.inventory.getRecordsByID("items",[entered my organisation ID],"item_ID");
purchasePrice = item.get("purchase_rate");
newRate = Map();
newRate.put("rate",purchasePrice);
update = zoho.inventory.updateRecord("items",[entered my organisation ID],itemID,newRate);
info newRate;
info update;

After executing, all appears OK....

Result

Function Executed Successfully

Log Messages

{"rate":"70.0"}

java.lang.Object@4ed6233f

After executing, the Item sell price (rate) is not updated from the purchase price field (purchase_rate) 
Sell Price currently set at £0.00
Purchase Price currently set at £70.00

I have then set up a Workflow to try and trigger when any field on the item is updated, however the Sell Price (rate) remains at £0.00 and it does not pull the updated purchase price (purchase_rate) of £70.00 (in this test) 

Thanks in advance

Chris
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方