• No results found

Creating a Workflow Report when Terminating a Workflow

This example script creates a report in HTML format when terminating a workflow and adds it to the document as an attachment. If the WF is linked to a structural element, the report is created in it as new document.

The script must be registered as end script in all end nodes of the WF.

'TermFlow.VBS 03/04/2003 '--- ' © 2003 ELO Digital Office GmbH

' Author: M.Thiele ([email protected]) '--- ' This script reads the actual workflow ' and creates a report as an

' HTML file which corresponds to the list view ' in the workflow designer.

'

' This report is then attached to ' the document or, if the source is a ' structural element, as new

' document. dim file ' temporary HTML file

Set Elo=CreateObject("ELO.professional")

set Fso = CreateObject("Scripting.FileSystemObject") main

AddHeader Elo.WFFlowName, Elo.LoadUserName(Elo.ActiveUserId) ' run across all WF nodes

for i=0 to cnt-1

call Elo.SelectNode(i) if Elo.NodeType=2 then

' Determine user name, UserTerminate has precedence over NodeUser UserName=Elo.UserTerminate

InsertLine i, Elo.NodeActivateDate, Elo.NodeTerminateDate, UserName, Elo.NodeName, Elo.NodeComment

end if next

' Complete HTML file and close CloseReport

' Copy the report as attachment or new document into archive AddAttachment EloId, Elo.WFFlowName

end if

call Elo.GetNodeList(0) end sub

© 1998..2002 ELO Digital Office GmbH Page: 33

' This function copies the report from the postbox to the archive sub AddAttachment(EloId, WFName)

if Elo.PrepareObjectEx(EloId,0,0)>0 then ' If the target is a doc., add as attachment,

' Transfers the report to the structural element, which is ' attached to the workflow.

sub MakeDocument(ParentId, WFName) call Elo.PrepareObjectEx(0,254,0) Elo.ObjShort="Workflowreport " & WFName Elo.ActivePostFile=FName

call Elo.AddPostboxFile("")

call Elo.MoveToArchive("#"&ParentId) end sub

' Attaches the report to the workflow document sub MakeAttachment(EloId, WFName)

dim status

status=Elo.ObjFlags if (status and 3)<>1 then

Elo.ObjFlags=(status and 1073741820) or 1 Elo.UpdateObject

else

status=-1 end if

call Elo.InsertDocAttachmentEx(EloId, FName, "Workflowreport "&WFName, Date) if status <> (-1) then

call Elo.PrepareObjectEx(EloId,0,0) Elo.ObjFlags=status

Elo.UpdateObject end if

end sub

' Determines the file name of the temp file and creates it.

sub MakeFile

FName=Elo.GetPostDir & "ELO_Workflowreport.htm"

set file=Fso.CreateTextFile(FName, true) end sub

' Adds the HTML prefix to the temp file sub AddHeader(WFName, UName)

if WFName="" then WFName="-" else WFName=toHtml(WFName)

file.WriteLine("<html><head><title>Workflow-Report : " & WFName & "</title></head>") file.WriteLine("<body bgcolor=""#ffffff"" text=""#000000"">")

