Does g_scratchpad works with onCellEdit client script?

ajitmundhekar
Tera Expert

I am trying to perform some validation check in list layout using Display BR with g_scratchpad & onCellEdit CS. But it is giving me error as:

'g_scratchpad is not defined' --I am getting this error in console of all 3 broswers i.e. (Chrome, Moz & IE)

Here is my code:

****************BR***************

(function executeRule(current, previous /*null when async*/) {

// Add your code here

g_scratchpad.tpid = current.u_trading_partner_cert_id;

})(current, previous);

********onCellEdit CS*********

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

  var saveAndClose = true;

//Type appropriate comment here, and begin script below

if(g_scratchpad.tpid != ''){

alert('This is an integration record & cannot be updated from list layout...');

}

callback(saveAndClose);

}

If its not possible to call g_scratchpad from onCellEdit CS, please suggest me some alternatives (preference is to perform this validation at client side only)

TIA.

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Ajit,



Display business rule is executed when you open the form. Hence in this case, Display BR is not executed and so is the error i.e "g_scratchpad not defined".


You will have to create a BEFORE business rule and then perform validations.


View solution in original post

5 REPLIES 5

rishireddy
Mega Guru

Hi All,

I thought below mentioned approach might be helpful to anyone who is looking to get the value in celledit client script.

Instead of g_scratchpad, we used gs.getSession().putClientData()) in BR to store the value and we accessed the value in celledit CS using g_user.getClientData().

It worked for us!

Regards,

Rishi

PS - Please mark Helpful, Like, or Correct Answer if applicable