Page 1 of 2

Problem updating lookups in web .net

Posted: Tue Oct 16, 2012 2:57 pm
by czentman
I have been working with code on a dll (in vb.net) that has been working for quite a while. It seems to working fine. Now I'm trying to do some of the same things in web - asp.net, and I can get the lookups data via the lookups api but when I try to update data in the lookup, it errors. I simplified it to a very simple new little table and I'm still getting this error "The entered field code does not correspond to a valid field code". I checked on the field names and they all look correct. Also, it let's me set the row/data up until the lookups.applychanges(table) line of code.

Server Error in '/Generic/TransactionsList/SelectServerTest' Application.
--------------------------------------------------------------------------------

The entered field code does not correspond to a valid field code.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Below is my Code


Dim sps As New SoftPro.Select.Client.SelectServer("http://spapp:8000") ', credentials)
Dim spec As New LookupQuerySpec()
Dim lookups As Lookups = sps.GetService(Of Lookups)()
'On Error Resume Next
Dim LookupsTable As New DataTable
LookupsTable = dsLookups.Tables(0)
sps.EnsureAuthenticated()
spec.Filter = "[Name] like '%%'"
spec.Table = "AbstractorTesting"
spec.SchemaOnly = False
spec.MaxRows = "50"

Dim table As ILookupTable = lookups.QueryTable(spec)
Dim row As ILookupRow, value As ILookupValue ', icol As ILookupColumn
row = table.NewRow()
value = row.NewValue(False, "AAA-Test")
row.Item("Name") = value

table.Rows.Add(row)
lookups.ApplyChanges(table)


Below is my Error
Exception Details: SoftPro.OrderTracking.Common.LookupException: The entered field code does not correspond to a valid field code.

Source Error:


Line 145:
Line 146: table.Rows.Add(row)
Line 147: lookups.ApplyChanges(table)
Line 148:
Line 149: 'lookups.ApplyChanges(ilookuptable)

Source File: \\devwebs\inet\MTAWebDevNEW\Generic\TransactionsList\SelectServerTest\Default.aspx.vb Line: 147

Stack Trace:


