Iron Speed Technical Forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
scrimej

Avatar / Picture

MVP Developer
Registered:
Posts: 236
Reply with quote  #1 
A half-dozen times yesterday I synchronized database schema, recompiled application and redeployed in order to fix an issue where 1 of foreign key fields keeps reverting to displaying the primary key and not the "display as" value.

It works for an undetermined amount of time and then eventually it always goes back to displaying the primary key instead of the "display as" value.

Yesterday, the last time I dropped the relationship in the database, recreated, synched the schema and redeployed and it worked for several hours.  This morning is was also fine.  I just went to make sure it was going to remain fixed and now it is back to showing the primary key instead of the "display as".....

IDEAS?
dingjing

Avatar / Picture

MVP Developer
Registered:
Posts: 256
Reply with quote  #2 
It changes "display as" value without you touching any of the code? Or does it change while you are making changes to unrelated code.

I recommend using a view instead of direct use of the underlying table to avoid "display as". 
pinbot

Avatar / Picture

MVP Consultant
Registered:
Posts: 968
Reply with quote  #3 
What type is your PK?

I saw something like that on a GUID PK in one of my apps.  I dropped and readded the field to the page and it seemed to work after that.

I'll have to go check it again now....



__________________
C. Bryan Patrick II
Iron Speed Designer MVP Consultant
Pseudo Consulting
scrimej

Avatar / Picture

MVP Developer
Registered:
Posts: 236
Reply with quote  #4 
This is a live system where it is changing.

I don't have to deploy any updates or make any changes in order for it to work one time and not the next.  It goes from working to not with no updates to the source code or database.
scrimej

Avatar / Picture

MVP Developer
Registered:
Posts: 236
Reply with quote  #5 
It is an Integer, Identity primary key in SQL Server.
scrimej

Avatar / Picture

MVP Developer
Registered:
Posts: 236
Reply with quote  #6 
Jing,

Thanks for the suggestion.  Just trying to make sure I understand your suggestion.

Wouldn't the view require the same FK relationship as the table?  At one point I actually added a virtual foreign key to the table in Iron Speed so I had a foreign key in the table and a virtual foreign key in Iron Speed and it still would eventually revert to displaying the integer key field.
scrimej

Avatar / Picture

MVP Developer
Registered:
Posts: 236
Reply with quote  #7 
Changed to use a view, deployed the update and it displayed correctly until they tried to edit a record and then it reverted to displaying the key field.
dingjing

Avatar / Picture

MVP Developer
Registered:
Posts: 256
Reply with quote  #8 
Resolve all foreign keys within the view. For example, your table has a column CustomerID. You set it to display as Cutomer.Name. You add a CustomerName column to your view. Then put CustomerName, instead of CustomerID, on your page.
pinbot

Avatar / Picture

MVP Consultant
Registered:
Posts: 968
Reply with quote  #9 
Jeremy,

What type of field/page?  Is this on a ShowTable?  or a DDL? Literal?  QuickSelector?  

Is it on an Add/Edit record page?

You don't mention in your original post.


Also, What type of DB?

Could there be an exception reading the lookup table?  IronSpeed might not expand FK lookups on an error.

You might try turning on tracing to see the actual SQL calls when trying to resolve your FK lookups.

__________________
C. Bryan Patrick II
Iron Speed Designer MVP Consultant
Pseudo Consulting
scrimej

Avatar / Picture

MVP Developer
Registered:
Posts: 236
Reply with quote  #10 
Thanks everyone for the tips and advice.  I was able to replicate the problem on my development machine and have coded a workaround that will hopefully eliminate the issue from returning.

For those that care he's the detail of what was happening:

I have a table called "Applicant" that has several child tables.
In the Applicant table I store a default "Town" as a FK relationship to a Town table.

The system was coded so that when they add a new applicant, rather than having them do the data entry in add table grids I would only allow them to add the parent applicant information and then upon save I would direct them to a ShowApplicant page with child tabs for each related table.  From here they could add the appropriate child table information by clicking the table Add button and this would redirect them to the child add table passing the Applicant Foreign Key and setting that field in the Add Child form using the URL("Applicant") function.

So far so good.

Now each child table also has a Foreign Key relationship to Town.  I would populate the Town Foreign Key on the Child table from the "default" value set on the applicant table.  This allowed them to override the Town value on any child item record as necessary but also gave them a default value which was correct a majority of the time.

So here's where things went bad.

When I clicked the Add button on the Child table and redirected to the Child Add Page.  The primary foreign key relationship from the child table to the Applicant was set using the url property.  At this time I also set the Child override Foreign Key value by using a formula on "Initialize Value when Adding Record".  The formula that I used was  
GetColumnValue("Applicant", URL("Applicant"), "FK_Towns_MapNo") 

This performed as expected and set the dropdownlist to the default foreign key value in the Applicant parent table.  By passing the Town key with the Applicant key on the ShowApplicant page to each corresponding Add<Child>Record page and then setting the "Initialize Value when Adding Record" formula to URL("Towns") instead of using GetColumnValue the issue seems to have been resolved.

If you have made it this far and understood all of that information then thanks for taking the time.  Perhaps I should have returned the DisplayAs from my view as Jing suggested and used that as the value to initialize my dropdown with.  Or perhaps I needed to use a .ToString on the above GetColumnValue.  In any event, the sure fire way to avoid this is to simply pass the value in a query string and initialize the field using the URL() function.



smithm

Registered:
Posts: 35
Reply with quote  #11 
I've always had problems with "Display As" for any key field since ISD 7. Even header labels would show as "= 'FieldNameID'" instead of "FieldName", including equal sign and quotes. I resorted to doing Ding Jing's suggestion a while back, using only views when displaying information, and every view has both the FK ID field and the actual value. It makes for some slightly messy views, but allows me absolute control over information displayed.
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.

Download Iron Speed Designer

Terms of Service Privacy Statement