<h1>Create document from template</h1>
<p>When creating documents, all available <a
href="#!/guide/p2F6C9FC4_91A9_4C37_B107_05A466B7C906">document templates</a> can be used. This allows you to generate standardized documents for a contract and to take over information from the contract.</p>
<blockquote>
<p><span
style='font-style:italic'>A new contract document is created for a contract. In the document header, the contacts and the contract partner's address are filled in automatically.</span></p>
</blockquote>
<h2>Action: Create document</h2>
<p>This action can be accessed on the <code>Contracts</code> tab in the ribbon.</p>
<p>{@img img1.png}</p>
<h3>Requirements</h3>
<ul>
<li>The user is in the client on or within a contract.</li>
<li>Select a <span
style='font-weight:bold'>document template</span></li>
</ul>
<h3>Data input</h3>
<p>The <span
style='font-weight:bold;font-style:italic'>002_create_document</span> from tab group from the <span
style='font-weight:bold;font-style:italic'>sol_contract_document</span> form is used for data input.</p>
<p><span class="tag_warning">Additional information has to be stored from the name in the document template. If there are no CUSTOM fields, the entire <code>Additional information</code> block is hidden.</span></p>
<p>{@img img3.png}</p>
<p>The form consists of the following components:</p>
<table><thead><tr><td><span
style='font-weight:bold'>Document</span></td><td><span
style='font-weight:bold'>Additional information</span></td></tr></thead><tbody><tr><td>210_document</td><td>220_general_readonly</td></tr><tr><td>311_additional_info_create</td><td>230_company_readonly</td></tr><tr><td></td><td>240_contract_data_readonly</td></tr><tr><td></td><td>250_partner_readonly</td></tr></tbody></table>

<h3>Implementation</h3>
<p><span class="tag_warning"><span
style='font-weight:bold'>Action definitions:</span> Definitions of the actions for the clients are located in the <code>sol.contract.documents.CreateDocument</code> configuration.</span></p>
<p>The <span
style='font-weight:bold'>technical workflow</span> is implemented by ELOas actions <code>sol.contract.as.actions.PrepareDocument</code> and <code>sol.contract.as.actions.CreateDocument</code>.</p>
<p>These are interlinked actions. After the action is started (by clicking the button on the ribbon), <span
style='font-weight:bold;font-style:italic'>PrepareDocument</span> is executed. Once the user has <span
style='font-weight:bold;font-style:italic'> successfully entered the data</span> (by submitting the form), <span
style='font-weight:bold;font-style:italic'>CreateDocument</span> is triggered.</p>
<p>{@img img5.png}</p>
<p><span class="tag_important">This interlinking is necessary to give the second action (or the template) access to all document metadata (including all generated values). Additional information on interlinked actions can be found in the general documentation on &quot;Business Solutions.&quot;</span></p>
<p>PrepareDocument creates an empty document based on the selected template and starts the workflow set to default for the document. The default workflow allows you to control the technical workflow for data capture as well as presetting of information based on the document type.</p>
<blockquote>
<p><span
style='font-style:italic'>Example: The standard logic in the form for creating new documents is insufficient. In this case, the <code>sol.contract.document.create</code> workflow can be copied and the user form can be tailored to the document type. As a result, you can address special situations for different keywording forms.</span></p>
</blockquote>
<p>Next, the CreateDocument action is called. This action opens the document and replaces placeholders with information from the contract or custom fields in the document.</p>
<p>If successful, the following events are transferred to the client:</p>
<p><span
style='font-weight:bold'>PrepareDocument</span></p>
<table><thead><tr><td>Event</td><td>Description</td><td>Status</td></tr></thead><tbody><tr><td>DIALOG</td><td>Shows the form to input data in a dialog box.</td><td></td></tr><tr><td>ACTION</td><td>Opens after an entry is made in the <span
style='font-weight:bold'>CreateDocument</span> form.</td><td>SUCCESS</td></tr></tbody></table>

<p><span
style='font-weight:bold'>CreateDocument</span></p>
<table><thead><tr><td>Event</td><td>Description</td><td>Status</td></tr></thead><tbody><tr><td>GOTO</td><td>Shows the newly created element in the client.<br />Document checked out and opened.</td><td></td></tr></tbody></table>

<p><span
style='font-weight:bold'>Description of the workflow</span></p>
<p>{@img img7.png}</p>
<table><thead><tr><td><span
style='font-weight:bold'>Node name</span></td><td><span
style='font-weight:bold'>Node description</span></td><td><span
style='font-weight:bold'>Function</span></td></tr></thead><tbody><tr><td><span
style='font-weight:bold'>collect data (file)</span></td><td><span
style='font-weight:bold'></span><br />Captures the required information</td><td></td></tr><tr><td><span
style='font-weight:bold'>create document</span></td><td><span
style='font-weight:bold'>Creates (passes forward) document</span></td><td></td></tr><tr><td><span
style='font-weight:bold'>cancel</span></td><td><span
style='font-weight:bold'>Cancels (passes forward)</span></td><td></td></tr><tr><td><span
style='font-weight:bold'>DELETE : temporary file</span></td><td>Deletes the temporary element</td><td>sol.common.ix.functions.Delete</td></tr><tr><td><span
style='font-weight:bold'>USERTOINDEX : responsible user</span></td><td>Sets the current user as the document manager.</td><td>sol.common.ix.functions.UserToIndex</td></tr></tbody></table>
