Auto-Refresh/Auto-Save

I am pretty sure most of us here are sports buff. Me being an ardent cricket lover used to spend 4-5 hours on cricinfo. Life is really cool when the scoreboard says the latest score automatically in every 2 minutes. It would have been real killing if someone had to manually click on refresh button to get the latest updates or for money matters latest update on stocks every n minute.

One of my friend recently experienced same problem while dealing with service requests. The scenario was to have auto refresh of the SR list applet pool in every 2 minutes so that users can pick request to work on, as requests were coming from some other portal. Once again support web was our alley. A little bit of browser script and deal was done. Following steps were taken to achieve this:

1 - Query applet for which auto-refresh is required. Open Browser Script editor. Jump on the Applet_Load event and put below script:

function Applet_Load ()
{
//To Invoke AutoRefresh function in every 2 minutes
setTimeout("AutoRefresh()", 120000);
}

2 - Create a function "AutoRefresh()" in the general section of applet with following code:

function AutoRefresh()
{
var sApplet = theApplication().FindApplet("Service Request List Applet");
sApplet.InvokeMethod("ExecuteQuery"); // this is used to refresh current applet
// condition that ensures that it happens in the desired view only, if applet is being used in other views
if(theApplication().GetProfileAttr("ActiveViewName") == "Personal Service Request List View")
{
setTimeout("AutoRefresh()", 120000); // this is to invoke the above function recursively
}
}

Similarly Auto-Save functionality could be achieved by using following function:

function AutoSave()
{
var sApplet = theApplication().FindApplet("Service Request List Applet");
sApplet.InvokeMethod("WriteRecord"); // this is used to write Record
setTimeout("AutoSave()", 120000); // this is to invoke the above function recursively
}

The main crux here is standard javascript function which takes two input parameters.

setTimeout(String(Function name), Number(Delay))

Function name - Name of the function to be executed
Delay - Number representing delay in milliseconds before the specified function will be called.

The same could be achieved by having a button on the List applet but then why to go for beans when you can have Cake.


תגובות

פוסטים פופולריים מהבלוג הזה

Access control with EAI Siebel Adapter

Profile Attributes and Open UI

SBL-SVC-00281