- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 01:05 AM
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:
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
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 03:12 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 08:08 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 11:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2020 11:46 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2020 11:58 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2020 12:12 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader