How to update zoho creator record ( a look up field) through widgets - js api?

How to update zoho creator record ( a look up field) through widgets - js api?

Can I ask help how to update a record with a look up field from a widget using JS API? I get to fetch value of look up field using the code below. But I'm not sure how to update the record in creator when user selected a different option from the dropdown.

      fetchLookupData();
        var selectedLookupValue = tempHolderData["Units_look_up"].ID; 
        setTimeout(function() {
            $("#unitDropdown").val(selectedLookupValue);
        }, 1000); // Timeout to allow dropdown to populate

    function fetchLookupData() {
        var config = {
            reportName: "All_Units", // Replace with the report name
            criteria : "ID!=null",
            page : 1,
            pageSize : 10
        };

        ZOHO.CREATOR.init().then(function() {
            ZOHO.CREATOR.API.getAllRecords(config).then(function(response){
                var recordArr = response.data;
                for(var index in recordArr){
                    console.log(recordArr[index]);
                    var item = recordArr[index];
                    var option = document.createElement("option");
                    option.value = item.ID; 
                    option.textContent = item.Unit; 
                    document.getElementById("unitDropdown").appendChild(option);
                }
            }).catch(function(error) {
                console.error("Error fetching lookup data:", error);
            });
        });
    }


HTML  Code:

                <div class="form-row">
                    <label for="unitDropdown" class="form-label">Unit</label>
                    <select id="unitDropdown" name="unitDropdown" class="form-input">
                        <!-- Options will be dynamically populated here -->
                    </select>
                </div>


    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 コンテンツ




                              ご検討中の方