locked
Help on creating workflow with query filtering.. RRS feed

  • Question

  • Hello to all... kindly help me with this matter... Thank you...
     

    using System;
    using System.Collections;
    using System.Workflow.ComponentModel.Compiler;
    using System.Workflow.ComponentModel.Serialization;
    using System.Workflow.ComponentModel;
    using System.Workflow.ComponentModel.Design;
    using System.Workflow.Runtime;
    using System.Workflow.Activities;
    using System.Workflow.Activities.Rules;
    using System.Reflection;

    using Microsoft.Crm.Workflow;
    using Microsoft.Crm.Sdk;
    using Microsoft.Crm.SdkTypeProxy;
    using Microsoft.Crm.Sdk.Query;

    namespace CPEComputation.workflow
    {
        [CrmWorkflowActivity("CPE Computation", "Programing Microsoft CRM4")]
        public class CPECredits : Activity
        {
            [CrmInput("CPE Member")]
            public Lookup CPEMember
            {
                get
                {
                    return (Lookup)base.GetValue(CPECreditProperty);
                }
                set
                {
                    base.SetValue(CPECreditProperty, value);
                }

            }

            public static DependencyProperty CPECreditProperty =
               DependencyProperty.Register("CPE Credits",
               typeof(CrmNumber),
               typeof(CPECredits));


            public static DependencyProperty resultProperty = DependencyProperty.Register("result",
                typeof(CrmNumber),typeof(CPECredits));

            [CrmOutput("result")]
            public CrmNumber result
            {
                get
                {
                    return (CrmNumber)base.GetValue(resultProperty);
                }
                set
                {
                    base.SetValue(resultProperty, value);
                }

            }

            protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
            {
                /*
                 *  How to create SQL Query like this
                 * 
                 * SELECT SUM(CPEcredits) as Total cpe from filteredCampaign where account.name = + " CPEMember " + AND
                 * statecodename = Active
                 */

                QueryExpression query = new QueryExpression();
                query.EntityName = "campaign";

                result = new CrmNumber(CPECredit.Value + EarnedCredits.Value);
                return base.Execute(executionContext);
            }

        }
    }
    Zosimo D. Recio Jr. Microsoft Certified (Business Management Solutions specialist)
    Tuesday, June 23, 2009 8:24 AM

Answers