Skip to main content

Notifications

Announcements

No record found.

Business Central forum
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;
 
  • Verified answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 12,678 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.
     
     
    Regards,
    Saurav Dhyani
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 62,342 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.
    Thanks.
    ZHU
  • Verified answer
    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 12,678 User Group Leader 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

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,682 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,000 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans