GlideRecord is not a constructor Error

Stephan S_
Tera Expert

Hi Community,

i have a little UI-Action, wich exports my Cases and sets them from one state to another.

As I am moving to Orlando, my UI-Action does not work anymore and I have no clue why. Can you please help out?

The Error:

find_real_file.png

 

The Code:

function downloadExcel(){
var checked = g_list.getChecked(); // get's the sys_id of the checked records
var query = "sys_idIN" + checked.toString();
var rows = checked.split(",").length; // rows to be sent to the export function
// this code you can move to script include and go GlideAjax as well
var gr = new GlideRecord('x_bhhgh_his_cases_his_cases');
gr.addQuery('sys_id', 'IN', checked);
gr.query();
while(gr.next()){
gr.state = 6;
gr.update();
}
var view = "Workspace"; // set this to default for columns present in default view for list layout
// set this to empty if you want all the columns present in the list layout including the customized ones.
var dialog = new GwtPollDialog('x_bhhgh_his_cases_his_cases', query, rows, view, 'unload_excel_xlsx');
dialog.execute();
}

Commenting out Line 6 to 11 (the part where the State gets modyfied) everthing runs properly...

 

Thanks a lot in advance!!!

Best Regards,

Stephan

 

1 ACCEPTED SOLUTION

Hi Stephan,

So you should be calling like this

I have added toString() as well while sending the checked values

Please try

var ga = new GlideAjax('x_bhhgh_his_cases.updateRecords');
    ga.addParam('sysparm_name', 'updateRecorWithValue');
    ga.addParam('sysparm_checked', checked.toString());
    ga.getXML(processResponse);
    
    function processResponse(response) {
    var result = response.responseXML.documentElement.getAttribute("answer");
    }

Also did you verify row count in script include?

Try adding some logs to function

updateRecorWithValue: function(){

        var checked = this.getParameter('sysparm_checked');

        gs.info('sys_ids are ' + checked);
        var gr = new GlideRecord('x_bhhgh_his_cases_his_cases');
        gr.addQuery('sys_id', 'IN', checked);
        gr.query();

        gs.info('Row count is: ' + gr.getRowCount());
        while(gr.next()){

        gs.info('Inside while');
            gr.state = 6;
            gr.update();
        }
    },

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

15 REPLIES 15

Sure -Here you go 🙂

find_real_file.png

Hi Stephan,

So you should be calling like this

I have added toString() as well while sending the checked values

Please try

var ga = new GlideAjax('x_bhhgh_his_cases.updateRecords');
    ga.addParam('sysparm_name', 'updateRecorWithValue');
    ga.addParam('sysparm_checked', checked.toString());
    ga.getXML(processResponse);
    
    function processResponse(response) {
    var result = response.responseXML.documentElement.getAttribute("answer");
    }

Also did you verify row count in script include?

Try adding some logs to function

updateRecorWithValue: function(){

        var checked = this.getParameter('sysparm_checked');

        gs.info('sys_ids are ' + checked);
        var gr = new GlideRecord('x_bhhgh_his_cases_his_cases');
        gr.addQuery('sys_id', 'IN', checked);
        gr.query();

        gs.info('Row count is: ' + gr.getRowCount());
        while(gr.next()){

        gs.info('Inside while');
            gr.state = 6;
            gr.update();
        }
    },

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

where can i read these logs? I added them, but have no clue where to find them 😞

 

The added .tostring() did not work 😞

Hi Stephan,

in left navigation type script logs

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

i did found an error, but i am still puzzeld:

"Script: updateRecords not found in scope: x_bhhgh_his_cases, and HTTP Processor class not found: com.glide.processors.xmlhttp.updateRecords: no thrown error"

Does this help you to find the answer? 🙂