AnsweredAssumed Answered

Odd behavior with FieldNames function

Question asked by Mike_Mitchell Expert on Apr 1, 2016
Latest reply on Apr 3, 2016 by electon

Good day, all. I have a system that needs to save a list of fields into a field. For purposes of abstraction, I'm using the FieldNames function to assemble the list of fields. The calculation looks like this:

 

Let ( [

createTSFieldName  = GetFieldName ( createTS ) ;

tableName = Left ( createTSFieldName ; Position ( createTSFieldName ; "::" ; 1 ; 1 ) - 1 ) ;

fields = FieldNames ( "" ; tableName & "_syncFields" )

] ;

 

Case ( not IsEmpty ( modifyTS ) ; fields )

 

)

 

It's used as an auto-enter calculation so it can be indexed later. Now, this works a treat when I create or modify a record from that table. It also works when I create or modify a record from one relationship away via a portal or directly through the relationship.

 

However, for some odd reason I can't fathom, this is completely failing when I attempt to modify a field from two relationships away. The relational structure looks like this:

 

     globalsTable --< virtualTable --- targetTable

 

The relationship between the globals table and the virtual table is based on a constant calculation field (same on every record). It's indexed on both sides. The relationship between the virtual table and the target table is an unstored calculation of the Virtual List type - GetValue ( $$someVariable ; row ). This is a key field to the target table.

 

I have a portal in globalsTable that points to virtualTable. When I use something like:

 

     Set Field [ targetTable ; someField ]

 

from the context of globalsTable, the field comes up null. When I do the same thing from the context of virtualTable, it works.

 

Other notes:

 

Yes, the layout "tableName_syncFields" exists. Again, it works from targetTable and from virtualTable, so I know it's seeing the list of fields.

The field shows some odd behavior between the time the field is set and the time you commit the record from the context of globalsTable. The calculation actually changes on commit.

 

I'm obviously missing something here. Why would this function fail from two relational hops away, but function fine from the local context or one hop away? And, more importantly, what can I do about it?

 

TIA

 

Mike

Outcomes