Setting datetime field as date.now() when other field changes (in a case)

Hi there,

I have two related fields in a case detail screen - case_root_cause and case_root_cause_datetime. I am trying to set the datetime field to date.now() when the case_root_cause field is changed to be no longer empty. I tried to do this by using the OnChangeScript for the case_root_cause as this:

if(this.value != ''){
case_root_cause_datetime.value = date.now();
}

The code hasn't worked but I suspect it can't be far wrong? Has anyone done anything similar before.

Any help or advice would be massively appreciated.

Thanks,

Paul