Assisted Input – Bug in WEBDEV is Caption and StoredValue are the same

A while back I wrote about using the wxFileManager in combination with the Assisted Input feature of WINDEV / WEBDEV to provide a nice predictive input control, if you missed that post check it out here.

Today I discovered a interesting bug with this in WEBDEV Note: I have tested this and it works as expected in WINDEV, the issue is only with WEBDEV.

A quick review, as the user types in the edit control, we rebuild the list of values available using the AssistedInputAdd function.

Below is the an example. Notice the AssistedInputAdd function takes 3 parameters, the edit control we are working with, the caption (or display value) and the stored value. In this example I am placing the Contractors name in the caption, which is what the field will be filled with when the user makes a selection. And I am placing the Contractors NameCode, which is a unique ID for the contractor in the stored value. This is what we will actually be writing to the table to link this record to a specific vendor.

PROCEDURE BuildList(LOCAL TypedValue is string)

AssistedInputDeleteAll(edtContactorName)
AssistedInputAdd(edtContactorName,"<Add Contractor Not in List>","<New>")

IF TypedValue = "" THEN
	//Nothing to do
	RETURN
END

NameParts	is array of string	= TypedValue.Split(" ")

SQLStatement	is string
FOR EACH Part OF NameParts
	SQLStatement += [" AND "] + "Name ilike '%[%Part%]%'"
END
mgrContractor.Filterstring	= [
WHERE ([%SQLStatement%]) 
]

mgrContractor.Orderby			= "limit 101"
mgrContractor.FetchData()

FOR EACH tmpRec OF mgrContractor.arrRec
	AssistedInputAdd(edtContactorName,tmpRec.Name,tmpRec.NameCode)
END

In the Select a value in the list of input suggestions event, we get the AssistedInput selected and can work with it. In my example I am calling a procedure set to the value in the database table

PROCEDURE SelectAssistedInput(MySelection is AssistedInput)

SelectValue(MySelection.StoredValue)
savValue = MySelf.Value
ValueSelected = True

PROCEDURE SelectValue(NameCode)

recPaxx.ContractorNameCode	= NameCode

The issue comes into play when the Contractor Name and NameCode happen to be the same value, apparently the AssistedInputAdd function does not include the stored value if it is the same as the caption, which causes my above code to have a blank for the NameCode.

To combat this issue I have had to adjust my SelectAssistedInput procedure as follows

IF MySelection.StoredValue = "" THEN
	MySelection..StoredValue = MySelection.Caption
END
SelectValue(MySelection.StoredValue)
savValue = MySelf.Value
ValueSelected = True

I have submitted this to PCSOFT support and will update this article when I get a response.

Update 3/11/2025

Issue was confirmed by support and submitted to development.

Leave a comment