Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Changing Warehouse to Quarantine Warehouse using X++ code.

(0) ShareShare
ReportReport
Posted on by 2,457

Hi,

Can anybody tell me how to change the warehouse to quarantine warehouse if quarantine is checked through code.

Thanks,

Raziq

*This post is locked for comments

  • Suggested answer
    Mohammad Raziq Ali Profile Picture
    2,457 on at
    RE: Changing Warehouse to Quarantine Warehouse using X++ code.

    Hi Baber,

    I Wrote one class method in which I am passing WmsJournalTrans table buffer as a parameter and below is the code.

    public void updateQuarantineWh(WMSJournalTrans _wmsjournalTrans)
    {
    InventLocationId inventLocationId;
    InventLocationIdQuarantine inventLocationIdQuarantine;
    InventDim inventdim;
    ;
    inventLocationId = InventDim::find(_wmsjournalTrans.inventDimId).InventLocationId;
    inventLocationIdQuarantine = InventLocation::find(inventLocationId).InventLocationIdQuarantine;
    inventdim = InventDim::find(_wmsjournalTrans.inventDimId);
    inventdim.InventLocationId = inventLocationIdQuarantine;
    inventdim = InventDim::findOrCreate(inventdim);

    _wmsjournalTrans.inventDimId = inventdim.inventDimId;
    _wmsjournalTrans.update();

    // return inventLocationIdQuarantine;
    }

    This method will find quarantine warehouse of actual warehouse and update to inventdim table using findorCreate Method.

  • Verified answer
    syed baber Profile Picture
    11,633 on at
    RE: Changing Warehouse to Quarantine Warehouse using X++ code.

    Hi Mohammad,

    There is an InventDim data source on the form which is used to show the inventory dimension under Dimensions tab. You can use the below code snippet to achieve this:

    ttsbegin;

    select forUpdate InventLocationId from InventLocation

    where InventLocation.InventLocationId == InventDim.InventLocationId;

    if (InventLocation)

    {

    InventLocation.InventLocationType = InventLocationType::Quarantine;

    InventLocation.update();

    }

    ttscommit;

    You can write the above code in the init method of InventDim data source on form WMSJournalReception after super(). If you get any error by calling the update method above, then you can use doUpdate(), but keep in mind that it will bypass any standard validations exist in update method. Not sure what would be the impact of changing the warehouse type like this, so I would suggest you to do proper testing of this before moving this to production.

    Please verify and let me know if you have further queries.

    Thanks,

    Baber.

  • Mohammad Raziq Ali Profile Picture
    2,457 on at
    RE: Changing Warehouse to Quarantine Warehouse using X++ code.

    yes baber.......

  • syed baber Profile Picture
    11,633 on at
    RE: Changing Warehouse to Quarantine Warehouse using X++ code.

    Hi Mohammad,

    Do you want to change the warehouse showing under Dimensions tab to quarantine warehouse on Item arrival journal?

    Thanks,

    Baber.

  • Mohammad Raziq Ali Profile Picture
    2,457 on at
    RE: Changing Warehouse to Quarantine Warehouse using X++ code.

    Hi Baber,

    Actually, When record is created in item arrival journal, every time it goes for check whether it is QuarantineCheck is marked or not. if it is marked then warehouse should changed to quarantine warehouse in the form but in dimension tab.

    Is there any possibility so that we can change through code.

    Thanks,

    Raziq

  • Suggested answer
    syed baber Profile Picture
    11,633 on at
    RE: Changing Warehouse to Quarantine Warehouse using X++ code.

    Hi Mohammad,

    You can set the warehouse to quarantine, by setting invent location type value to quarantine. The code should be as follows:

    InventLocation.InventLocationType = InventLocationType::Quarantine;

    Is this what you are looking for?

    Thanks,

    Baber.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,978 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,821 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans