Javascript/AGS: Code after AGS call executes too quickly before AGS is complete.

 2 Replies
 0 Subscribed to this topic
 17 Subscribed to this forum
Sort:
Author
Messages
Larry Chough
New Member Send Private Message
Posts: 2
New Member
Hello,

I'm a web developer, but a newbie to Lawson.  My company has a lot of custom web pages derived from ESS.

Is there any convention to make sure the JavaScript code has completed an AGS call before continuing to execute?

I've been running into instances where the code is trying to process data from AGS (or DME), but fails because the AGS call has not yet completed and thus no data to process yet.  I've been trying timeouts, but those aren't 100% reliable.

Any help or insight would be most appreciated.

Thank you very much.

Larry
Robert Spurr
Veteran Member Send Private Message
Posts: 130
Veteran Member
While this is a sample from a design studio modification, it illustrates the steps. This has always worked for me and I've never had an issue of beating the DME or AGS to the punch.


//DME call
var s = "?PROD="+strPDL;
s += "&FILE=ITEMLOC";
s += "&INDEX=ITLSET1&KEY=" + vCompany + "=" + vLocation + "=" + vItem;
s += "&FIELD=LAST-REC-COST;LAST-ISS-COST;SOH-QTY;ALLOCATABLE";
s += "&MAX=1&OUT=XML";

var sReturn = portalWnd.httpRequest(portalWnd.DMEPath + s);

if (!sReturn || sReturn.status)
{
var msg="Error calling DME ";

msg += (sReturn
? "(status code): " + sReturn.status
: "bad server response.");
alert(msg);
return true;
}
Larry Chough
New Member Send Private Message
Posts: 2
New Member
Thanks so much Robert! Much appreciated.