Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

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()
 
    var
        vDims: Record /Default Dimension/;
    begin
        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;
        end;
    end;
 
Categories:
  • Verified answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 17,965 Super User 2024 Season 2 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.
     
     
    Regards,
    Saurav Dhyani
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 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.
    Thanks.
    ZHU
  • Verified answer
    Mustafa Omerbegović Profile Picture
    Mustafa Omerbegović 1,079 on at
    Customer dimension on Creation
    Hello,
    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.
     
     
    Greeting
  • 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 17,965 Super User 2024 Season 2 on at
    Customer dimension on Creation
    Hi,
     
    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)
        var
            DefaultDimension: Record "Default Dimension";
        begin
            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.');
        end;
     
    Hope it helps.
     
    Regards,
    Saurav Dhyani

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!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans