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.

What is the use of "setLocation" method in the below code?

yogesh15dd
Tera Guru

Hi, i have the below jelly code in one of the UI pages, not sure what is the use of this? especially the use of "setLocation" method?

Here i the "pageNumber" value will be 1 and finally grOffset   will be equal to = 0 (zero) , then using the zero in setLocation will be like "current.setLocation(- 1)", what is the use of this?, where it sets "-1"??


I tried changing the value of this to current.setLocation(50), but found no changes in the results.

Thinking is it really required?

Any suggestions are most welcome.

Jelly code:

<j2:if test="${RP.getParameterValue('sysparm_page') != ''}">

          <g2:evaluate var="jvar_page_number" jelly="true">

                var pageNumber = RP.getParameterValue('sysparm_page') + '';

                pageNumber = parseInt(pageNumber, 10);

               

                if (isNaN(pageNumber) || pageNumber ${LT} 1)

                      pageNumber = 1;

                var grOffset = (pageNumber - 1) * jelly.jvar_max_entries;

                current.setLocation(grOffset - 1)

          </g2:evaluate>

    </j2:if>

3 REPLIES 3

yogesh15dd
Tera Guru

we are using jelly.jvar_max_entries = 20


Jim Coyne
Kilo Patron

It sets the current row location in a GlideRecord object - GlideRecord - ServiceNow Wiki


thanks, i have read this wiki page already. my doubt is why isn't the result table rows position getting changed if I change the value for "pageNumber"?? like i find no difference in the result table page with this script part removed.