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

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.


Let me know if that answered your question. If so, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list. Thank you


How To Mark Answers Correct From Community Inbox


Done


Sorry to ressurect this,

Would the business Rule be a Before Query business rule?