- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2019 04:01 PM
I have a catalog client script below on a catalog item, Type = onChange, Variable name = rpType, applies to Catalog Item view (checked).
In the Background, this code:
var n = getNextTbn();
gs.print('Final TBN: ' + n);
function getNextTbn() {
var tbnCount=0;
var gr = new GlideRecord('u_badgtbn');
gr.query();
gs.print("Nn: " + gr.getRowCount() );
tbnCount = pad(gr.getRowCount(), 9);
return tbnCount;
}
function pad(num, size) {
var s = "000000000" + num;
return s.substr(s.length-size);
}
Returns this:
Script execution history and recovery
*** Script: Nn: 1
*** Script: Final TBN: 000000001
In my client script below, just shows the alerts
Precall...
1...
Then nothing.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var rpIdentifier = g_form.getValue('rpIdentifier');
if ( rpIdentifier.length < 2 ) {
alert ('Precall...');
var nNext = getNextTbn();
alert ("nNext: " + nNext);
g_form.setValue('rpIdentifier', nNext );
alert ('postCall... ' , nNext );
}
}
function getNextTbn() {
var tbnCount=0;
var gr = new GlideRecord('u_badgtbn');
gr.query();
alert ("1...");
alert("Nn: " + gr.getRowCount() );
alert ("2...");
tbnCount = pad(gr.getRowCount(), 9);
alert ("3...");
return tbnCount;
}
function pad(num, size) {
var s = "000000000" + num;
return s.substr(s.length-size);
}
Any idea why that would be the case? Table u_badgtbn has read and write ACLs set to public. Nothing showing up in any of the logs on this.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2019 04:06 PM
Lot of GlideRecord function wont work in Client Script. That's why you need to use Glideajax for such use cases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2019 04:06 PM
Lot of GlideRecord function wont work in Client Script. That's why you need to use Glideajax for such use cases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2019 04:28 PM
Ah! Good to know. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2020 11:40 AM
From client side, you can't use getRowCount(). However, gr.rows.length will return what you are looking for without a GlideAjax call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2025 05:57 AM
Ironically, if you use the callback function, getRowCount() does work.
gCI.query(myCallbackFunction);
function myCallbackFunction(gCI) {
gCI.getRowCount(); //Does return the correct value
}