none
Problem with Custom Workflow Activity RRS feed

  • Question

  • Hi,

    After a bit of struggling and a lot of help from Frank I managed to write a custom workflow activity in VB using visual studio 2010. The activity basically returns today's date according to a format you specify and pass this to a workflow parameter also specified through the designer.  I used the logging request example converted to a VB version by someone as well as some examples from Cortego ILM2 activity libraries.  This part works 100%

    Problems I am having is:

    1. I am trying to set the activity title to some text specified during the configuartion of the workflow, although it appears to be a simple task acording to the example, I just can't get it right.  I am doing this in VB which is different than C#. Any help or suggestions around this will be appreciated.

    2. The second issue is that it seems that activity is not properly saved to / registered with the workflow (apologies if I use wrong terminology).  Although it saves with the workflow it is not possible to edit it when the workflow is opened and shows the error below.

    Also note that the activity name reflects the namespace, which I think is part of the problem but has no idea as to what can be the cause of this,there are no errors or warning displayed in teh code or during the installation. Again I would appreciate any help with this.

    Thanks

    Johan Marais


    JkM6228

    Friday, May 11, 2012 4:17 PM

Answers

  • Johan,

    The custom title should only be displayed when the activity is in read-only mode (non-edit). You can add a property to hold the current state of the activity and adjust the displayed title based on the state with the following:

    Private currentMode As ActivitySettingsPartMode = ActivitySettingsPartMode.Edit
    
    Public Override Sub SwitchMode(mode As ActivitySettingsPartMode)
        Me.currentMode = mode
    End Sub
    
    Public Override ReadOnly Property Title() As String
        Get
            Dim result As String
            If Me.currentMode = ActivitySettingsPartMode.Edit Then
                result = "Default Title for Activity"
            Else
                Me.EnsureChildControls()
                result = String.Format("Custom Property is: <span style=""color: blue; text-decoration: underline;"">[{0}]</span> Property2: <span style=""color: blue; text-decoration: underline;"">[{1}]</span>", property1, property2)
            End If
            Return result
        End Get
    End Property
    
    Hope this helps,

    • Marked as answer by Johan Marais Thursday, May 17, 2012 5:37 AM
    Wednesday, May 16, 2012 12:15 PM

All replies

  • The problem looks to be that the activitySettingsPart (aka UI) isn't recognized by FIM. The UI part is usually the biggest pain...

    In my example I named them like this..

    namespace FIM.CustomActivity
    {
        class TimeForm : Microsoft.IdentityManagement.WebUI.Controls.ActivitySettingsPart

    so in the AIC, I use   " FIM.CustomActivity.TimeForm  " as the " Type Name " - you add the namespace and the class name..

    Once that's fixed, title should work. You simply override the implemented interface property "Title" - which VS probably does for you -

    I used

    public override string Title
            { get  {return "Time Activity";} }

    or you can get really fancy and use one of the fields in the UI to specify the Title along with other items like the assembly version. In this example, I have a checkbox that allows me to disable the activity without having to remove it. All this kind of stuff I keep in a template so the next activity development time is less than half.

     public override string Title
            {
                get
                {
                    string isActive = string.Empty;
                    switch (_enableWorkflow.Value)
                    {
                        case true:
                            isActive = " (Active)";
                            break;
                        case false:
                            isActive = " (Disabled)";
                            break;
                    }


                    return "[Transform Resource " + this.GetType().Assembly.GetName().Version.ToString()  +"] " + _activityTitle.Value + isActive;
                }
            }


    Frank C. Drewes III - Senior Consultant: Oxford Computer Group

    Friday, May 11, 2012 4:59 PM
  • Frank,

    Thanks for the reply.  I verified the above and my code is similar to yours above.  When I create a new workflow I can add my custom activity, and provide the input strings, which are:

    1. Title

    2. date format string

    3. Workflow parameter

    When I click 'Save' on the activity it updates the title with what I have typed in the textbox, but the difference is that it is not displayed like a hyperlink as with the Function Evaluater activity.  I think this is becasue the activity is not really saved.  Then when teh workflow is saved and opened again, the message in teh graphic in my first post is displayed.

    I wonder, isn't there a MPR which needs updating to be able to do this from custom WF activities?  (Did'nt see anything in all documentation I reviewed unless it is assumed.)

    Regards

    Johan Marais


    JkM6228

    Monday, May 14, 2012 8:02 AM
  • Hi,

    Glad to be finally reporting that everything is now working as expected.  think the problem was the fact that I used so many examples and code snipits and although there were no compile and build errors, the program flow was not what it should be.  I decided to rewrite the whole activity yesterday, and everything started to work.

    Thanks again for all the help and patience.

    Johan Marais


    JkM6228

    Tuesday, May 15, 2012 10:06 AM
  • To get the title to display the blue-underlined text similar to a hyperlink, wrap the text in the following span:

    String someVar = String.Format("<span style=\"color: blue; text-decoration: underline;\">{0}</span>", strText);
    Add that as part of your Title text and it will display in blue-underline when not in Edit mode.
    Tuesday, May 15, 2012 12:51 PM
  • Hi Mgercevich,

    I am using Visual Basic from VS 2010, looked for a similar command but couldn't find anything.  Is this possible in VB?  Or should I add a specific reference to the project for this to become available.

    Thanks

    Johan


    JkM6228

    Wednesday, May 16, 2012 6:26 AM
  • Johan,

    The custom title should only be displayed when the activity is in read-only mode (non-edit). You can add a property to hold the current state of the activity and adjust the displayed title based on the state with the following:

    Private currentMode As ActivitySettingsPartMode = ActivitySettingsPartMode.Edit
    
    Public Override Sub SwitchMode(mode As ActivitySettingsPartMode)
        Me.currentMode = mode
    End Sub
    
    Public Override ReadOnly Property Title() As String
        Get
            Dim result As String
            If Me.currentMode = ActivitySettingsPartMode.Edit Then
                result = "Default Title for Activity"
            Else
                Me.EnsureChildControls()
                result = String.Format("Custom Property is: <span style=""color: blue; text-decoration: underline;"">[{0}]</span> Property2: <span style=""color: blue; text-decoration: underline;"">[{1}]</span>", property1, property2)
            End If
            Return result
        End Get
    End Property
    
    Hope this helps,

    • Marked as answer by Johan Marais Thursday, May 17, 2012 5:37 AM
    Wednesday, May 16, 2012 12:15 PM
  • Mgercevich,

    Thanks for the help.

    Regards

    Johan


    JkM6228

    Thursday, May 17, 2012 5:38 AM
  • The description above is a good explanation. The blue underline is just some fancy formtting Mcrosoft has done, and isn't at all a requirement.

    As far as the Title value, the comment above that "The custom title should only be displayed when the activity is in read-only mode (non-edit)." is not a requirement, but is a UI option you can choose to use, but again, not something you *must* do..

    Production SettingsParts I use in consulting jobs have a lot of that fancy stuff (including our logo and license info) but something every simple will work just fine. The more you experiment, the more experienced and confident you'll feel in understanding what's happeneing.

    If you want to really see what's going on behind the scenes, attach the debugger to the W3WP.exe process(es) and set breakpoints on all your methods and you'll see exactly what gets called when. It's a great exercise to do at least once.


    Frank C. Drewes III - Senior Consultant: Oxford Computer Group

    Thursday, May 17, 2012 6:43 AM