Question

I have a workflow activity which I use to send out e-mails to suppliers on a regular basis and scheduling follow-up phone calls etc if there is no reply. However my problem is that I somehow need to retrieve the e-mail for each supplier before sending the message.

How can I go about retrieving the value in a specific field from a specific entity in CRM 2011?

Here is the pseudo-code:

For each supplier entity in the system {

     if (sendSalesRequest) {

          Send Initial E-mail
          - wait 21 days
          if (noReply) {
              Send Follow up e-mail
              - wait 7 days
              if (noFollowupReply) {
                 schedule phone call activity everyday until reply
              }
          }
      }
}

However, I need a way of retrieving the e-mail address from the suppler entity.

I'm not looking for a worked solution (though I wouldn't turn it down!), just guidelines on how to go about this task as I'm brand new to CRM development.

Thanks,

Tysin

Was it helpful?

Solution

If your new to 2011 I would suggest reading about the SDK. In particular you need to look at custom workflow activity development. It has a number of samples which should help you along the way.

I would suggest having:

  1. A master workflow, that has a single step to call your custom workflow activity which processes the suppliers. You start this workflow whenever you want to process all the suppliers.
  2. An on-demand workflow that sends the initial email
  3. An on-demand workflow that sends the follow up email
  4. An on-demand workflow that schedules the phone call

The reason I suggest this is that means you keep the creation of data in workflows where is it easier to manage and handle. E.g. you could change the email message without recompiling your custom workflow activity.

So first step in your master custom workflow activity, is to query Crm, I would suggest a QueryExpression to start with. That way you can get the data to base you logic on.

Then you need some code to start a workflow against a record, to send the email and phones calls. There is an example for this here.

Then you code would look a little like this:

    QueryExpression query = new QueryExpression("supplier");
    query.ColumnSet = new ColumnSet("sendsalesrequest", "noreply", "nofollowupreply");

    EntityCollection entities = service.RetrieveMultiple(query);
    entities.Entities.ToList().ForEach(entity => 
        {
            if(entity["sendsalesrequest"] == "Yes")
            {
                StartWorkflow(entity.Id, "Send Initial E Mail Workflow Name");
            }
            //etc
        }

This is quite high level but should hopefully get you going in the right direction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top