Print Page | Close Window

Retriving all variables from a worfklow instance

Printed From: TMS Software
Category: VCL Components
Forum Name: VCL Workflow Studio
Forum Discription:
Printed Date: 30 May 2020 at 1:07pm

Topic: Retriving all variables from a worfklow instance
Posted By: Sharlandjiev Kamen
Subject: Retriving all variables from a worfklow instance
Date Posted: 09 Mar 2017 at 4:10pm
I'm trying to get all workflow instance variables & their values when a SendEmail block is executed.
I need this outside of the script, as I'm trying to send HTML email, and by some reason WS.ScriptEngine.TranslateText is returning a parse error when the input is a big string containing HTML.
Anyway... I tought this will be quite easy as in OnSendMail event we should get a TaskIns: TTaskInstance; as input.
So in theory, having the Task Instance, I can get the workflow instance (TaskIns.WorkInsKey) and get the paramenters from the Workflow instance, BUT....

It seems you guys are passing nil instead the actual TaskInstance, or tleast this is what I'm seeing in
wsBlocks.pas -> procedure TWorkflowSendMailBlock.DoExecuteEx(var ExecInfo: TExecuteNodeInfo);

After assigning all attributes to emailInfo, you are calling:
WS.SendMail(nil, nil, emailInfo);

So my question is, is there any way I can get the actual taskInstance,
Is there any other way I can get all variables onSend
Is there a way to pass a big HTML string trough WS.ScriptEngine.TranslateText

Any of these will work perfectly fine for me.
Thanks In advance.

Posted By: Sharlandjiev Kamen
Date Posted: 09 Mar 2017 at 4:48pm
Okay, just a small update from me, and Hopefully an advise if I'm doing something crazy!
Looking down the source code, I've realised that TTaskInstance is called only for Task blocks!
So basically There is no info passed to the OnSendEmail which can give me the opportunity to get the WfInstance.
So What I've done is to adjust the TEmailInformation record in wsClasses, to contain a TWorkflowInstance element, that I'm now passing in every TEmailInformation.
So in wsBlocks I now have:

emailInfo.WorkFlowInstance := WorkflowDiagram.WorkflowInstance;
WS.SendMail(nil, nil, emailInfo);

And tada! I'm now able to get all variables!

It's not the most elegant solution but it work for me :)
Any advise on how to make this in a better way are welcome.

Posted By: Wagner R. Landgraf
Date Posted: 09 Mar 2017 at 7:54pm
I think it's acceptable. Ideally, the SendMail method/event should have an additional TWorkflowInstance parameter. But since this will break backward compatibility and might cause headaches with existing code base, adding such info in the TEMailInformation is indeed a good solution.

Print Page | Close Window