Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Apply customer template via c/al

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;

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans