Skip to main content

Notifications

Microsoft Dynamics AX forum
Answered

Insert Record to InventSum and InventTrans

Posted on by

Hi All,

Anyone can give me some guide or tips on this scenario.

I delete the record in InventTrans and InventSum.

Now I am trying to create a Job to insert it back to InventTrans and InventSum as well using the record in SalesLine.

 

Anyone can help me.

Thanks in Advance

Ariston

 

  • dolee Profile Picture
    dolee 11,279 on at
    Re: Insert Record to InventSum and InventTrans

    Lol

  • Ariston J. Profile Picture
    Ariston J. on at
    Re: Insert Record to InventSum and InventTrans

    haha

  • Verified answer
    Joris dG Profile Picture
    Joris dG 17,775 on at
    Re: Insert Record to InventSum and InventTrans

    Andi, you crack me up :-)

    I've seen the same picture with the phrase "one does not simply implement vanilla AX"...

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: Insert Record to InventSum and InventTrans

    [View:http://cdn.memegenerator.net/instances/400x/34903227.jpg]  

    :)

  • Suggested answer
    dolee Profile Picture
    dolee 11,279 on at
    Re: Insert Record to InventSum and InventTrans

    Hi Ariston,

    If your sales Lines has not been received/posted with anything, then delete that sales lines and insert them again.

    Otherwise.....I would +1 on Joris suggestion of restore a backup and rethink.

    For your reference, AX uses a bunch of classes to manipulate the inventTrans due to complex logic and connections to different module and business processes. Which is the reason why manipulating them directly has been a No-no from day 1.

  • Ariston J. Profile Picture
    Ariston J. on at
    Re: Insert Record to InventSum and InventTrans

    Thanks Joris,

    But my Consultant want to do that I think he want to do something on that.

    These are the scenario.

    In SQL my Consultant delete the record in INVENTTRANS and INVENTSUM.

    Then he want to put it back using Job in AX.

    I have a valid SALESLINE record with InventTransID. No need to create new InventTransID when I push it back to INVENTTRANS and INVENTSUM also just push all the record to that table.

    This is my sample job code do you think this is wrong? do I need to put some classes or methods?

    static void Job24(Args _args)
    {
        SalesLine   salesLine;
        InventTrans inventTrans;
        ;
        while select salesLine where
        salesLine.SalesId == 'SO1208/0001'
        {
            select forupdate inventTrans;
                inventTrans.InventTransId   = salesLine.InventTransId;
                inventTrans.ItemId          = salesLine.ItemId;
                inventTrans.Qty             = salesLine.SalesQty;
            inventTrans.insert();
        }
    }

  • Verified answer
    Joris dG Profile Picture
    Joris dG 17,775 on at
    Re: Insert Record to InventSum and InventTrans

    Manipulating records in inventtrans and inventsum directly is a HUGE violation of AX data. Never, ever, ever, ever, ever, ever, ever update, insert or delete records in these tables yourself. There is ALWAYS a way to use the front-end transaction (salesline, journaltrans, etc) to achieve what you wish to do.

    My advice: restore your database and rethink what you are trying to achieve.

Helpful resources

Quick Links

Dynamics 365 Community Update

Welcome to the inaugural Community Platform Update. As part of our commitment to…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Community Spotlight of the Month

Kudos to Mohana Yadav!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,142 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,979 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans