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

Retriving all variables from a worfklow instance

 Post Reply Post Reply
Author
Sharlandjiev Kamen View Drop Down
New Member
New Member
Avatar

Joined: 17 Feb 2017
Posts: 8
Post Options Post Options   Quote Sharlandjiev Kamen Quote  Post ReplyReply Direct Link To This Post Topic: Retriving all variables from a worfklow instance
    Posted: 09 Mar 2017 at 4:10pm
Hello,
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,
OR
Is there any other way I can get all variables onSend
OR
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.
K.
Back to Top
Sharlandjiev Kamen View Drop Down
New Member
New Member
Avatar

Joined: 17 Feb 2017
Posts: 8
Post Options Post Options   Quote Sharlandjiev Kamen Quote  Post ReplyReply Direct Link To This Post 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.
K.


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

Joined: 18 May 2010
Posts: 2403
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down