web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Apply customer template via c/al

(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?

I have the same question (0)
  • Verified answer
    Binesh Profile Picture
    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;

  • Ricardo Jacobsen Profile Picture
    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
    Ricardo Jacobsen Profile Picture
    50 on at
    RE: Apply customer template via c/al

     Binesh 

  • Binesh Profile Picture
    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.

  • Ricardo Jacobsen Profile Picture
    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,232

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 2,863

#3
Sumit Singh Profile Picture

Sumit Singh 2,819

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans