Process Mapping Logo

Process Mapping - Forums

Sharing 19 years of knowledge and experience

 
Metastorm BPM forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
Jas

Senior Veteran
Registered:
Posts: 429
Reply with quote  #1 
Hi All

I seem to remember doing this before for another project but cant seem to think straight now. I have a button which updates a field i.e.

When Button Pressed
%x:= %SelectSQL()

What I need to do is on the field where %x is assigned run a client script if that makes any sense.

Jas

0
mohnshine

Avatar / Picture

Senior Veteran
Registered:
Posts: 270
Reply with quote  #2 

Since you are updating the field server side and want to run a script on the client side after the server side code completes, you may find the following function useful
 
/*
This function requires a check field called chkServerActionComplete
The server action should set this to true on completion of the server action
The field should be set to is dependent
*/
var wfsTimeOut = null;
var wfsEvalFunction = null;

function WaitForServer(EvalFunction)
{
    try
    {
        if(wfsTimeOut == null)
        {
            eworkSetField('chkServerActionComplete','','false' );
            if(EvalFunction==null || EvalFunction=="") return;
            wfsEvalFunction=EvalFunction;
            wfsTimeOut = window.setTimeout('WaitForServer()',5);
        }
        else
        {
            if(eworkGetField('chkServerActionComplete','')==0)
            {
                wfsTimeOut = window.setTimeout('WaitForServer()',5);
            }
            else
            {
                // an additional setTimeout is required for reliable performance
                // 300 is minimum tested value for reliable performance
                window.setTimeout(wfsEvalFunction,500);
                wfsEvalFunction=null;
                wfsTimeOut=null;
            }
        }
    }
    catch (ex) {alert(ex.description);}
}


Call the function in the button click event code


function UpdateButtonClick()
{
// do stuff
alert('doing stuff before server code');
 
// start waiting for server code completion
WaitForServer("alert('doing stuff after server code');")
}


__________________
Your best practice does not conform with my best practice.
0
Jas

Senior Veteran
Registered:
Posts: 429
Reply with quote  #3 
mohnshine
I seem to recall hooking into the fields onchange event and doing a button click or something.
 
(pain in the ass not being allowed to copy your own code from a client site).

 

Jas



0
Jas

Senior Veteran
Registered:
Posts: 429
Reply with quote  #4 

sorry i'm being my stupid self (again). Your right i'm trying to run a client script after a server event.

0
tspafford

Senior Member
Registered:
Posts: 64
Reply with quote  #5 
I have a client script that I would like to have run after a server button click, so I am trying your script.

I have the pre and post alert messages and they appear, but the function wrapped in WaitForServer does not run

It runs fine from a Client button as:

OnClick=loadIFrameSrc (document.getElementById("txt_SharePointFolder").value)&Language=JScript 


This populates an iFrame with a Sharepoint page

txt_SharepointFolder is a URL location computed in server button

The UpdateButtonClick() code I am using (tied to server button) is:

function UpdateButtonClick()
{
// do stuff
alert('doing stuff before server code');

// start waiting for server code completion
alert('doing stuff after server code');
WaitForServer(loadIFrameSrc (document.getElementById("txt_SharePointFolder").value));
}


No js errors on form when loaded.

alert messages both appear, but code does not populate iFrame

Thanks

0
tspafford

Senior Member
Registered:
Posts: 64
Reply with quote  #6 
Found the problem, needed to escape the inside double quotes

function UpdateButtonClick()
{
// do stuff
alert('doing stuff before server code');

// start waiting for server code completion
alert('doing stuff after server code');
WaitForServer("loadIFrameSrc (document.getElementById(\"txt_SharePointFolder\").value);")
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:


Create your own forum with Website Toolbox!