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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to create Inventory Movement Journal through x++

(0) ShareShare
ReportReport
Posted on by 113

Hi Experts,

I want to write a code in X in MAP- InventInventoryJournalEntryMap in method -setJournalNumber with following condition.

1- If the JournalType = Movement and “Original journal No.” field has value.

2- If the existing Journal is “blocked” by system or any user.


If any condition fulfilled then a new journal movement will be created.

I have written a code for this but getting error.

[ExtensionOf(mapstr(InventInventoryJournalEntryMap))]
public final class CreateInventoryMomentJournal_CAP_Extension
{
    public static void setJournalNumber( InventJournalType   _expectedJournalType,int64 _approxNumberOfLines = 1000)
    {
       
       // next setJournalNumber();
           
            InventJournalTable                  inventJournalTable;
            InventJournalTrans                  inventJournalTrans;
            InventJournalNameId                 inventJournalNameId;
            InventJournalName                   inventJournalName;
            InventDim                           inventDim;
            DimensionAttributeValueCombination  dimAttrValueCombo;
            JournalCheckPost                    journalCheckPost;
            int                                 numOfLines = 0;

            select forupdate inventJournalTable
            where inventJournalTable.JournalType == InventJournalType::Movement && inventJournalTable.JournalIdOrignal
            ||  inventJournalTable.SystemBlocked == true;
    
            if (inventJournalTable)
          //  if (( inventJournalTable.JournalType == InventJournalType::Movement && inventJournalTable.JournalIdOrignal ) || inventJournalTable.SystemBlocked == true)
            {
                ttsbegin;
                inventJournalTable.clear();
                inventJournalNameId =  InventJournalName::standardJournalName(InventJournalType::Movement);
                inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalNameId));
                inventJournalTable.insert();

                inventJournalTrans.clear();
                inventJournalTrans.initFromInventJournalTable(inventJournalTable);
                inventJournalTrans.TransDate = systemDateGet();
                inventJournalTrans.ItemId = '1000';
                inventJournalTrans.initFromInventTable(InventTable::find(inventJournalTrans.ItemId));
                inventJournalTrans.Qty = 1;
                inventdim.InventSiteId = '1';
                inventdim.InventLocationId = '11';
                inventJournalTrans.InventDimId = InventdIm::findOrCreate(inventDim).inventDimId;

                dimAttrValueCombo.clear();

                select firstonly RecId from  dimAttrValueCombo
                where dimAttrValueCombo.MainAccount == MainAccount::findByMainAccountId("110110").RecId
                && dimAttrValueCombo.DisplayValue == '110110';
          
                inventJournalTrans.LedgerDimension = dimAttrValueCombo.RecId;

                if(inventJournalTrans.Qty > 0)
                {
                numOfLines  ;
                inventJournalTrans.insert();
                }

                inventJournalTable.NumOfLines = numOfLines;
                inventJournalTable.update();
                ttscommit;
                  info(strFmt("Movement Journal ID: %1", inventJournalTable.JournalId));
            }
                // journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
                //journalCheckPost.run();
    }

}
5344.Capture.PNG

I have the same question (0)
  • Suggested answer
    huijij Profile Picture
    19,811 on at

    Hi HARISH,

    For the error message, the COC method must have the final keyword, and the Wrapper methods must always call next method, I think you need to read Microsoft Doc carefully.

    learn.microsoft.com/.../method-wrapping-coc

  • Alex VN Profile Picture
    1,994 on at

    Hi,

    I think the message is rather clear. The method you extend is not a static method but in your extension it is static. Hence I think ou need to remove static key.

    public static(remove) void setJournalNumber

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 258 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans