OnCellEdit client script is not working?

Shantharao
Kilo Sage

Hi All,

 

OncellEdit client script is not working, please tell me the issue in the below code

I have to use g_form.getReference call back function to populate user email 

u_name is reference filed refering to USER table

u_email is string filed, onCellEdit of Name(refernce) filed I have to populate user's email in the email string filed

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
alert("test on cell edit");
if (newValue != oldValues) {
var userEmail = g_form.getReference('u_name', populateEmail);
alert(userEmail.email);
saveAndClose = true;
} else {
saveAndClose = false;
}

function populateEmail(userEmail) {
g_form.setValue('u_email', userEmail.email);
}
callback(saveAndClose);
}

1 ACCEPTED SOLUTION

Hi,

what type of BR is this? if this is before update then remove current.update()

Also do you want it to set when u_name changes or you want to set u_email always

if always then use this

current.u_email= current.u_name.email;

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

14 REPLIES 14

Hi,

what type of BR is this? if this is before update then remove current.update()

Also do you want it to set when u_name changes or you want to set u_email always

if always then use this

current.u_email= current.u_name.email;

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

This is before business rule I am using this table as embedded list to other table
Whenever I have updated the parent update record this embelist list table should update

whenever u_name chnages automatically email should populate in the list view, is this possible?

Hi,

embedded list will get refreshed only when you save the record; it won't show immediately

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Bawiskar,

 

can you please tell me the best practice,

Below code is befor BR but I am using current.update(), is there any other way to achieve this 

if (current.u_name.changes()){
  current.u_email= current.u_name.email;
  current.update();
}

Hi,

Can you share screenshot?

you are trying to update field in embedded list or parent form?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader