I'm looking for a way to associate an order number to an obs term in VFE. Currently I have a function that will give me the Order Description, Order Start date and Order Number of all active orders in a drop down. I am limiting the drop down to allow one selection on the VFE form. I need to extract out that Order Number (position 25) and add it as a value to an obs term called ORDERNUMBER.
I have reviewed the substring symbols but I'm not sure how to get them to work for my needs since the order number will not always start in the same position, nor will it always be the same length.
Any help is appreciated.
Here is my function I'm using in the function view:
{
fn ordList(strList)
{
local lCounter
local lOrdArray
local lStart
local lBuffer
local lFormattedList = ""
lOrdArray = getfield(strList, "|", "")
for lCounter = 1, lCounter <= size(lOrdArray), lCounter = lCounter + 1 do
lOrdArray[lCounter] = getfield(lOrdArray [lCounter], "^", "")
lBuffer = ReplaceStr(lOrdArray [lCounter][1], ",", ";")
lFormattedList = lFormattedList + lBuffer + if lOrdArray [lCounter][4] == "" then "" else " Start: " + lOrdArray [lCounter][4] endif + if lOrdArray [lCounter][25] == "" then "" else " Order ID: " + lOrdArray [lCounter][25] endif + ","
endfor
if (lCounter > 1) then
lFormattedList = remove(lFormattedList, size(lFormattedList))
endif
return (lFormattedList)
}
}
Here is what I'm calling in the drop down list:
{ordList(ORDERS_PRIOR("Delimited"))}
You have almost answered your question. Using the same ORDERS_PRIOR, write another function where you match the selected order name and date, then grab index 25 and store it in the obsterm using obsnow(obsname,varassignedtoindex25).
fn fnStoreOrderNumber(strList,strSelectedOrder)
{
local retStr = ""
local strTemp = ""
local strBuf = ""
local i
strTemp = getfield(strList,"|","")
for i = 1, i <= size(strTemp), i = i + 1 do
strTemp[i] = getfield(strTemp[i],"^","")
strBuf = replacestr(strTemp[i][1],",",";")
if strTemp[i][4] <> "" then
strBuf = strBuf + " Start: " + strTemp[i][4]
else ""
endif
if strTemp[i][25] <> "" then
strBuf = strBuf + " OrderID: " + strTemp[i][25]
else ""
endif
if strSelectedOrder == strBuf then
OBSNOW(obstermName,strTemp[i][25])
break
else ""
endif
endfor
return ""
}
}
Call the function with:
fnStoreOrderNumber(ORDERS_PRIOR("delimited"),variableNameOfTheDropdown)
Hope that helps!
Lee,
Thanks so much for the assist. I think I'm doing something wrong though.
I placed the second function (your code) in the function view as follows:
{
fn fnStoreOrderNumber(strList,strSelectedOrder)
{
local retStr = ""
local strTemp = ""
local strBuf = ""
local i
strTemp = getfield(strList,"|","")
for i = 1, i <= size(strTemp), i = i + 1 do
strTemp[i] = getfield(strTemp[i],"^","")
strBuf = replacestr(strTemp[i][1],",",";")
if strTemp[i][4] <> "" then
strBuf = strBuf + " Start: " + strTemp[i][4]
else ""
endif
if strTemp[i][25] <> "" then
strBuf = strBuf + " OrderID: " + strTemp[i][25]
else ""
endif
if strSelectedOrder == strBuf then
OBSNOW("ORDERNUMBER",strTemp[i][25])
break
else ""
endif
endfor
return ""
}
}
Then I added a data dispay with MEL expression connection type with:
{fnStoreOrderNumber(ORDERS_PRIOR("delimited"),DOCUMENT.SELECT_ASSOC)}
When I select the order from the drop-down (first function) nothing happens in the data display, and the obs term ORDERNUMBER is not added. Any suggestions what I may be doing wrong?
Check the MEL trace and see if the order names are matching. If not, you might need to adjust the code a bit to make it do so.