web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Reference Groups - Unknown value

(0) ShareShare
ReportReport
Posted on by

Hi everyone!

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!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Annette Theissen Profile Picture
    1,653 on at
    RE: Reference Groups - Unknown value

    Hi Martín,

    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 ;-)

    Kind regards,

    Annette

  • Verified answer
    Martín Flores Profile Picture
    on at
    RE: Reference Groups - Unknown value

    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 

    logisticsPostalAddressDeliveryHeader_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, ValidFrom));
    
        logisticsPostalAddressDeliveryHeader_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, ValidTo));
    
        logisticsPostalAddressDeliveryHeader_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, CountryRegionId))

    And in the init method on SalesTable dataSource this ones

    logisticsPostalAddressDeliveryHeader_ds.validTimeStateUpdate(ValidTimeStateUpdate::Correction); 
    logisticsPostalAddressDeliveryHeader_ds.query().validTimeStateDateTimeRange(DateTimeUtil::minValue(), DateTimeUtil::maxValue());
    

    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!

     

     

  • Verified answer
    Annette Theissen Profile Picture
    1,653 on at
    RE: Reference Groups - Unknown value

    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

    Annette

  • Verified answer
    Martín Flores Profile Picture
    on at
    RE: Reference Groups - Unknown value

    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)
    {
        FormDataSource fds;
    
        super(_query);
    
        fds = this.listPage().activeRecord('LogisticsPostalAddress_1').dataSource();
        
        fds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, ValidFrom));
        fds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, ValidTo));
        fds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, CountryRegionId));
    
        fds.validTimeStateUpdate(ValidTimeStateUpdate::Correction);
        fds.query().validTimeStateDateTimeRange(DateTimeUtil::minValue(), DateTimeUtil::maxValue());
    
    }


    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!

  • Annette Theissen Profile Picture
    1,653 on at
    RE: Reference Groups - Unknown value

    Hi Martin,

    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.

    Have fun!

    Annette

  • Martín Flores Profile Picture
    on at
    RE: Reference Groups - Unknown value

    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!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans