- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 04:28 AM
Hi All,
I am trying to show an UI page when the user finishes his test, it will redirect to the page.
In the client script part, I have used GlideRecord to query the total score of that user.
The score will be entered into the query table when the user answers the final question.
The HTML is:::
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html>
<br></br><br></br><br></br><br></br><br></br><br></br><br></br><br></br>
<center> <p style="font-size:70px; color:green"> Thank you </p>
<p style="font-size:70px" >Your Score is ---> <b id = "1">> Result</b></p> </center>
</html>
</j:jelly>
The Client script is:::
var m;
var gr=new GlideRecord('u_quiz_router');
gr.addQuery('u_tester_id',g_user.userName);
gr.query();
while(gr.next()){
document.getElementById("1").innerHTML = gr.u_result;
}
The client script gives the exact answer when I run it separately.
Can you help me in this?
Regards,
Francis Xavier.
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2017 06:09 AM
I have done some modification to the client script and now it is working fine.
Thank you
addLoadEvent(function() {
var gr=new GlideRecord('u_quiz_router');
gr.addQuery('u_tester_id',g_user.userName);
gr.query();
while(gr.next()){
document.getElementById("1").innerHTML = gr.u_result;
}
});
This is the Output::>
Regards,
Francis Xavier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2017 04:38 AM
Instead of creating GlideRecord directly in client script, call a script include. I mean GlideRecord code should be in ScriptInclude and call that SI in client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2017 04:34 AM
Hi Xavier,
First of all how many records the query will return since you have only 1 html element to store the value
Can you try to use if() condition instead of while and check it once whether it is able to populate the value
also i think there is a mistake in your ui page html section
<p style="font-size:70px" >Your Score is ---> <b id = "1">> Result</b></p>
i have removed the '>' and below is the html code
<p style="font-size:70px" >Your Score is ---> <b id = "1"> Result</b></p>
var m;
var gr=new GlideRecord('u_quiz_router');
gr.addQuery('u_tester_id',g_user.userName);
gr.query();
if(gr.next()){
document.getElementById("1").innerHTML = gr.u_result;
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
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
09-12-2017 06:09 AM
I have done some modification to the client script and now it is working fine.
Thank you
addLoadEvent(function() {
var gr=new GlideRecord('u_quiz_router');
gr.addQuery('u_tester_id',g_user.userName);
gr.query();
while(gr.next()){
document.getElementById("1").innerHTML = gr.u_result;
}
});
This is the Output::>
Regards,
Francis Xavier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2017 06:21 AM
Hi Xavier,
Nice to hear. Can you also mark the answer as correct, helpful and hit like. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader