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 :
Small and medium business | Business Central, N...
Answered

Sales Header CodeUnit Example (Set Dimension Value)

(0) ShareShare
ReportReport
Posted on by 87

I am looking for an example or documentation for a way of setting a dimension value (not global 1 or 2) for a sales header.  I found a question on the community here that someone answered and said that it could be done by using a CodeUnit.  I have not created a CodeUnit before and am not sure how they are triggered/fired.  Are there other methods of doing this?  What is the path of least resistance on accomplishing this?

I have the same question (0)
  • Suggested answer
    MahGah Profile Picture
    15,529 on at

    Hi

    Can you please provide more info here? What is the final goal here? Is this a one time deal or ongoing

    For one time deal you can use Order -> Dimension and set any dimension. 

    pastedimage1623178538422v1.png

    If this will be customer related then you can go to Customer Card and set the dimension for customer. Then the settings will follow to sales order.

    pastedimage1623178662158v2.png

    Thanks

  • HPC Keith Profile Picture
    87 on at

    Thank you for the response.  The goal is an integration.  We are creating the sales headers in an ASP.NET web project by posting to the native Web Services in BC (ODATAv4) and we also need to set a dimension value during this process.  Each sales header (invoice) will have a value based on logic in our web project and is not based on the customer.  Definitely not a one-time thing.  From reading Stefano Demiliani's responses to the question I was referencing (and have linked below), he appears to be using C# and I would love to have native integration and SDK for BC, but have not found any resources on how to set something like that up.

    community.dynamics.com/.../add-dimension-in-sales-order-by-web-service

  • Suggested answer
    MahGah Profile Picture
    15,529 on at

    Thanks for info.

    I believe you need help from people with development background. You can try the following forum

    dynamicsuser.net/.../developers

    or go to Stefano blog and see if he can provide more details https://demiliani.com/

    But this is my understanding of his post

    I believe he is using AL language. See below for more info. He suggested that you create codeunit (Your function needs 4 parameters: Dimension Set ID,Dimension Code,Dimension Value Code,Dimension Value ID.) then go to Web Service in BC and select New and use Codeunit and select your codeunit id and publish this codeunit. Then use this in your end to accomplish what you need.

    I hope some developer provide more info.

    docs.microsoft.com/.../devenv-programming-in-al

    docs.microsoft.com/.../

    Codeunit example

    navhelp110.fenwickcloud.com.au/main.aspx

    Thanks

  • Verified answer
    HPC Keith Profile Picture
    87 on at

    Thank you so much for the information.  I will reach out to Stefano.

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,116

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 764 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 635 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans