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

need to ovveride the salesline WMSlocation field value through x++ in D365FO

(0) ShareShare
ReportReport
Posted on by 70

Hi,

we creating sales order using x++ 

in the x++ code for that WMSlocation we are giving some value

but in the warehouse  default location has been set, while creating the sales line even if we gave our Wmslocation value still it is taking the default value from the warehouse i tried to ovveride using doupdate still am not able to ovveride it

in salesline we have method call modifyWMS location

whenever we call the salesline table this mehtod getfing called and changing the WMSlocation value to default

this method is wrrappable and hookable (false) method

i cant extended it either 

is there some other way to ovverride the sales line WMSlocation value

I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    305,196 Super User 2026 Season 1 on at

    Hi Ram,

    You can follow the next steps in x++:

    1)  You can get the current InventDimId from the sales line.

    2) With this value, get the InventDim record.

    3) Modify the WMSlocation.

    4) Then don't save the record, but use the InventDim method to find or create an InventDim record

    5) You will now have a new InventDimId value which can be replaced on the sales line

    Hope this helps.

  • ram_ind Profile Picture
    70 on at

    Hi andre,

    yes am doing this only

    but while the data written into the sales line table it overriding into default value

    there is a method in sales line table modifyWMSlocation this method is called during insert this replacing our value into the default wmslocation vlaue

  • Alex VN Profile Picture
    1,994 on at

    Him

    May I know if you tried to use Andre's suggestion and if you can show us your code. I would recommend to debug the process to see the inventdim value and when the warehouse value is changed.

    Regards,

  • Alex VN Profile Picture
    1,994 on at

    Reference for full code to create SO with warehouse, might need both InventSiteID, InventLocationID and InventDimID.

    community.dynamics.com/.../create-sales-order-using-x

    Regards,

    Anh Ong

  • ram_ind Profile Picture
    70 on at

                inventdim.InventSiteId = InventDim::find(this.InventDimId).InventSiteId;
                inventdim.InventLocationId = InventDim::find(this.InventDimId).InventLocationId;
                inventdim.wMSLocationId = "11";
                dimid = InventDim::findOrCreate(inventDim).inventDimId;
                this.InventDimId = dimid;

    this is code that am using

    i have done coc to sales line insert method in that method only above code is placed

  • Alex VN Profile Picture
    1,994 on at

    Hi,

    Not sure what you are doing but it seems that you set the InventSiteID and InventLocationID to the default value as you get it from InventDim::find(this.InventDimId) and current this.InventDimId contains default value for the site and location.

    I would recommend you to set the InventSiteID and InventLocationId with similar code as below.

    str warehouse = '11';

    if(InventLocation::find(warehouse).InventLocationId != "")

               {

                   salesLine.InventSiteId = InventLocation::find(warehouse).InventSiteId;

                   salesLine.InventLocationId = inventlocation::find(warehouse).InventLocationId;

               }

    Please check and let me know the result.

  • André Arnaud de Calavon Profile Picture
    305,196 Super User 2026 Season 1 on at

    Hi Ram,

    Have you used the debugger to find out if your logic is executed or not? If your coding is working, you can then also check what happens after your code got executed.

  • ram_ind Profile Picture
    70 on at

    Hi All,

    thanks for your response

    i have done doupdate in the sales line insert method after the next call

    now its updating the value properly

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 April 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 692

#2
André Arnaud de Calavon Profile Picture

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

#3
CP04-islander Profile Picture

CP04-islander 478

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans