2 Replies Latest reply on Oct 27, 2016 11:40 PM by natdavidson

    Assigning a template to an element using AF SDK

    natdavidson

      I've been able to add elements, and assign them under the correct hierarchy, my issue is now assigning a template to each element. I see there is Template property for the AFElement class, but i think this is only a read property. Any help would be appreciated.

        • Re: Assigning a template to an element using AF SDK
          mtippett

          Hi Nate,

           

          The element template property is not read only, so once you have created your element(s) you can do something like the following to assign them a template:

           

          AFElementTemplate myTemplate = database.ElementTemplates["my template name"];
          
          
          element.Template = myTemplate;
          element.ApplyChanges();
          database.CheckIn();
          

           

          Alternatively, rather than creating elements and then assigning them a template you can use the AFElements.Add method to create elements of a specifed template in one step.

           

          Hope that helps.