UI PAGE HTML document.getElementById('id').innerHTML is not printion value.

xavifrancis
Kilo Expert

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.

1 ACCEPTED SOLUTION

xavifrancis
Kilo Expert

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::>


find_real_file.png




Regards,


Francis Xavier


View solution in original post

4 REPLIES 4

Raju Koyagura
Tera Guru

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.


Ankur Bawiskar
Tera Patron
Tera Patron

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


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

xavifrancis
Kilo Expert

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::>


find_real_file.png




Regards,


Francis Xavier


Hi Xavier,



Nice to hear. Can you also mark the answer as correct, helpful and hit like. Thanks in advance.



Regards


Ankur


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