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.

How to call onload script in jelly

jeevitha3
Kilo Contributor

Hi All,

I have a dynamic block on homepage , in dynamic content I have created a button and onclick of button I am calling a function and based on the input(userid) given , reports will be populated for that particular user. This is working fine.

But i want the same functionality ,When the homepage loads, it should get logged in user id and populate records.

I tried calling function in div tag but its not working, how to call function onload in jelly script.

Thanks in advance.

1 ACCEPTED SOLUTION

Add this to your existing script below xyz function defintion



addLoadEvent( function() {  


xyz();  


});


View solution in original post

13 REPLIES 13

apurvasharma
Kilo Guru

Hi,



You can create a UI script which is global. and can check


if (window.location.pathname.indexOf('home.do') == 1) { // you can call your function here}



Hope this helps!.



Thanks,


Apurva Sharma


Hi Apurva ,



Thanks for your response. I want it for one particular Homepage. I am using Dynamic Content and added it to that homepage. Onload I want to load reports with logged in user ,then they should also have a button to check for other users. I am done with second part , not aware about onload thing.


amaradiswamy
Mega Sage

Hi Jeevitha,



Include the below script in your jelly script.



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


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


<script>


addLoadEvent( function() {


onLoadFunction();


});


</script>


</j:jelly>



Client script:



function onLoadFunction()


{


// Yor statements in onload function


}



Thanks and regards,


Swamy


Thanks Amaradi , will try it.