Populating text box from a DME Call

 7 Replies
 0 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
Ahmer
Basic Member Send Private Message
Posts: 4
Basic Member
We have a custom text box in BL 31.3 we used them to store additional description values in the custom tables.
Now we want to populate those values in the text boxes after DME call retrieved those values from the database by clicking on Inquiry.
DME call fetches two rows, I need to populate a text box with these values in a textbox twice for line nbr 1 and line nbr 2.
Below is the code, we are using

function FORM_OnAfterTransaction(rowNum)
{
var vComp = lawForm.getFormValue("text1");
var vInv = lawForm.getFormValue("text2");
var vCust = lawForm.getFormValue("text3");

//was transaction successful?
if (formState.agsError) return;

for (var rowNum = 0; rowNum < 5; ++rowNum)
{
//get Line Number 
var vLine = lawForm.getDataValue("BUL-LINE-NBR",rowNum);
//alert("Line number is: "+vLine+"; rownumber is "+rowNum);

//reset desc to blank for each detail line

var vDesc  = "";

//Do DME call if there is Line Nbr
if(vLine != "")
{
var s = portalWnd.DMEPath;
s += "?DEV=";
s += "&FILE=BLRILUF";
s += "&FIELD=DESCRIPTION";
s += "&INDEX=BLRSET1";
s += "&KEY=";
s += vComp;
s += "=";
s += vCust;
s += "=";
s += vInv;
s += "=";
s += vLine;     
s += "&XCOLS=TRUE&XKEYS=TRUE&XRELS=TRUE&XCOUNT=TRUE&XIDA=TRUE&OUT=XML";    
//alert("string is "+s)
 
//send DME call to server
var vDMEInfo = portalWnd.httpRequest(s);
//alert(vDMEInfo.xml);
// DME Error Checking
if(!vDMEInfo||vDMEInfo.status)
{
var msg="Error calling DME, ";
msg += (vDMEInfo? "(status code): "+vDMEInfo.status: "bad server response.");
alert(msg);
return true;
}
   
//create an XML object to contain the DME data
var vObjDMEXML = new portalWnd.DataStorage(vDMEInfo);
var vRecords=vObjDMEXML.document.getElementsByTagName("RECORD");
   
if (vRecords.length != 0)
{
var vCols = vRecords[0].getElementsByTagName("COL");
var vDesc = vCols[0].firstChild.data;
lawForm.setFormValue("text12",vDesc,rowNum);

}
}

}
return true;
}

 
David Williams
Veteran Member Send Private Message
Posts: 1127
Veteran Member
Is there a question here?
David Williams
Ahmer
Basic Member Send Private Message
Posts: 4
Basic Member
Yes this is a question, we have debugged it and we saw appropriate values returned in XML however there are two record returned and values are only being written in the first row of the form.In other words it appears that the third parameters of setFormvalue (one that specify row number) is being ignored.The end result is the only the value from the second record is populated.
Robert Spurr
Veteran Member Send Private Message
Posts: 130
Veteran Member
I assume that you are getting data back and that you have validated. I only ask because I noticed that your DME call doesn't specify a productline. I'm not an expert and this could work, I've just never seen a DME call that didn't specify a productline so I thought I'd point it out. I did some comparision to code I have and while I'm not updating row information the concept is the same and I didn't see anything that raised a red flag.

Sample of my DME call in regards to the productline concern:

var vCompany = lawForm.getDataValue("ITL-COMPANY");
var vLocation = lawForm.getDataValue("ITL-LOCATION");
var vItem = lawForm.getDataValue("ITL-ITEM");
var strPDL = portalWnd.oUserProfile.getAttribute("productline");

//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);
Ahmer
Basic Member Send Private Message
Posts: 4
Basic Member
yes, we are getting the correct data back by looking at the xml.The only problem is not writing to the correct row.
Robert Spurr
Veteran Member Send Private Message
Posts: 130
Veteran Member
I know I've had issues when adding objects like text boxes to rows. What I've noticed is that the field number is not set like other objects. You could check and update to something like _f99r0. basically add the the "r0" not sure if the issue is that it can only find a single occurance even though you can see them. Just a thought.
David Williams
Veteran Member Send Private Message
Posts: 1127
Veteran Member
I think Robert S has given you the answer you need. Go into your Source code and find the reference for your text12 field and add the r0 to the end of your field number; like nbr="_f23r0"
Save your changes and you should then be able to reference the field with a row number. If that doesn't work, let me know.
David Williams
Ahmer
Basic Member Send Private Message
Posts: 4
Basic Member
Thanks David and Robert.

The solution worked.