'SyntaxError: Unexpected end of JSON input' error message when running ATF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 03:46 AM
When I run an ATF, an error message of 'There is a JavaScript error' in your browser console' for a catalogue item on the service portal within the client test runner. However, when I view the same catalogue item on my browser, I don't get that error message.
When I look at the results of the ATF, it mentions the following message:
'Error while running Client Script "Check subGroups and Juridiction - Reinst": SyntaxError: Unexpected end of JSON input'
When I open the "Check subGroups and Juridiction - Reinst" catalog client script, I can't see any syntax issues. The client script can be found below:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.clearValue('provider_subgroup_is_rfb');
var mrvsUbsRec = '';
var conditionsMet = 'false';
var mrvs = JSON.parse(g_form.getValue('ubs_table_reinstate'));
//Iterate each row in the UBS table (multi row variable set)
var ubsrec = [];
for (var i = 0; i < mrvs.length; i++) {
var row = mrvs[i]; //individual row
ubsrec.push(row.ubs_mrvs_reinstate);
}
mrvsUbsRec = ubsrec.toString();
//alert('The value of mrvs s ' + mrvs);
//alert('The value of mrvs is ' + mrvs.toString());
//art('The value of mrvsUbsRec is ' + mrvsUbsRec.toString());
//alert(mrvsUbsRec: '+mrvsUbsRec);
var checkConditions = new GlideAjax("LBGSPCAjaxUtils");
checkConditions.addParam("sysparm_name", "checkProvderRecipientSubgroupsJurisdiction");
checkConditions.addParam("mrvs", mrvsUbsRec);
checkConditions.getXML(processResponse);
//alert('e value of checkConditions is ' + checkConditions);
function processResponse(response) {
var result = response.responseXML.documentElement.getAttribute("answer");
conditionsMet = result;
//alert("departsubGroup value is " + departsubGroup);
//alert('The value of mrvs is ' + mrvs);
//alert('The value of mrvs is ' + mrvs.toSting());
//alert('The value of result is ' result); //alert('The value of conditionsMet is ' + conditionsMet);
if (conditionsMet== 'true') {
g_form.setVaue('provider_subgroup_is_rfb', 'true');
}
}
}
If somebody could let me know if there's anything wrong with the code, that would be great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 04:01 AM
Hello @matthew_hughes ,
Can you try modifying your code to below code if this helps
Also, Please check this below link
Thanks,
Omkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 04:15 AM
Hi @Omkar Kumbhar I did try the following code:
for (var i = 0; i < mrvs.length; i++) {
var row = mrvs[i]; //individual row
ubsrec.push(row.ubs_mrvs_reinstate).toString();
}
Unfortunately that made no difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 04:25 AM
@matthew_hughes There must be some error in "checkProvderRecipientSubgroupsJurisdiction" function of "LBGSPCAjaxUtils" script include. As its used in GlideAjax. Please check that.
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 05:02 AM
This is the code for the 'checkProviderRecipientSubgroupsJurisdiction' within the script include:
checkProviderRecipientSubgroupsJurisdiction: function() {
var result = this.newItem("result");
var mrvs = this.getParameter('mrvs');
// gs.log('JT: ' + mrvs);
//var mrvs current.variables.ubs_table_update; //Table of UBS records to update (multi-row variable set)
var providerCount = 0;
var jurisdictionCountProvider= 0;
var recipientCount = 0;
var jurisdictionCountRecipient = 0;
var capProv = new GlideRecord('u_cmdb_ci_capability_provisioning');
capProv.addQuery('sys_id', 'IN', mrvs);
//capProv.setLimit(1);
capProv.query();
while (capProv.next()) {
//Check if provider is rfb
if (capProv.u_provider.u_subgroup == 'rfb') {
providerCount++;
}
//check if jurisdiction is Germany or netherlands for the provider
if (capProv.u_provider.u_jurisdiction.includes(gs.getProperty('LBG.recipient.jurisdiction.germany')) || capProv.u_provider.u_jurisdiction.includes(gs.getProperty('LBG.recipient.jurisdiction.germany2')) || capProv.u_provider.u_jurisdiction.includes(gs.getProperty('LBG.recipient.jurisdiction.Netherlands'))) {
jurisdictionCountProvider++;
}
//check if recipient rfb
if (capProv.u_recipient.u_subgroup != 'rfb') {
recipientCount++;
}
//check if jurisction is Germany or netherlands
if (capProv.u_recipient.u_jurisdiction.includes(gs.getProperty('LBG.recipient.jurisdiction.germany')) || capProv.u_recipient.u_jurisdiction.includes(gs.getProperty('LBG.recipient.jurisdiction.germany2')) || capProv.u_recipient.u_jurisdiction.includes(gs.getProperty('LBG.recipient.jurisdiction.Netherlands'))) {
jurisdictionCountRecipient++;
}
}
if (providerCount >= 1 && recipientCount >= 1) {
result= 'true';
} else if (providerCount >= 1 && jurisdictionCountProvider >= 1 && jurisdictionCountRecipient >= 1 && recipientCount == 0) {
result = 'true';
} else {
result = 'false';
}
// gs.log('JT providerCount: ' + providerCount);
// gs.log('JT recipientCount: ' + recipientCount);
// gs.log('JT jurisdictionCount: ' + jurisdictionCount);
return result;
},