Try Microsoft Edge
A fast and secure browser that's designed for Windows 10
I ran into this issue. I've a custom table that needs to store an address thus I've added a foreign key to the LogisticsPostalAddress Table. I've added this field to a form and set the replacementGroup property of the control to LocationReference, like SalesTable form.
Until now everething works as expected. I can view all the adresses in my form wihtout problems. The issue arises when there is a modification in one of the addresses (like the street) that are stored on my custom table.
After someone modifies one of the used addresses (no matter wich field), the records that use this address start displaying "Unknown" on the reference group control.
The RecIds stored in the custom table are not modified and are correct. The strange this is that if I go the "View Details" on one of this "Unknown" values the address is opened correctly.
Any ideas what I'm missing?
Thanks in advanced!
the LogisticsPostalAddress table is date-effective. If you modify a record
- the new content will be created in a new record
- the record you're editing will be set to closed (ValidTo = now)
- the new record will have a validFrom date = now
The new record has a new recId as well, of course.
My bet is that your table's record still points to the old RecId, which relates to record that's not valid "today" anymore, therefore it's shown as unknown.
The question of course is now, what's the correct behaviour in your case.
- Shall the old address still be valid?
- Shall a new address be selected? By the user? Automatically?
- something else
I hope this helps getting you to the root of your problem, even if I cannot answer the followup questions ;-)
Hi Annethe thank you for answering and you are totally right!
I realized the same after posting this, sometimes explaining your problems gives you some light to find the answer :)
I was writing what I found an then Dynamics Community went under maintainance, yeah I know today is my lucky day...
Fortunately I saved what I was going to post:
Ok, I learned something today, LogisticsPostalAddress is a time effective table (I can't belive I didn't see this before). After a modification on an address AX creates a new record thus it can't resolve the reference because is not valid anymore.
I looked again on salesTable Form and I found how Microsoft manage this.
First of all I added the ReferenceDataSource on my custom table data source.
On the init Method of the form I found this lines
And in the init method on SalesTable dataSource this ones
All this makes a lot of sense now.
The only problem I have now is that this this field is in a "classic" form and a List Page and I cannot find a way to achieve the same on a List Page because I can't add a reference data source.
I was thinking that I could add it from code in the interaction class on the initalizeQuery method, but don't know how yet. Any suggestions?
And again thank you for your time!
Hi again :-)
Can you add LogisticsPostalAddress as a datasource to the query you use for your ListPage (probably an outer join below your main datasource)?
Then, your ListPage form will have an additional datasource node. On that node you can set the validTimeState properties.
And, in the initalizeQuery() method of the interaction class, you set the validTimeStateDateTimeRange() as you showed above.
Hope this helps
Hi Annette, great idea! It worked!
I added LogisticsPostalAddress as a datasource to my query and used the initializeQuery() method to init the ranges.
The only problem I ran into was that the validTimeStateDateTimeRange method and the others are FormDataSource's methods. I couldn't find a way to get the FormDataSource from the query parameter in initalializeQuery(). I ended up using the active record to get the FormDataSource like this
public void initializeQuery(Query _query)
fds = this.listPage().activeRecord('LogisticsPostalAddress_1').dataSource();
I don't know if there is a "cleaner" way to do this, but at least it worked!
Thank you very much! You were a time saver!
great, glad to be of help.
You can call the validTimeStateDateTimeRange method directly on the parameter _query. As a matter of fact, you do that too, but with a much "longer path" to get there.
Yeah, I don't like that you set the ranges to the whole query. I don't know how it could be done if I had two date effective datasources and wanted to set different ranges to each one. As this is not the case I'll probably follow your advice.
Thanks again and have a great day!