Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Use script block

 Post Reply Post Reply
Author
BRANQUART Alexandre View Drop Down
New Member
New Member
Avatar

Joined: 21 Sep 2011
Posts: 8
Post Options Post Options   Quote BRANQUART Alexandre Quote  Post ReplyReply Direct Link To This Post Topic: Use script block
    Posted: 23 May 2012 at 8:10am
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.

script:
xxx_ID: =: xxx_ID;

I want to use this value in one of workflow tasks.
Thank's
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2434
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 23 May 2012 at 11:48am
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.
Back to Top
BRANQUART Alexandre View Drop Down
New Member
New Member
Avatar

Joined: 21 Sep 2011
Posts: 8
Post Options Post Options   Quote BRANQUART Alexandre Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 2012 at 2:36am

1 I want to link the WSWORKFLOWINSTANCE table, to another table XXX (primary key XXX_ID) of my database

For this, I added a foreign key in the table WSWORKFLOWINSTANCE.

I want to display all tasks in progress for a XXX_ID.

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

Script block : xxx_ID: =: xxx_ID;

I get an error, which is:

 Error while compiling script block. Syntax error. 

Another question,

 how to update variables in the workflow, by the code and not by the editor?

Thanks

Back to Top
BRANQUART Alexandre View Drop Down
New Member
New Member
Avatar

Joined: 21 Sep 2011
Posts: 8
Post Options Post Options   Quote BRANQUART Alexandre Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 2012 at 2:37am
Originally posted by BRANQUART Alexandre

1 I want to link the WSWORKFLOWINSTANCE table, to another table XXX (primary key XXX_ID) of my database

For this, I added a foreign key in the table WSWORKFLOWINSTANCE.

I want to display all tasks in progress for a XXX_ID.

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

Script block : xxx_ID: =: xxx_ID;

I get an error, which is:

 Error while compiling script block. Syntax error. 

Another question,

 how to update variables in the workflow, by the code and not by the editor?

Thanks

Back to Top
BRANQUART Alexandre View Drop Down
New Member
New Member
Avatar

Joined: 21 Sep 2011
Posts: 8
Post Options Post Options   Quote BRANQUART Alexandre Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 2012 at 4:02am

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

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

Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2434
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 2012 at 8:36am
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).
Back to Top
BRANQUART Alexandre View Drop Down
New Member
New Member
Avatar

Joined: 21 Sep 2011
Posts: 8
Post Options Post Options   Quote BRANQUART Alexandre Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 2012 at 9:32am
Hi,
 
Thank you for these
details.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down