I'm creating a custom workflow activity that requires that I gather account information for a third party application in the activity. Best I can tell, the custom activity only supports clear text fields. Is there a way to gather password information within an activity field that masks the user input?
Question
Question
Answer
Peter,
You can add a custom EditControl for your activity that contains a user control and any number of standard .NET Framework child controls. In your specific case you could might have a user control that contains a Textbox for the UserID and a Textbox with the PasswordChar property set for the password.
In the snip below from one of our Qfiche Toolkit custom workflow activities you can see an example of adding EditControls to your activity. The EditControls are actually user controls that contain standard .NET Framework Textbox, Combobox, Buttons, Radiobuttons, etc...
Replies
Please make sure you encrypt the data or the password will be visible in the workflow XML.
Thanks Cliff! This seems to be the only way to accomplish this. I was hoping there was a "simple" way I was missing. Your post here: http://answers.laserfiche.com/questions/94028/How-do-I-add-a-test-button-to-my-Workflow-custom-activity was very helpful. Ultimately, I think I need to get to something similar to your FTP example (a test "link button" would be nice also). Are you passing the serialized FtpDestination object to other activities? If that is how this works, it would be ideal for what I'm doing. It would let me define the settings for my connection in one location and then call that object in other locations.
Miruna's point brings up and issue for me. If I don't want to store the password in the workflow xml (not sure that is a huge issue yet), I'd need to encrypt it and return the encrypted password to my other activities. No problem there. But how does the activity know what to populate in the password textbox upon a refresh? Is there a way to define this? Maybe override the OnLoad event?
I'm also curious if the custom EditControl is documented somewhere. Seems like it should be but I had trouble finding anything beyond the basics of creating a custom activity.
Peter,
In reverse order;
The only custom EditControl example I have been exposed to is included in the Workflow SDK installation. There is a 'Samples' folder in the same folder as the Activity Proxy Generator.exe. The sample solution has a project called 'GetTagComments' that has a simple button custom EditControl. Everything else has been through my own research.
When you run your custom workflow activity through the Activity Proxy Generator there are options to make tokens available to other workflow activities. Not sure if you need to pass simple text tokens or more complex serialized objects but you can make those tokens available to other activities.
When I need to encrypt/decrypt connection information I use the System.Security.Cryptography namespace. In the example you mention I would do a decryption of the stored credentials in the UpdatePropertyPane Sub to update the controls and then I would do an encryption of the plain text in the controls in the Save sub. (So the actual workflow XML contains encrypted credentials)
In the example you mentioned I am not passing the serialized FtpDestination object to any other activity as everything FTP related is handled internally to the custom activity. I am confident though that you could pass a serialized object as a token to another activity. (I would check to see if there is perhaps a maximum token length that you might need to be aware of?)
I have the same question as the original one in this thread. I am new to using Custom Edit Controls, so I learned a lot reading through the thread, but am left without an answer. Is there an example that someone could supply to handle this case. I would think it is fairly common. Thanks in advance.
Mike,
Not quite sure what you are looking for but here are some pointers (hopefully not too basic);
To start with in the activity class I usually declare the properties that will contain the values for the control as type Object. I found that this will 'trick' the Proxy Generator into allowing you to select the new custom edit control instead of assuming you want to use an existing control type. (You can always edit the proxy code after it has been generated to use your new custom control no matter what code the generator spits out)
Next, in the custom control class you need to inherit from the Laserfiche.UI.EditPanel.EditPanelControlBase class. You also need to override some of the default methods. Here is a code snip for a very basic custom user control with only a textbox;
Imports Laserfiche.UI.EditPanel Public Class DemoUserControl Inherits EditPanelControlBase Private _textValue As String = String.Empty #Region "Default Method Overrides" Public Overrides Sub NotifyPanelShown() Me.UpdatePanel() End Sub Public Overrides Sub Save() Me.Value = _textValue End Sub #End Region #Region "Control Events" Private Sub ValueTextBox_TextChanged(sender As Object, e As System.EventArgs) Handles ValueTextBox.TextChanged _textValue = Me.ValueTextBox.Text Me.Save() End Sub #End Region #Region "Helpers" Private Sub UpdatePanel() _textValue = Me.Value Me.ValueTextBox.Text = _textValue End Sub #End Region End Class
The important points are the class level variable for the value of the control and the overrides of the OnNotifyPanelShown and Save methods.
Once the project is built you should now be able to select your new custom control as the control to use for editing the property in the Proxy Generator;
Typically our custom user controls contain many standard .NET controls not just a single textbox so the class level variable is more commonly an instance of a class that will contain all of the values for all of the controls in the custom control. We do our own serialization of the value class to store it in the activity class property. Something like this;
And in the UpdatePanel routine the value gets deserialized and the .NET controls are updated with the correct values;
Finally in the Save routine the class is serialized and stored in the controls Value property;
Let me know if you need additional information or have specific questions.