Tips and Frequently Asked Questions
Localizing strings
Workflow Studio provides an easy way to localize the strings. All strings used in user interface
(messages, button captions, dialog texts, menu captions, etc.) are in a single file names
wsLanguage.pas.
In the languages folder, included in Workflow Studio distribution, there are several wsLanguage.pas
files available for different languages. Just pick the one you want and copy it to the official directory of
your workflow studio source code.
If the language you want does not exist, you can translate it yourself. Just open wsLanguage.pas file
and translate the strings to the language you want.
As a final alternative, you can translate the wsLanguage.txt file, also included in ws_languages.zip file,
and send the new file to us. The advantage of this approach is that this file is easier to translate (you
don't have to deal with pascal language) and can be included in the official Workflow Studio
distribution. This way we keep track of changes in translable strings and all new strings are marked in
the upcoming releases. This way, you will always know what is missing to translate, and do not need to
do some kind of file comparison in every release of Workflow Studio.
So, in summary, to localize Workflow Studio strings:
Option 1
- Pick the correct wsLanguage.pas file from the ws_languages.zip file, according to the language you
want.
- Replace the official wsLanguage.pas (in source code directory) by the one you picked.
Option 2
- Translate the official wsLanguage.pas directly
Option 3
- Translate the wsLanguage.txt file and send it to us (support@tmssoftware.com).
- We will send you back a translated wsLanguage.pas file and this translation will be included in official
release.
Sending e-mails
There are several points in the workflow definition where an e-mail can be sent. An example is when a
task instance is created for an user. If the task definition properties of this task instance is marked as
"Send e-mail notification", an e-mail will be sent to the user notifying him that the task instance was
created and assigned to him.
However, there is no built-in code to send e-mails in Workflow Studio. When an e-mail is to be sent,
the event OnSendMail of TWorkflowStudio component is fired. So, if you want your workflow so
support e-mail sending, create an event handler for TWorkflowStudio.OnSendMail event, and send the
e-mail yourself from there, using your own method.
The signature for the OnSendMail event is below:
type
TEmailInformation = record
ToAddr: string;
From: string;
Bcc: string;
Cc: string;
Subject: string;
Text: string;
end;
procedure(Sender: TObject; TaskIns: TTaskInstance; AUser: TWorkflowUser;
AEmailInfo: TEmailInformation; var Sent: boolean) of object;
So, use AEmailInfo parameter to build your e-mail message, using ToAddr, From, Bcc, CC, Subject
and Text properties.
Set Sent parameter to true when the e-mail is sent. For extra information (you will often use only
AEmailInfo), you can use TaskIns and AUser parameters to know which task instance generated the
e-mail, and for each workflow user the e-mail is about to be sent.
Adding users and groups
Workflow Studio is strongly based on tasks, which in turn are always assigned to an user or a group of
users. So, Workflow Studio does also need to use information about users and groups.
This can be done at the beginning of the program. The code below is an example that shows how to add users and groups to Workflow Studio.
{Add users and groups}
With WorkflowStudio.UserManager do
begin
{Add all users}
Users.Clear;
Users.Add('1', 'John', 'john@domain');
Users.Add('2', 'Sarah', 'sarah@domain');
Users.Add('3', 'Scott', 'scott@domain');
Users.Add('4', 'Mario', 'mario@domain');
Users.Add('5', 'Tina', 'tina@domain');
{Add groups and specify which users belong to each group}
Groups.Clear;
With Groups.Add('managers') do
begin
UserIds.Add('1'); //John
UserIds.Add('2'); //Sarah
end;
With Groups.Add('programmers') do
begin
UserIds.Add('3'); //Scott
UserIds.Add('4'); //Mario
UserIds.Add('5'); //Tina
end;
end;
Note that two groups were created, and each group contains a list of user id's that belong to that group.
Workflow Studio uses the user information to assign tasks, send e-mails, and other user-based tasks.
Registering components and methods in workflow scripting system
The Workflow Studio manual describes how to register new components, methods, classes and properties to a scripter component by using methods like DefineClass, DefineProp, etc..
However, Workflow Studio creates a new scripter component instance for each script block that is used in a workflow instance. Due to that, you must use OnGlobalScripterCreate event to make sure you initialize all scripter components in the system. The following steps show how to do that.
The OnGlobalScripterCreate is a global variable of type TNotifyEvent declared in Wf.Script.pas unit. First of all, you need to set that global variable to a method in your application:
{PrepareScripter is a method in any of your existing and instantiated classes}
OnGlobalScripterCreate := PrepareScripter;
Then you declare your global initialization method PrepareScripter. The Sender parameter is the scripter component, so you just need to typecast it to a generic TwfCustomScripter class. Here is an example:
Procedure TMyDataModule.PrepareScripter(Sender: Tobject);
begin
With TwfCustomScripter(Sender) do
begin
AddComponent(Form1);
end;
end;