[LookupException: The entered field code does not correspond to a valid field code.]
SoftPro.OrderTracking.Client.Lookups.ApplyChanges(IEnumerable`1 tables, LookupTableApplyChangesSettings settings) +2035
SoftPro.OrderTracking.Client.Lookups.ApplyChanges(ILookupTable[] tables) +11
SelectServerTest._Default.SetLookup(String TableName, String FilterField, String FilterText, DataSet dsLookups) in \\devwebs\inet\MTAWebDevNEW\Generic\TransactionsList\SelectServerTest\Default.aspx.vb:147
SelectServerTest._Default.submit_Click(Object sender, EventArgs e) in \\devwebs\inet\MTAWebDevNEW\Generic\TransactionsList\SelectServerTest\Default.aspx.vb:181
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

Please advise.

Re: Problem updating lookups in web .net

Posted: Wed Oct 17, 2012 2:14 pm
by Graham Campbell
I have inspected your code and it seems fine. You do not appear to be making any modifications to the lookup table structure.

Do you have this problem with any other lookup tables or only this one? If it is only this one table then there is probably a problem with the table definition.


The message you are receiving is related to lookup table structure problems. This suggests that the lookup table is already in a bad state which needs to be corrected. To prove this you may consider simply retrieving the table without any rows, modify the description, and then attempt to save. In this case I would expect to see the same failure.

I would expect the same sort of failure when saving the lookup table through the SoftPro Select application. If you can save this lookup table through SoftPro Select but cannot save it through this application then there is a large problem which we should look into, so please let me know if that is the case.


The validations that cause this sort of message come from having a Context/Path combination that does not resolve to a field in the application or from a column type not matching the type of the field in the model.

I would suggest going through all of the ILookupColumn objects in the ILookupTable and casting them to System.ComponentModel.IDataErrorInfo. If you do this you can look at the Error property on this interface to find out which column is having a problem. If we can get details about the properties on that ILookupColumn and the Context of the lookup table then we can figure out what is not mapping correctly.

Re: Problem updating lookups in web .net

Posted: Mon Oct 22, 2012 11:42 am
by czentman
thank you. This was pretty helpful. I tried creating a new table for Abstractor lookup called AbstractorTesting. When adding fields, so lookupcode didn't give the error but Name did and PayeeName did and my custom field "test##" did not give an error. See my response.writes and code along with it. When I try putting more fields in the table via the Select Proform admin system - it seems to work fine. I can add fields and data in the fields for "Name" and "PayeeName". Any additional suggestion why these fields are not working?


This is what my response.write did
table.overlaycontext:Abstractor
LookupCode :
test## :
PayeeName : The entered field code does not correspond to a valid field code.

This is the code
sps.EnsureAuthenticated()
spec.Table = "AbstractorTesting"
spec.SchemaOnly = False

Dim table As ILookupTable = lookups.QueryTable(spec)
Dim row As ILookupRow, value As ILookupValue ', icol As ILookupColumn
Response.Write("<BR>table.overlaycontext:" & table.OverlayContext)
For Each icol In table.Columns
idataErrInf = TryCast(icol, System.ComponentModel.IDataErrorInfo)
Response.Write("<BR>" & icol.Name & " : " & idataErrInf.Error)
Next

Re: Problem updating lookups in web .net

Posted: Mon Oct 22, 2012 1:43 pm
by Graham Campbell
For a lookup table with OverlayContext of "Abstractor" and a column named "PayeeName" we expect the ILookupColumn to have the following:

OverlayPath == ".PayeeName"
Kind == LookupColumnKind.String
Size == 255

Does this data seem accurate to your table?

Re: Problem updating lookups in web .net

Posted: Mon Oct 22, 2012 2:43 pm
by czentman
Response.Write("<BR>table.overlaycontext:" & table.OverlayContext)
For Each icol In table.Columns
idataErrInf = TryCast(icol, System.ComponentModel.IDataErrorInfo)
Response.Write("<BR>" & icol.Name & " : " & idataErrInf.Error & " : " & " ilkupcol.overlaypath:" & icol.OverlayPath & " ilkupcol.kind:" & icol.Kind & " ilkupcol.size:" & icol.Size)
Next

table.overlaycontext:Abstractor
LookupCode : : ilkupcol.overlaypath:.LookupCode ilkupcol.kind:0 ilkupcol.size:255
test## : : ilkupcol.overlaypath:.test## ilkupcol.kind:0 ilkupcol.size:255
.PayeeName : The entered field code does not correspond to a valid field code. : ilkupcol.overlaypath:.PayeeName ilkupcol.kind:0 ilkupcol.size:255
FirstName## : : ilkupcol.overlaypath:.FirstName## ilkupcol.kind:0 ilkupcol.size:255

Re: Problem updating lookups in web .net

Posted: Mon Oct 22, 2012 2:46 pm
by czentman
the ilookupcolumn.kind was coming out as 0 but both for the column that has the error (payeename) and the columns that don't have the error (lookupcode and test## and firstname##). What should I make of it?

Re: Problem updating lookups in web .net

Posted: Mon Oct 22, 2012 2:59 pm
by Graham Campbell
Those look correct. LookupColumnKind.String is an enumeration value which equals 0.

Re: Problem updating lookups in web .net

Posted: Tue Oct 23, 2012 9:27 am
by john.morton
As Graham has pointed out, what you're doing looks correct. I'm going to spend a little time trying to reproduce the behavior you're getting on our side so that I might be able to help you figure out a solution.

Re: Problem updating lookups in web .net

Posted: Tue Oct 23, 2012 12:45 pm
by john.morton
I have reproduced your problem, and I'm working on figuring out the solution. I'm able to do the exact same process in a non-web application though. This being the case, I believe it's a matter of correctly putting the required files (\Data\RuleInstanceDefs\DataItemIDs.xml as an example) in an appropriate place for the web application to find them during run time, and making sure permissions are correctly setup for the web application to be able to access them.

Re: Problem updating lookups in web .net

Posted: Thu Oct 25, 2012 9:35 am
by czentman
It's so strange that I can access the data to get the lookup data and load into a datatable, gridview, or fields on the web but just not set the data. How can I figure out which file we're talking about.