onCellEdit client script: update field based on change from a different field.

EdwinCoronado
ServiceNow Employee
ServiceNow Employee

Hello,

I have fields Y (reference) and Z (reference). When a user changes field Y, I want to extract a "dot-walk" value "Y.assigned_to" and pass it to field Z. I want to be able to dynamically do this and refresh the list through an onCellEdit client script. So far, I'm using an 'on before insert update' business rule to do this, but the user will have to reload the page to see the change take effect. Any help would be appreciated.

Thanks!

3 REPLIES 3

Mike Patel
Tera Sage

you can create onChange script like

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
	var user = g_form.getReference('myvariablename', populateDetails);

	function populateDetails(user) {
		g_form.setValue('test', user.assigned_to);
	}	
}

I already have the onChange. I need to implement this onCellEdit so that functionality is there across the UX.

SanjivMeher
Kilo Patron
Kilo Patron

You can try solutions provided in below link and try refreshing the list on celledit

 

https://community.servicenow.com/community?id=community_question&sys_id=a550d329dbdcdbc01dcaf3231f96...


Please mark this response as correct or helpful if it assisted you with your question.