View Full Version: Design Studio 3.1.6 Script Example Problem

LawsonTalk > BCI, Processflow and Addins > Design Studio 3.1.6 Script Example Problem



Title: Design Studio 3.1.6 Script Example Problem
Description: oXMLObj is undefined


maddiew - February 9, 2007 09:26 PM (GMT)
Attempting to use script example from Design Studio User Guide "When a new record add a record in two applications, when record is added in AP10, this script automatically adds the same record in PO10". When I try to add a new vendor record I receive error message "oXMLObj is undefined. Here is the code:


function FORM_OnAfterTransaction(data)
{
// was transaction successful?
if (formState.agsError) return;
if (data.selectSingleNode("//_f1").text == "A")
{
var sVendorGroup = lawForm.getDataValue("VEN-VENDOR-GROUP");
var sVendor = lawForm.getMessage();
sVendor = sVendor.substr(sVendor.indexOf(" ") + 1, sVendor.length);
sVendor = sVendor.substr(0, sVendor.indexOf(" "));

var sAGSCall = "http://myserver/cgi-lawson/ags.exe?_PDL=";
sAGSCall += top.lawsonPortal.getUserVariable("PRODLINE");
sAGSCall += "&_TKN=PO10.1&_EVT=ADD&_LFN=ALL&_TDS=IGNORE&FC=A";
sAGSCall += "&POV-VENDOR-GROUP=" + sVendorGroup;
sAGSCall += "&POV-VENDOR=" + sVendor;
sAGSCall += "&_OUT=XML&_EOT=TRUE";

var sAGSInfo = top.httpRequest(sAGSCall);
if (!sAGSInfo || sAGSInfo.status > 400)
return;

var sFldNbr = oXMLObj.selectSingleNode("//FldNbr").text;
var sMsgNbr = oXMLObj.selectSingleNode("//MsgNbr").text;
var sMessage = oXMLObj.selectSingleNode("//Message").text;
alert(sFldNbr + ", " + sMessage + ", " + sMsgNbr);
}

}


Please help...Lawson won't.

Phil Feller - February 12, 2007 02:37 PM (GMT)
The example seems to have left out a necessary statement:
CODE
// create an XML object to contain the AGS data
var oXMLObj = new top.DataStorage(sAGSInfo);


The function DataStorage is a Lawson-supplied (in v3.js) wrapper around the native IE/MSXML and Mozilla methods for creating a DOM parser from the XML data returned by AGS request.

maddiew - February 12, 2007 05:01 PM (GMT)
Thanks a bunch for the reply, I added the code but I received this error:
"Object doesn't suppor this property or method" but I do see that it added the vendor record and I can access it via PO10. Do you know why I would receive this message?

Phil Feller - February 13, 2007 12:08 AM (GMT)
The easiest way to fix this might be to remove the code that I suggested, plus some of the Lawson sample code that you might not need.

Look at the code:
CODE
var sFldNbr = oXMLObj.selectSingleNode("//FldNbr").text;
var sMsgNbr = oXMLObj.selectSingleNode("//MsgNbr").text;
var sMessage = oXMLObj.selectSingleNode("//Message").text;
alert(sFldNbr + ", " + sMessage + ", " + sMsgNbr);


This picks the field number, message, and message number out of the XML that is returned by the PO10 AGS request. It then pops up a JavaScript alert box with this information. Do you want this to happen? If not, you can remove these four lines plus the code that I supplied.




Hosted for free by InvisionFree