Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Is business logic called when inserting records with AIF

Posted on by 459

We are trying to inserting records in ForecastSales table using using an AIF-service that we built by our self.

The service gets triggered and a record is inserted in the ForecastSales table, however some fields are not populated. Are you supposed to write code to trigger business logic (code) to have all required fields updated, or should the AIF to that automatically? When I insert a record manually in the table some fileds are updated, so I hoped the create method in the AIF service replicated a manual insert.

Thanks in advance.

*This post is locked for comments

  • HenkeNord Profile Picture
    HenkeNord 459 on at
    RE: Is business logic called when inserting records with AIF

    After CIL-compilation I got most parts to work. However I have a problem setting correct inventdim. I can provide an ConfigId in the xml-file, and I know it gets verified (if I enter a configId that's not in the system I gen an error message). The problem is that the InventDim on the forecastSales-row isn't updated. The config field is nested in the xml-file like this.

           <ForecastSales class="entity">

     <Currency>SEK</Currency>

             <CustAccountId>3000</CustAccountId>

     <ItemId>ABC123</ItemId>

             <ModelId>VP</ModelId>

             <SalesQty>25</SalesQty>

             <StartDate>2019-05-28</StartDate>

             <InventDim class="entity">

       <ConfigId>A</ConfigId>

     </InventDim>        

           </ForecastSales>

    Do I have to manually code something to have the forecast row updated?

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Is business logic called when inserting records with AIF

    You don't need to activate anything to call settablefields and it should call all set* methods. As you can see first thing in the set method is to check that parm method has not been called, so AX should call all set methods each time.

    It obviously uses CIL so check that you built it.

  • HenkeNord Profile Picture
    HenkeNord 459 on at
    RE: Is business logic called when inserting records with AIF

    One more thins, Ievgen. It doesn't seams like my set-methods gets called. I cannot even see that setTableFields-method is called. Do I have to "activate" something to have it called?

  • HenkeNord Profile Picture
    HenkeNord 459 on at
    RE: Is business logic called when inserting records with AIF

    Do you know if the initvalue-method (on the table) is supposed to be called when a record is inserted?

  • HenkeNord Profile Picture
    HenkeNord 459 on at
    RE: Is business logic called when inserting records with AIF

    Yes, I saw that. Good thanks, I'll try...

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Is business logic called when inserting records with AIF

    Regeneration won't help. AX does not know what code to put there, so you will have to manually create set methods for each parameter you want to have defaulting logic. Then you need to add calls to them into setTableFields() method in specific order as shown in documentation.

  • HenkeNord Profile Picture
    HenkeNord 459 on at
    RE: Is business logic called when inserting records with AIF

    Thanks Ievgen, that helped a lot, though I think you mean Ax<Table> class. My AxForecastSales class hasn't got any Set-methods. I'll regenerate that and see if it works. I also found good code example in AxSalesLine.SetDefaultDimension that I can use.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Is business logic called when inserting records with AIF

    Axd<Table> class has 2 sets of methods parm* and set*. Set methods are called when there is no value in inbound message (note empty value still a value). You will write all defaulting logic in set methods, here is documentation with examples docs.microsoft.com/.../about-ax-table-classes

    And then open any existing class, for example, sales order and see how it is done.

  • HenkeNord Profile Picture
    HenkeNord 459 on at
    RE: Is business logic called when inserting records with AIF

    No the fields are not in the parameters and some of them I doubt will be able to have there. For example you could have default invent locations on the items in AX. Information the exporting system doesn't know anything about. But the main question is: Is any business logic called when inserting records with AIF? I mean methods like datatable.initValue() and datatable.insert(). Otherwise, is there a way to add logic that calls this methods in some of the AIF-service classes?"

  • HenkeNord Profile Picture
    HenkeNord 459 on at
    RE: Is business logic called when inserting records with AIF

    No, I mean inserting directly into the table in the AOT. I thought that was as close as inserting records with the AIF I could get.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans