Examples
Partial MS Word Template:
PLM Process Script example
- Define report variables such as Function Code/Document Type, output type (MS Word or
Adobe
PDF)
'Define doc code here - required if using IDM Reports; Optional for WebReports dim doccode as string = "ATTACHMENT" 'Define Report template name for IDM Reports (Must be same as template file Title in IDM): dim reportname as string = "USDA Submittal Summary" dim extension as string = ".pdf" ' change extension to docx to generate as Word doc dim filename as string = reportname & "_" & cstr(_wipid) & extension
- Generate the XML data using
ObjectXML
dim sLCXML as string = ObjectXML("", "", "HEADER")
- Convert the XML String to a dataset and
datatables
Dim reader As StringReader = New StringReader(sLCXML) Dim ds As DataSet = New DataSet() Dim row As DataRow ds.ReadXml(reader)
- As needed, add columns to datatables, add datatables to the dataset, or modify
existing
data
ds.Tables("FSLABELCONTENT").Columns.Add(xtfield, GetType(String)) dim apprdate as string = ObjProperty("C_DATEPRRAPPR") If isblank(apprdate) = 0 then apprdate = cdate(apprdate).ToString("MM/dd/yyyy") dt.Rows(0)("C_DATEPRRAPPR") = apprdate End If dim sProcess as string = ObjProperty("DOCTEXT.DOC", "", "", "AGENCY_INFORMATION", "FUNCTION_CODE") if isblank(sProcess) = 0 then ' CREATE TABLE dim processtable as DataTable = idmReportHelper.ConvertTextToTable("DOC_PROCESSING", "TEXT_DATA", sProcess) ' Uses script library IDMREPORTHELPER which is provided with MT Provisioning if not processtable is nothing then Ds.Tables.Add(processtable) end if
- Re-generate XML from the DataSet, and optionally / temporarily show XML in an alert
message*
(*Save the XML to a local file to use with your MS Word Template for building the template content)ds.AcceptChanges() dim xmlData as string = ds.GetXml() ' messagelist(xmlData)
- Generate and attach the
Report
'Define report generation parameters Dim reportParams as New IDMReportParams Dim reportResult as New IDMReportResult reportParams.xmlData = xmlData reportParams.templateFileName = reportname ' "Item Summary Report" reportParams.targetFileName = filename '****** ' Code needed to use non-default Function Code: reportParams.TargetDocCode = doccode Dim targetCMItem As DocICP.CMItem = New DocICP.CMItem() targetCMItem.EntityName = doccode targetCMItem.SetAttributeValue("OPTIVA_SYMBOL", _OBJECTSYMBOL) Dim objKey As String() = _OBJECTKEY.Split("\") targetCMItem.SetAttributeValue("OPTIVA_SYMBOL_ID", objKey(0)) If objKey.Length > 1 Then targetCMItem.SetAttributeValue("OPTIVA_SYMBOL_VERSION", objKey(1)) targetCMItem.SetAttributeValue("OPTIVA_ARCHIVE", False) filename = Replace(filename, extension, "") ' For later report presentation targetCMItem.SetAttributeValue("OPTIVA_DOC_TITLE", filename) reportParams.targetCMItem = targetCMItem '********** ' Generate and attach report reportResult = CreateIDMReport(reportParams) 'Turn on if needed for debugging: ' Messagelist(reportResult.ErrorMessage) ' messagelist("ITEMID - " & reportResult.IDMDoc_ITEM_ID) ' messagelist("IDM Document URL - " & reportResult.IDMDoc_URL) ' messagelist("Job ID - " & reportResult.IDMDoc_JobId)
- If appropriate, launch the report for the user’s view. This script library is provided
with MT
provisioning
dim oidm as IDM_EPPLUS = New IDM_EPPLUS(me) oidm.OpenAttachments(doccode, _objectsymbol, _Objectkey, filename)