getRowCount is not a function

ninnesr
Kilo Contributor

Hi all,

**Some of the field names are different to defaults due to our build.

I'm currently writing a script to auto fill a requestor (caller) field if an organisation (department/company?) is entered and there is only one user in that organisation.

long story short I'm receiving an error when trying to use the getRowCount() function on a GlideRecord

Firbug error:
userRec.getRowCount is not a function
if (userRec.getRowCount() == 1){



//grab the confirm organisation from the form
var requestor = g_form.getReference('u_requestor')
var organisation = g_form.getReference('company')
var confirmOrg = g_form.getReference('u_confirm_organisation')
var userRec = new GlideRecord('sys_user');
if (newValue !='' && requestor.name == undefined){
//search for users with who are a member of this confirm org
userRec.addQuery('u_confirm_organisation', '=', confirmOrg.sys_id);
userRec.query();

//BROKEN!! userRec.getRowCount is not a function !?!
alert('query = '+userRec.getEncodedQuery());
if (userRec.getRowCount() == 1){
g_form.setValue('u_requestor', userName)
}

//so have to do the below. . .
var i = 0;
while (userRec.next()) {
i++;
if (i == 1){
var userName = userRec.name;
}
}
if (i == 1){
//Only one user associated with this confirm org, auto fill the requestor field
g_form.setValue('u_requestor', userName)

} else {
//more than one requestor, don't auto fill
}
}


As you can see I have a work around, but using the getRowCount() function would be much nicer.

Other functions work such as getEncodedQuery();

12 REPLIES 12

thanks a lot Capa JC the attribute rows.length can substitute to the function .getRowCount()


Thanks a lot for Capa ,It was a valuable information


Thanks


saranya


Hi Capa JC,



I have Similar like this, I used .rows and .rows.length, But both are Not working as expected and nothing is returned. Can this be corrected.


Caller is Reference Field in Form(New Call Table), Requirement is to display count of incidents of selected caller in last 30 days.



Client Script: Onchange



var caller = g_form.getReference('caller');



var gr = new GlideRecord("incident");


gr.addQuery('caller_id', caller);


gr.addQuery('opened_at', '<', gs.daysAgoStart(30));


gr.query();


g_form.addInfoMessage("Incident Count of Caller in Last 30 days", gr.rows);



I cannot use GlideAggregate in Script Include and Script Include in GlideAjax as I am using Onchange Script Here.



Thank You in Advance.



Regards,


Shravani