Skip to main content


Business Central forum

Customer dimension on Creation

Posted on by 105
Dear all,
How can I ensure that while user is creating a new customer he should fill default dimension? I tried to write a few lines of code in customer table extension and call it on customer card page Onpageclose trigger but it is not meeting the requirement.
procedure CheckDim()
        vDims: Record /Default Dimension/;
        vDims.SetRange(/Table ID/, Database::Customer);
        vDims.SetRange(/No./, rec./No./);
        vDims.SetRange(/Dimension Code/, '');
        if vDims.FindSet() then begin
            if vDims./Dimension Code/ = '' then
            Error('Customer Dimension is required');
            // begin
            //     if vDims./Dimension Value Code/ = '' then
            //         Error('Customer Dimension is required');
            // end;
  • Verified answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 12,769 User Group Leader on at
    Customer dimension on Creation
    Hi @Maro9595,
    It will be created but you will not be able to unblock it.
    Until its unblocked you will not be able to do any transaction for that customer. 
    Additionally, as @Mustafa Omerbegović suggested, if that is something you can do. It's a great suggestion.
    Saurav Dhyani
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 62,529 Super User on at
    Customer dimension on Creation
    Hi, I would like to mention that the standard environment can do it, but it will be checked at post time, not at creation time.
    Hope this helps.
  • Verified answer
    Customer dimension on Creation
    I believe that Saurav.Dhyani gave you the correct answer, but I do not know why you do not use Customer Template for this purpose.
    Why write code when you can use native functionality that will work well?
    Customer Templates -> Dimensions -> Define default dimensions for customer template
    Afer you create new customer with that template you will have defined dimension on customer card.
    Templates gives you the opportunity to define another customer data which will automatically applied to new customer cards.
  • Maro9595 Profile Picture
    Maro9595 105 on at
    Customer dimension on Creation
    Thank you for your valuable replay Saurav,
    but when I select OK the page close and customer is still created
  • Suggested answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 12,769 User Group Leader on at
    Customer dimension on Creation
    You are approaching it incorrectly.
    Here is how I would suggest approaching this - 
    1. When a new customer created, using oninsert subscriber make Blocked as All.
    2.  When user tries to Blocked as " ", then check Default Dimension.
    3. If you only want to do it during first time (creation), then add a Boolean "Dimension Checked".
    4. If you do 3, then after Blocked is set to " ", set that Boolean true and Do 2 only if Dimension Checked = false.
    Here is code that you should be using - 
        Procedure CheckDefaultDimension(var Customer: Record Customer)
            DefaultDimension: Record "Default Dimension";
            DefaultDimension.SetRange("Table ID", Database::Customer);
            DefaultDimension.SetRange("No.", Customer."No.");
            If DefaultDimension.IsEmpty() then
                Error('Default Dimension is not set for this customer. Please set the default dimension for this customer.');
    Hope it helps.
    Saurav Dhyani

Helpful resources

Quick Links

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284,217 Super User

Martin Dráb Profile Picture

Martin Dráb 225,202 Super User

nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans