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

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now