Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

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

 

*This post is locked for comments

  • 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.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans