Creates a document or a new version of a document on the specified path using specified template and given xml data.

Syntax

Visual Basic (declaration)
Public Function CreateDocumentUsingTemplate( _ 
ByVal AuthenticationTicket as String, _ ByVal Path as String, _ ByVal TemplatePath as String, _ ByVal xmlContent as String) as XmlNode

C# (declaration)
public XmlNode CreateDocumentUsingTemplate( 
string AuthenticationTicket, string Path, string TemplatePath, string xmlContent)

Parameters

AuthenticationTicket
    string inforouter ticket
Path
    string The Document path that will be created or updated.
TemplatePath
    string The path of the template that will be used while creating or updating the document.
xmlContent
    string An xml data that will be placed in the document while creating the document. See the remarks section for details.

Return Value

returns xml fragment.
<response success="true" error="">
if success attribute is "true", the document has been created or updated successfully.
if success attribute is "false", the error attribute indicates the encountered error.

Remarks

The caller can be any user who has authing rights in the publishing folder and read access to the template.

The XML data structure must be like below. The prompts must be consistent with the template input names.

<FORMDATA>
<Prompt Name="MemoDate">2005-05-01"</Prompt>
<Prompt Name="Author">Ed Mahoney</Prompt>
<Prompt Name="Subject">New GUI Rules</Prompt>
<Prompt Name="MemoBody">Lorem dolor sit amet.....</Prompt>
</FORMDATA>

minus gif Example

Visual Basic Example
Option Explicit On
Option Strict On

Module Modul_CreateDocumentUsingTemplate

    Public Sub CreateDocumentUsingTemplate(ByVal ServiceURL As String, ByVal AuthenticationTicket As String)

        Const IRNewDocumentPath As String = "/samplelib/memo-guirules.htm"
        Const TemplatePath As String = "/Form Templates/memo.htm"
        Dim IR_OBJ As InfoRouter.srv
        Try

            IR_OBJ = New InfoRouter.srv
            IR_OBJ.Url = ServiceURL

            Dim patientdata_xml As System.Xml.XmlDocument
            Dim DataElem As System.Xml.XmlElement
            patientdata_xml = New System.Xml.XmlDocument
            patientdata_xml.LoadXml("<FORMDATA/>")

            DataElem = patientdata_xml.CreateElement("Prompt")
            DataElem.SetAttribute("Prompt", "MemoDate")
            DataElem.InnerText = "2005-05-01"
            patientdata_xml.DocumentElement.AppendChild(DataElem)

            DataElem = patientdata_xml.CreateElement("Prompt")
            DataElem.SetAttribute("Name", "Author")
            DataElem.InnerText = "Ed Mahoney"
            patientdata_xml.DocumentElement.AppendChild(DataElem)

            DataElem = patientdata_xml.CreateElement("Prompt")
            DataElem.SetAttribute("Name", "Subject")
            DataElem.InnerText = "New GUI Rules"
            patientdata_xml.DocumentElement.AppendChild(DataElem)

            DataElem = patientdata_xml.CreateElement("Prompt")
            DataElem.SetAttribute("Name", "MemoBody")
            DataElem.InnerText = "Lorem dolor sit amet....."
            patientdata_xml.DocumentElement.AppendChild(DataElem)

            Dim xml_response As System.Xml.XmlNode
            xml_response = IR_OBJ.CreateDocumentUsingTemplate(AuthenticationTicket, IRNewDocumentPath, TemplatePath, patientdata_xml.OuterXml)
            'check response xml if any error occured.
            If xml_response.Attributes("success").Value.ToUpperInvariant() = "TRUE" Then
                Console.WriteLine("The Document has been created using template successfully")
            Else
                Console.WriteLine("The Document cannot be created.")
                Console.WriteLine("ERROR:" + xml_response.Attributes("error").Value)
            End If
            xml_response = Nothing
            DataElem = Nothing
            patientdata_xml = Nothing

        Catch ex As Exception
            Console.WriteLine("ERROR:" + ex.Message)
        Finally
            IR_OBJ = Nothing
        End Try
    End Sub
End Module