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)

Custom AIF service issue

(0) ShareShare
ReportReport
Posted on by 692

Hi

I have generated a new AIF service using a query consisting of a query based on the tables WHSLoadTable and WHSLoadLine with a relation of WHSLoadTable.LoadId == WHSLoadLine.LoadId with the AIF wizard.

When I try to create a new load with the service it fails. I have debugged the issue and found that it is failing because it is trying to save the WHSLoadLine data before the WHSLoadTable data. This causes an issue because it is saying that the LoadId in the WHSLoadLine does not exist in the WHSLoadTable table.

Does anyone know how to resolve this issue please?

Any help would be much appreciated.

Thanks,

Joe

*This post is locked for comments

I have the same question (0)
  • Verified answer
    JoeBrewer Profile Picture
    692 on at
    RE: Custom AIF service issue

    I found the solution in this blog post: https://dynamicsaxposed.wordpress.com/tag/ax-2012-aif/

    This pattern can be found in the prepareForSaveExtended method of the AxdBankStmt class - search for the text "Ensure Document record is saved before any of its dependent child records". It's also used in some of the other Axd classes - search for the text "AxdRecordProcessingContext::BeforeChildRecordProcessed" in the Axd classes to find more examples.

  • JoeBrewer Profile Picture
    692 on at
    RE: Custom AIF service issue

    Hi ievgen

    I havent got easy access to the code at the moment. It was mostly generated by the wizard - the only thing that I added was to pass the LoadId from the WHSLoadTable to the WHSLoadLine just like the sales quotation that you mentioned.

    The problem is though that AX is trying to insert the WHSLoadLine record before it inserts the WHSLoadTable record. If there was a way of specifying the order that the records are inserted, or to remove the constraints on the table for the service that would be the answer, but I cant see a standard way that AIF does this.

    Thanks,

    Joe

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at
    RE: Custom AIF service issue

    It's hard to help you without seeing your code.

    You can look at AxdSalesQuotation class as an example, there in method prepareForSave() quotationId from header is manually passed to lines so you need to do the same because there is no "magic" that can do it for you.

  • JoeBrewer Profile Picture
    692 on at
    RE: Custom AIF service issue

    Hi ievgen

    The WHSLoadTable is the parent table in the query

    Thanks,

    Joe

  • Mea_ Profile Picture
    60,284 on at
    RE: Custom AIF service issue

    Hey Joe Brewer,

    Can you show us how your query was build ? I think you can have this issues if lines are parent for load table.

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
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans