Check if value is updated by user or not

Sai Sai
Kilo Contributor

Hi,

In onchange client script i wanted to check if the field value is updated directly by user or by another client script.

For example there are 3 fields a,b,c

based on value of b, the value of c will automatically change. (first client script on field b)

Now i wrote a onchange client script on field c. 

My requirement now is : If I manually change value of c then client script should trigger. If the value of c is updated by first client script mentioned above then my new client script should not trigger.

How can i determine it?

12 REPLIES 12

Just imagining this scenario, if this not documented very well, any new developer will go crazy about the idea.

Best Regards
Aman Kumar

Ian Mildon
Tera Guru

Was trying things out on a PDI and this seemed to work:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
	
	var who = g_form.sys_updated_by;
    if (newValue != '' && who == 'system') {
        g_form.addInfoMessage("System updated the field");
    }
	
	if (newValue != '' && who != 'system') {
        g_form.addInfoMessage("User updated the field");
    }

}

Although for Choice fields you may need to list the possible values in the "if" checks.

Hi

correct me if I'm wrong but 

g_form.sys_updated_by

returns the user who has last changed the record but not which script is firing on client-side at the moment the user works with the form

Maik

It was a quick test, so may not have been the most thorough on all possibilities. Got called away so never fully tested.

Ok, so I went back and tested it fully with a Client Script to trigger an update to a field. Maik was right, 'sys_updated_by' can't be used in this respect

Yes it did not work. It is taking updated value from database and not on form.