Creating Document Fragment

In this part, we will create document fragment to hold the recipient name and address.

We will now create a document fragment that will hold the recipient’s name and address. Document fragments can contain static text as well as data from the back end sources. So to create document fragment we login to AEM forms, navigate to the forms section, and then click on the document fragments.
So here I want to create a document fragment in this particular folder so I navigate into the folder and click on the create button here. As you can see there are three or four kinds of document fragments that are available to you so for the purpose of this exercise we are going to create a document fragment of type “text”.
Specify a name and a title to it. And every document fragment typically will be based on a form data model so that it can insert data returned by the form data model. So in our case, we’re gonna select the retirement accounts statement form data model.
And click on select here, and click next. So what do you see here on the right hand side is the rich text editor. And on the top, you see the various formatting options that are available to you so you can specify the font and the font size and then the text color, bold, italics, underline, and other capabilities are available for you. You can also specify some in-line rules. You can do a search and replace text here, you can specify the page break or you can insert some special characters into your document fragment. Since this document fragment is going to contain the recipients name and address, we’re gonna basically use the elements of the form data model. So on the left you’ll see the various form data model elements. The route element is the balances object so make sure you’re working with the elements under the balances object. So here we’re gonna navigate to the user object and we’re gonna insert the name element into the document fragment you just, once you insert name, hit the enter button. And then you insert the address. Then we insert the city. And then we insert the state and hyphen with the zip. And then we also have an account number seen over here.
So as you can see here these are the elements from the form data model and this is a static text and then, again, there’s a data model element here. So we can also format this text by selecting all the text elements in the document fragment and simply make it bold here. So once you have created your document fragment, save the document fragment and then that is available for you to include it in your communications document.

Document fragments hold the text content of interactive communication documents. This text content can be static text or inserted from the underlying data model elements values. For example Dear {name}, where Dear is static text and name is the form data model element name. At runtime, this will resolve to Dear Gloria Rios or Dear John Jacobs depending on the value of the name element.

Rich text editor is intuitive enough for a business user to author text and inserts form data elements. The document fragment editor has the ability to format text, specify font types and styles, ability to insert special characters and create hyperlinks.

Document fragment editor also has the ability to insert inline conditions in your text as demonstrated in this video

Make sure the Form Data Model elements you insert into a document fragments are descendants of the root element. For example in this use case make sure the User object’s elements that you select is the child of the balances object

Next Steps

Create print channel document