Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Set Sales Header Dimension Shortcut codes in code

Posted on by 65

Hi!

I have defined in my BC default dimension shortcut codes for Sales Header and Sales Line. 

In my application, I create sales invoices and its lines from code.

Setting the dimensions for the lines works fine:

InvoiceLine. "Shortcut Dimension 1 Code" := 'VALUE1';
InvoiceLine. "Shortcut Dimension 2 Code" := 'VALUE2';

On the other hand, when I do the same for the invoice header the values do not set:

InvoiceHeader. "Shortcut Dimension 1 Code" := 'VALUE1';
InvoiceHeader. "Shortcut Dimension 2 Code" := 'VALUE2';

In the debugger, I can see that in the code the values assign correctly for these fields. However, when I go into the created invoice and select "Invoice > Dimensions" I don't see the dimensions set.

pastedimage1673955634773v1.png

How do I assign dimensions for the invoice header from the code? :)

Best Regards

Categories:
  • Alzack18 Profile Picture
    Alzack18 65 on at
    RE: Set Sales Header Dimension Shortcut codes in code

    That's all my code. I'm creating new Sales Header record.

    procedure fun()
    var
        InvoiceHeader: Record "Sales Header";
    begin
        Clear(InvoiceHeader);
        InvoiceHeader."Dimension Shortcut 1 Code" := 'Value1';
        
        //more fields and insert to DB
    end;

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,125 Super User 2024 Season 2 on at
    RE: Set Sales Header Dimension Shortcut codes in code

    It would be helpful if you can show all your code to identify the issue.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,188 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,030 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans