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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

Create Inventory ownership change and post journal through X++

(0) ShareShare
ReportReport
Posted on by

Dear all,

After I created Consignment Replenishnment Order. I have to create inventory ownership change and post this journal through X++. So if you guys have any ideas or suggestion please help me.

Thanks a lot

Phuoc Dinh

I have the same question (0)
  • Verified answer
    Sumit Loya Profile Picture
    2,230 on at

    Hi Phuoc Dinh,

    You can try following code:

            //Header Creation
            InventJournalTable  inventJournalHeader;
    
            inventJournalHeader.JournalNameId = '';//Default Ownership change journal name
            inventJournalHeader.initFromInventJournalName(InventJournalName::find(inventJournalHeader.JournalNameId));
    
            inventJournalHeader.JournalId     = NumberSeq::newGetNum(InventParameters::numRefInventJournalId()).num();
            inventJournalHeader.Description   = 'Inventory ownership change';
            inventJournalHeader.insert();
    
            //Line Creation
            InventJournalTrans  inventJournalLine;
            InventDim	        inventDimIssue;
            InventDim	        inventDimReceipt;
    
            inventJournalLine.initValue();
            inventJournalLine.initFromInventJournalTable(inventJournalHeader);
    
            inventJournalLine.LineNum           = 1;//Set your logic for line number
            inventJournalLine.TransDate         = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
            inventJournalLine.ItemId            = ''; Set your item id
            inventJournalLine.modifiedField(fieldNum(InventJournalTrans, ItemId));
    
            inventJournalLine.Qty               = 1;//Set your Qty;
            inventJournalLine.modifiedField(fieldNum(InventJournalTrans, Qty));
    
            inventJournalLine.DefaultDimension  = ;//Logic for Financial dimensions
    
            inventDimIssue.InventSite           = '';
            inventDimIssue.InventLocationId     = '';
            inventDimIssue.InventOwnweId_RU     = '';
            inventDimIssue = InventDim::findOrCreate(inventDimIssue);
    
            inventDimReceipt.data(inventDimIssue);
            inventDimReceipt.InventOwnweId_RU   = '';
            inventDimReceipt = InventDim::findOrCreate(inventDimReceipt);
    
            inventJournalLine.InventDimId       = inventDimIssue.InventDimId;
            inventJournalLine.ToInventDimId     = inventDimReceipt.InventDimId;
            inventJournalLine.insert();
    
    	    //Post record
    	    InventJournalCheckPost journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalHeader);
            journalCheckPost.runOperation();

  • Community Member Profile Picture
    on at

    Hi Sumit Loya,

    This code work for me. Appriciate it. Thank you a lots

    Phuoc Dinh

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Siv Sagar Profile Picture

Siv Sagar 283 Super User 2025 Season 2

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 213 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 152 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans