Client Script: new value not set after calling setValue() - what's wrong?

Client Script: new value not set after calling setValue() - what's wrong?

I'm new to Javascript and Zoho Client Script, though I have experience developing applications in C and Java. I have been trying to figure out why my code doesn't work and would appreciate help from the community to point out what's wrong.

For my current JS and Zoho Client Script learning purpose, this client script will run when the user associates the current record with an Accounts record, and when that happens, I want to update a field called phase with the value "Updated". I'm expecting to see this value change on screen after I have associated the records. The problem is I am not seeing this happen and looking at the log messages, the phase field value is not updated with the new value after calling setValue() function.

Here's my code snippet:

let phaseField = ZDK.Page.getField('Current_Incubation_Phase');
log(phaseField.getValue());
let textToSet = "Updated";
log(textToSet);
phaseField.setValue(textToSet);
log(phaseField.getValue());

    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