locked
Send email to the marketing director when the customer credit limit is updated RRS feed

  • Question

  • Hi, how can I create a workflow that allows to send an email to the marketing director (jhonhernandez300@gmail.com)when the customer credit limit is updated to 5 000? 

    Tuesday, November 14, 2017 8:38 PM

All replies

  • Please create a workflow which should trigger on update of Credit Limit field. Check the condition that that the data in Credit Limit field is greater than 5000. If it is then send email by adding a step.
    Wednesday, November 15, 2017 1:38 PM
  • OK... and by code, how this can be done?

    I have this part

    #region Properties 
           
            [Output("Get email"), ReferenceTarget("email")]
            public OutArgument<EntityReference> Email { get; set; }

            private ITracingService m_tracingService;
            #endregion

            private void Trace(string message)
            {
                if (this.m_tracingService != null)
                {
                    this.m_tracingService.Trace(message);
                }
            }

                  
            public void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext)
            {

                if (crmWorkflowContext == null)
                {
                    throw new ArgumentNullException("crmWorkflowContext");
                }

                try
                {
                    IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
                    IOrganizationServiceFactory factory = executionContext.GetExtension<IOrganizationServiceFactory>();
                    IOrganizationService service = factory.CreateOrganizationService(context.UserId);
                    m_tracingService = executionContext.GetExtension<ITracingService>();

                    EntityReference emailTosend = new EntityReference();
                    Run(service, Registration.Get(executionContext), out emailTosend);
                    Email.Set(executionContext, emailTosend);
                }
                catch (FaultException<OrganizationServiceFault> e)
                {
                    // Handle the exception.
                    throw e;
                }

            }

            public void Run(IOrganizationService service, EntityReference registerReference, out EntityReference emailToSend)
            {
                //the rest goes here
            }

    • Edited by Jhon2905 Wednesday, November 15, 2017 4:20 PM
    Wednesday, November 15, 2017 4:17 PM