file.WriteLine("&nexp;<p><table><tr><td width=""10%"">&nexp;</td><td

width=""85%""><table><tr><td colspan=2><h1>Workflow final report</h></td></tr>") file.WriteLine("<tr><td>&nexp;</td></tr>")

file.WriteLine("<tr><td><b>Workflowname</b></td><td><b>" & WFName & "</b></td></tr>") file.WriteLine("<tr><td><b>Final&szlig;date</b></td><td><b>" & Date & " " & Time &

"</b></td></tr>")

file.WriteLine("<tr><td><b>Editor</b></td><td><b>" & UName & "</b></td></tr>") file.WriteLine("</table><p>")

file.WriteLine("<table border=""2"" CELLPADDING=""8"" cellspacing=""0"">") file.WriteLine("<tr bgcolor=""#d0d0d0""><th>No.</th><th>Start date</th><th>End date</th><th>User</th><th>Node</th><th>Remark</th></tr>")

end sub

' completes the HTML section and closes the file sub CloseReport

file.WriteLine("</table></td></tr></table></body></html>") file.Close

end sub

' Adds the information to a node in the file

sub InsertLine(LineNo, Startdate, Enddate, User, Node, Comment) dim col

if (LineNo Mod 2) = 1 Then Col="""#f0f0f0""" else Col="""#ffffff"""

if Startdate="" then Startdate="-"

if Enddate="" then Enddate="-"

© 1998..2002 ELO Digital Office GmbH Page: 34

if User="" then User="-" else User=toHtml(User) if Node="" then Node="-" else Node=toHtml(Node)

if Comment="" then Comment="-" else Comment=toHtml(Comment) file.WriteLine("<tr bgcolor=" & col & ">")

file.WriteLine("<td valign=top>" & LineNo & "</td>") file.WriteLine("<td valign=top>" & Startdate & "</td>") file.WriteLine("<td valign=top>" & Enddate & "</td>") file.WriteLine("<td valign=top>" & User & "</td>") file.WriteLine("<td valign=top>" & Node & "</td>") file.WriteLine("<td valign=top>" & Comment & "</td>") file.WriteLine("</tr>")

end sub

' Converts the reserved characters to HTML format toHtml function (Text)

Text=Replace(Text,"&","&amp;") Text=Replace(Text,"<","&lt;") Text=Replace(Text,">","&gt;") Text=Replace(Text,"ö","&ouml;") Text=Replace(Text,"ä","&auml;") Text=Replace(Text,"ü","&uuml;") Text=Replace(Text,"Ö","&Ouml;") Text=Replace(Text,"Ä","&Auml;") Text=Replace(Text,"Ü","&Uuml;") Text=Replace(Text,"ß","&szlig;")

Text=Replace(Text, vbcrlf & vbcrlf, "<p>") Text=Replace(Text, vbcr & vbcr, "<p>") Text=Replace(Text, vblf & vblf, "<p>") toHtml=Text

end function

© 1998..2002 ELO Digital Office GmbH Page: 35 HTML Subject Data View Script Event

Since version 4.00.080 ELO has a new option for displaying the data of the subject data parallel to the

document. You can define the view yourself by a HTML document. Thereby you can put a file templ_X.htm for the mask type x (e.g. templ_23.htm for mask 23) in the postbox directory, which contains the subject data view.

Furthermore you can deposit a file templ_default.htm for all masks, which need no special description. In this files are put appropriate placeholders for the current data (in terms of a HTML comment, so that the pages can be created with any HTML editors). Then these placeholders are replaced for view with the proper data and displayed in a browser window in the ELO client.

... <td width="80" bgcolor="#d8d8d8"><!--ELO_N_1--></td>

<td bgcolor="#d8d8d8"><!--ELO_T_1--></td>

...

The two lines listed above show the name(<!--ELO_N_1-->) and the content (<!--ELO_T_1-->) of the index line 1 in two cells of one table. All ELO placeholders begin with a HTML comment introduction <!--, followed by the permanent text ELO_. Afterwards follows the information , if it concerns the name (N) or the content (I).

At the end stands the number of the index line and the comment is to be closed.

The indicator for the index line can contain the numbers 1 till 50 (for the 50 index lines), furthermore following letters are available:

A Storage date <!—ELO_T_A-->

B Internal ELO number of the file attachment <!—ELO_T_B-->

D Document date <!—ELO_T_D-->

E Name of the owner <!—ELO_T_E-->

I Internal ELO number of the document file <!—ELO_T_I-->

K Short name <!—ELO_T_K-->

M Mask name <!—ELO_T_M-->

O Internal ELO number of the logical entry <!—ELO_T_O-->

S Internal ELO number of the signature file <!—ELO_T_S-->

T Document type <!—ELO_T_T-->

V Validity end date <!—ELO_T_V-->

Moreover you have the possibility to leave out parts of the HTML document completely, as a function of, if a value is entered or not. At the index lines you can save a lot of space, if the empty lines are not displayed. For this you add the complete region to a clip of the comment characters <!--ELO_B_xxx--> and

<!--ELO_E_xxx--> (xxx stands for the line number or for one of the special characters mentioned above).

... <!--ELO_B_1--><tr>

<td width="80" bgcolor="#d8d8d8"><!--ELO_N_1--></td>

<td bgcolor="#d8d8d8"><!--ELO_T_1--></td>

</tr><!--ELO_E_1-->

...

In this example the index line 1 is included as an table line only if the text in this line is not empty. For the numerical fields with the internal ELO object numbers the 0 (no document assigned) is classified as “empty”.

Table characters, which are marked as invisible or allow no reading access to the user, are also not displayed.

In the HTML template files are allowed in principle all permitted TML constructs (inclusive CSS and Java Script). But keep in mind, that the scripting functions are switched of in some browsers. Furthermore you have to mind, that the source comes from a file and not from a server, all active contents (active server pages, server side includes) would not be worked on.

© 1998..2002 ELO Digital Office GmbH Page: 36 The script event is requested before the template file is loaded. At the time of the request the normal object properties to the document to be displayed are loaded as after a PrepareObjectEx (Id…) and the ViewFileName property contains the name of the template file to be loaded (e.g. c:\temp\templ_7.htm). Now you can redirect the template file in the script to another file (by setting the ViewFileName property). In addition you are able to change the values of the index lines if required (SetObjAttrib…).

Example for a view of the short name and the first 11 index lines (if they are not