The CreatorCon Call for Content is officially open! Get started here.

Receiving SyntaxError while submitting the Quiz created from Catalog Item Request

SumeetG
Tera Contributor

Hello All,

I am trying to create a quiz which can be submitted after user submits request from catalog item and will trigger a specific use case on Service Portal.

The issue is I am receiving below error:

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at eval (eval at providers (sp_min.jsx:2997:793), <anonymous>:461:35)
    at js_includes_sp_libs.jsx:150:434
    at m.$eval (js_includes_sp_libs.jsx:165:69)
    at m.$digest (js_includes_sp_libs.jsx:162:131)
    at m.$apply (js_includes_sp_libs.jsx:165:363)
    at l (js_includes_sp_libs.jsx:116:421)
    at N (js_includes_sp_libs.jsx:121:376)
    at M.onload (js_includes_sp_libs.jsx:122:338)
(anonymous)	@	js_includes_sp_libs.jsx:137

 

The same quiz when submitted a request can be accessed and submitted from platform view and works as expected. I am unable to navigate what the issue is and how to resolve it.

4 REPLIES 4

AnirudhKumar
Mega Sage

Its hard to tell exactly what might be causing the issue as you have not provided what components you have used (client scripts, MRVS, etc.) The root-cause could be in any of these. But I will provide a general guidance though.

 

Know that Service Portal runs on what is called a 'Strict Mode'. Meaning it will not allow certain types of scripting that manipulates HTML elements on the page (Unless you explicitly ask it to). So if you have a client script that has a line of code that says - document.getElementByID... then Service Portal will throw an error.

 

Also, the error speaks about a JSON. This is common when trying to parse JSON type variables, often used with Multi-row variable sets, again in a client script.

 

There you go. With these inputs, I hope you will be able to better debug now.

Hello Anirudh,

So, to explain my situation, I am making user to submit a request using catalog item. After request is submitted, a quiz pops up based on Users data on request. The "Quizzes" component is used for this scenario. Also, the workflow of catalog item (which includes scripts) does all the work which adds user to "assign quiz" and scores the results based on answers.

The error is displayed when user tries to submit the quiz.

 

If it try to take this generated quiz instance (from request catalog item) on platform view. It works fine.

SumeetG_1-1722883812439.png

 

 

Community Alums
Not applicable

Hi @SumeetG ,

 

This error indicates that the JSON being parsed is incorrect or malformed.

 

Can you please double check if the logic to parse the data is correct.

Please add the below logging script to inspect the JSON data before parsing it.

try {
var jsonData = JSON.parse(yourJsonString);
} catch (e) {
console.error("Error parsing JSON:", e);
console.error("JSON data:", yourJsonString);
}

It should help you identify the issue and you can review the scripts that is responsible for the errors.

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!


Thanks & Regards,

Sanjay Kumar

RanaElsekhily
Tera Contributor

Hello SumeetG,

Were you able to fix this error?
I receive the same problem.
Thank you,