Custom Function: How to update a custom field in purchase orders with warehouse information

Custom Function: How to update a custom field in purchase orders with warehouse information

Hi, I am new to custom functions but have managed to write into custom fields based on certain criteria when purchase orders are edited/changed. My problem is how to access (get) the warehouse name after I have retrieved the warehouse_ID from the purchase order. It looks like I have a data type problem or just don't have enough experience. Here is my code (with missing statements).

POID = purchaseorder.get("purchaseorder_id");
POdate = purchaseorder.get("date").toDate();
ORGID = organization.get("organization_id");
wh = "";
WhID = ORGID;
WhID = zoho.inventory.getRecords("puchaseOrders",ORGID,"warehouse_id");
wh = WhID.toString(); /* This is just for testing if I have a valid warehouseID */
/* What is the datatype of warehouseID??*/
/* Here n eeds to be a "getRecordsbyID function?? like:
wh = zoho.inventory.getRecordsByID("warehouses",ORGID,WhID); How do I get the "warehouse_name" content? */
CustomFields = List();
CustomField = Map();
CustomField.put("label","Project"); /*This is the field I want to update)
CustomField.put("value",wh);
CustomFields.add(CustomField);
json = Map();
json.put("custom_fields",CustomFields);
result = zoho.inventory.updateRecord("purchaseOrders",ORGID,POID,json);

So far my result in the custom field "project" is:
java.lang.Object@2d78211a
which might be the warehouse_ID??

Can anybody help fill in the blanks? Again, I would like to see the warehouse name in the custom field "Project".
Thanks so much (and stay safe these days)!
    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 コンテンツ




                              ご検討中の方