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>


    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