infoRouter Document Management System - Web Services API Documentation Version 7.0
CreateDocumentUsingTemplate
Creates a document or a new version of a document on the specified path using specified template and given xml data.
Syntax
[Visual Basic]
Public Shared Function CreateDocumentUsingTemplate(ByVal AuthenticationTicket As String, _
ByVal Path As String, _
ByVal TemplatePath As String, _
ByVal xmlContent As String _
) As System.Xml.XmlDocument
Parameters

AuthenticationTicket

infoRouter Authentication Ticket

Path

The Document path that will be created or updated.

TemplatePath

The path of the template that will be used while creating or updating the document.

xmlContent

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>
Example
Sub CreateDocumentUsingTemplate_sample()
'Define Input values

Const IRNewDocumentPath As String = "/Memos/memo-guirules.htm"
Const TemplatePath As String = "/Form Templates/memo.htm"


Dim IR_OBJ As InfoRouter.srv

Try
ClearOutputWindow()
WriteOutputLine("[CreateDocumentUsingTemplate]")
WriteOutputLine("Document Path = " & IRNewDocumentPath)
WriteOutputLine("Template = " & TemplatePath)
WriteOutputLine("----------------------------------------")
Application.DoEvents()
Me.ActiveForm.Cursor = Cursors.WaitCursor

IR_OBJ = New InfoRouter.srv
IR_OBJ.Url = (txtSrvUrl.Text & "/srv.asmx")

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.XmlElement
xml_response = IR_OBJ.CreateDocumentUsingTemplate(AuthenticationTicket, _
IRNewDocumentPath, TemplatePath, patientdata_xml.OuterXml)
'check response xml if any error occured.
If xml_response.GetAttribute("success") = "true" Then
WriteOutputLine("The Document has been created using template successfully")
Else
WriteOutputLine("The Document cannot be created.")
WriteOutputLine("ERROR:" & xml_response.GetAttribute("error"))
End If
xml_response = Nothing
DataElem = Nothing
patientdata_xml = Nothing

Catch ex As Exception
MsgBox(ex.Message)
Finally

IR_OBJ = Nothing
Me.ActiveForm.Cursor = Cursors.Default
End Try
End Sub
See Also
Upload Document | DownloadDocument
Web Services API Syntax based on infoRouter Document Management System Version 7.0
Copyright() 1998-2008 Active Innovations, Inc.
infoRouter Enterprise Document Management Software