Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Custom Workflow Activities

  • 1.  Custom Workflow Activities

    GOLD CONTRIBUTOR
    Posted 25 days ago
    Here is one for developers.

    I've written a custom workflow activity to use in workflows. So far, success.

    Now I want to extend the assembly to include three activities in the one package. I can see how to do that. However, there is a reasonable amount of shared code between the three activities (mostly to do with authenticating to an external system).  I haven't figured out how to make this shared code available to each of the activities as opposed to including the code in each activity class. Is this possible?

    Here is some pseudo-code of what I mean, any advice would be gratefully received.
    namespace Feridun.CustomActivities
    {
        public class activity1 : CodeActivity
        {
            // input and output parameters omitted for clarity
     
            protected override void Execute(CodeActivityContext activityContext)
            {
                // authenticate with other system   - CAN THIS CODE BE MADE AVAILABLE TO ALL THREE CodeActivity classes?
     
                // do somestuff
     
            }
        }
     
        public class activity2 : CodeActivity
        {
            protected override void Execute(CodeActivityContext activityContext)
            {
                // authenticate with other system
     
                // do some other stuff
            }
        }
     
        public class activity3 : CodeActivity
        {
     
            protected override void Execute(CodeActivityContext activityContext)
            {
                // authenticate with other system
     
                // do some different stuff
            }
        }
    }




    ------------------------------
    Feridun Kadir
    Principal Consultant, MVP
    Expert CRM Services Ltd
    Stansted
    ------------------------------


  • 2.  RE: Custom Workflow Activities

    GOLD CONTRIBUTOR
    Posted 25 days ago
    Hello Feridun,
    You can check code that I use in my Ultimate Workflow Toolkit:
    Here is the base class for all my activities - https://github.com/a33ik/UltimateWorkflowToolkit/blob/master/Common/CrmWorkflowBase.cs
    And depending on what I need to do I inherit my custom workflow activities from base class and use methods from it:
    For example this - OppoerunityWin - https://github.com/a33ik/UltimateWorkflowToolkit/blob/master/CoreOperations/Opportunity/OpportunityWin.cs

    Feel free to ask more questions.

    ------------------------------
    Andrew Butenko
    ------------------------------



  • 3.  RE: Custom Workflow Activities

    GOLD CONTRIBUTOR
    Posted 12 days ago
    Thank you Andrew, I will review your code.

    Much appreciated.

    ------------------------------
    Feridun Kadir
    Principal Consultant, MVP
    Expert CRM Services Ltd
    Stansted
    ------------------------------