Skip to main content
Business Central forum
Answered

Apply customer template via c/al

editSubscribe (0) ShareShare
ReportReport
Posted on by 50

I'm creating new customers via c/al extensions. I would like to apply one template that was created in business central to the new customers.

It seems that I have to use the Codeunit "Customer Templ. Mgt."

Anyone that would help on how to apply the template to the new customers via C/AL?

Categories:
  • Ricardo Jacobsen Profile Picture
    Ricardo Jacobsen 50 on at
    RE: Apply customer template via c/al

    Hello Binesh . I'm sorry but I didn't get what you mean?

    Which name you are talking about?

    I didn't put any name as correct answer.

    Sorry I'm new to the forum I'm trying to understand what is going on.

  • Binesh Profile Picture
    Binesh 7,885 on at
    RE: Apply customer template via c/al

    Hello Ricardo,

    Before going to further discussion, I want to know how the "name" can be correct answer of your query which you have verified for your statement?

    Don't put false as this is a community channel which helps to other members as well when they have similar kind of query by seeing the verified answer.

    Hope you can understand my concern, and also for new query create a new question instead of making a chat, by this way you can also help other members to find the query.

  • Verified answer
    Ricardo Jacobsen Profile Picture
    Ricardo Jacobsen 50 on at
    RE: Apply customer template via c/al

     Binesh 

  • Ricardo Jacobsen Profile Picture
    Ricardo Jacobsen 50 on at
    RE: Apply customer template via c/al

    That really helps, thank you very much.
    Another question, if you can reply..
    How do I select a specific template? 
    For example, I saved this CLIENT template and I want to select it for applying via C/AL.

    pastedimage1658801650184v2.png

    It seems that CustomerTempl: Record "Customer Templ." is using a standard template from business central. Am I correct?

  • Verified answer
    Binesh Profile Picture
    Binesh 7,885 on at
    RE: Apply customer template via c/al

    Hello,

    See the below code for your reference and update it as per your needs if required.

    procedure CreateCustomerFromTemplate(var Customer: Record Customer; CustTempCode:code[20])
        var
            CustomerTempl: Record "Customer Templ.";
            CustTempMgmt: codeunit "Customer Templ. Mgt.";
        begin
            if not CustomerTempl.Get(CustTempCode) then 
                Error('Customer template code not exist.')
           
            Customer.SetInsertFromTemplate(true);
            Customer.Init();
            CustTempMgmt.InitCustomerNo(Customer, CustomerTempl);
            Customer."Contact Type" := CustomerTempl."Contact Type";
            Customer.Insert(true);
            Customer.SetInsertFromTemplate(false);
    
            CustTempMgmt.ApplyCustomerTemplate(Customer, CustomerTempl);
        
        end;

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,066 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,585 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans