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

Hi Stephan,

Got the issue

The script include name is UpdateRecords but in GlideAjax you are using updateRecords

so please correct the script include name as updateRecords

Regards
Ankur

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

Hi Ankur,

I am very new to this field in development. I changed the Name, but i still get errors 😞

Maybe the following Screenshots can help 🙂

find_real_file.png

 

find_real_file.png

Hi Stephan,

In which scope did you create the UI action?

In which scope did you create the script include?

Is this for your personal instance and you are ok to share url, some admin credential you can share here; it can be checked

Regards
Ankur

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

Hi Ankur,

unfortunately i developed this in my companys instance. I am not allowed to give you access there...

I did a scoped App and tryed to make this work within the application.

But i did found a workaround.

My aim was to mark a state, when a set of data was downloaded as excel, as a batch update of the state field is not possible in a list view.

The workspace has this solution - There you are able to batchupdate the state field for the seleceted cases.

This is a step more for my users, but they will learn it soon 🙂

 

Thank you very very much! Your help on this topic was just great!

@Stephan S. 

Glad to know that I was able to provide help.

Would you mind marking my response as helpful/correct if I am able to help you.

Regards
Ankur

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