The Zurich release has arrived! Interested in new features and functionalities? Click here for more

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

Hi Swamy ,



Its not working. I need to use dashboardMessageHandler as well for setting filter. Please suggest how to achieve this.


Hi Jeevitha,



Please post your code to edit.



May be you can use below in onloadfunction.



function onLoadFunction()


{



  var IDuser = "${gs.getUserID()}";


top.window.location = "/sys_report_list.do?sysparm_query=user=" + IDuser;


}



Thanks and regards,


Swamy


Hi Swamy,



This is what I have done for button part(onclick), same way I need to do on OnLoad.



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

function xyz()
{



var userID=prompt('Enter User ID');
if(userID!='' &amp; userID!= undefined ){
var my_dashboardMessageHandler1 = new DashboardMessageHandler("my_unique_id2");

var query=''; //my query

my_dashboardMessageHandler1.publishFilter('incident',query);



}
}
</script>


<input id="onlyMine" type="button" value="Show Filtered Records" onclick="xyz();" />
</j:jelly>


Hi Jeevitha,



Create a UI page instead of dynamic content and use the below 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()


{



var userID=prompt('Enter User ID');


if(userID!='' && userID!= undefined ){


var my_dashboardMessageHandler1 = new DashboardMessageHandler("my_unique_id2");


var query=''; //my query


my_dashboardMessageHandler1.publishFilter('incident',query);



}


}


Hi Swamy,



I tried it, it   is not working for dashboardMessageHandler, it works only on dynamic content itseems.