Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Scroll Automatically to the Bottom of the Page in Service Portal

salu
Mega Guru

Hello,

Consider I have a list of questions. When I click on the first question, it should automatically take me to the bottom of the page.

window.scrollTo(0,document.body.scrollHeight); won't work as document won't work in API.

Thanks

Saranya

1 ACCEPTED SOLUTION

Hello Mansoor,


I got the solution for the same.



$scope.scrollTo = function(id) {



var old = $location.hash();


$location.hash(id);


$anchorScroll();


//reset to old to keep any additional routing logic from kicking in


$location.hash(old);


};



<sp-model form-model="::data.sc_cat_item" mandatory="mandatory" ng-click="scrollTo('e30904d54f83e200bb603f828110c721')"   ></sp-model>


View solution in original post

23 REPLIES 23

renakhanna
Kilo Contributor

hello Saranya S Babu



                                  I Also Facing Same Problem


Please Explain Deeply.



$scope.scrollTo = function(id) {



var old = $location.hash();


$location.hash(id);


$anchorScroll();


//reset to old to keep any additional routing logic from kicking in


$location.hash(old);


};



<sp-model form-model="::data.sc_cat_item" mandatory="mandatory" ng-click="scrollTo('e30904d54f83e200bb603f828110c721')"   ></sp-model>



Actually I Am New For


ServiceNow,How I Use Above


Code.


Below Video I Mentioned


My Issue



Hello Dinesh,



Ca you please share me the code which you using?


renakhanna
Kilo Contributor

Hello


Saranya



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">




<g:evaluate>


var kburl = "/$knowledge.do?";


if ("${RP.getParameterValue('sysparm_search')}" != "")


kburl += "query=${RP.getParameterValue('sysparm_search')}&amp;sysparm_type_filter=all&amp;sysparm_order=relevancy";


if ("${RP.getParameterValue('category')}" != "") {


kburl += "sysparm_type_filter=all&amp;";


kburl += "sysparm_kb=dfc19531bf2021003f07e2c1ac0739ab&amp;";


kburl += "sysparm_category=${RP.getParameterValue('category')}&amp;";


kburl += "browse_type=categories";


}





</g:evaluate>


<div id="loading-gif" class="loading-wrapper">


<img src="loading_gif.gif" width="441" height="291" />


</div>


<div class="">


<iframe scrolling="no" onload="applyStyle()" width="100%" height="100%" name="gsft_main" id="gsft_main"   frameborder="0" border="0" allowtransparency="true" src="${kburl}" />


</div>


<g:macro_invoke macro="vs_frame_after_script" />


</j:jelly>




Thanks For Your Reply And Please Help For My Issue



Thanks


Dinesh


renakhanna
Kilo Contributor

Hello Saranya


                              Still I Am Waiting For Your Responce, Where I Use This Code Please Help To Me



Thanks


Dinesh


Hello Raghu,


I hope you are using the CMS..



Above code was for service portal




In the jelly script you pass the sys_id of the variable or div id and call that on the client script..