Use script block

How to use the script block in the workflow and run it from code ?

I want to create a workflow on startup, run a script to retrieve a value from a table in my database. When I check my workflow, an error occurs.

xxx_ID: =: xxx_ID;

I want to use this value in one of workflow tasks.


Hi Alexandre,

sorry but I couldn't understand exactly what you are trying to achieve. Can you be more specific, maybe giving an example? And what kind of error do you get? If you can please also post some Delphi/script code, thanks.

1 – I want to link the WSWORKFLOWINSTANCE table, to another
table XXX (primary key XXX_ID) of my database<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

For this, I added a foreign key in the

I want to display all tasks in
progress for a

2 – In
my workflow, I want to assign a value in the fields
XXX_ID through a
in the workflow

Script block :
xxx_ID: =: xxx_ID;<o:p></o:p>

I get an
error, which is:<o:p></o:p>

« Error while compiling script block. Syntax error. »<o:p></o:p>

Another question,<o:p></o:p>

 how to update variables in the workflow, by
the code and not by the editor?<o:p></o:p>


Finally, I used the variables of the workflow to update the fields

wfi : TWorkflowInstance;
wvar: TWorkflowVariable;
wvar := wfi.Diagram.Variables.FindByName('OrderNo');
if Assigned(wvar) then
wvar.Value := AOrderNo;

Hi Alexandre,

I'm glad you solved your problem. Just for the record, most users use a different approach. Changing the workflow tables is not very safe when it comes to future upgrades. Usually users do the opposite: after creating the workflow instance, they save the id of newly created instance in a table associated with your application. Just to be clearer, instead of saving XXX_ID in workflow table, you save the workflow id in the XXX table (or an intermediate table with both workflowID and XXX_ID).

Thank you for these details.