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());