Can someone help me with CellEdit client script ...with an example ???

s_kumar
Mega Contributor

Can someone help me with CellEdit client script ...with an example ???

1 ACCEPTED SOLUTION

Hi Sandeep,


onCellEdit is a function that is used in the case of a list. If you want to write some script that should be executed on a list then you can do that by using onCellEdit function.



In my previous example:



It is checking in one field whether it is having the same old value or new value and if success then returns a success using the callback function.



Another small example for you:



The script below runs on the State field and prevents users from changing the State to closed in a list.   Hope this helps.



function onCellEdit(sysIDs, table, oldValues, newValue, callback) {


    var saveAndClose = true;



  if(newValue == 7){


  alert('Not allowed');


  saveAndClose = false;


  } else {


  saveAndClose = true;


  }



callback(saveAndClose);


}


View solution in original post

16 REPLIES 16

Gurpreet07
Mega Sage

HI Gurpreet



I really appreciate your help and the example you gave to me but as i told you i have no idea how its working


can you please explain one any one and on which filed it will work


how to write ..


why we need function call at the button...



Thanks


Sandeep Kumar


Ajai S Nair
Giga Guru

Hi Sandeep,



This link may help you:


Client Scripts - ServiceNow Wiki


Hi Ajay



Thankyou So much.



Please help me to understand that example ..i am not able to get anything from that ..do you have any other example .



Thanks


Sandeep Kumar