Muhammad Ali Khan

MS CRM 3.0, MS CRM 4.0, Sharepoint 2007 & Sharepoint 2010

Close Service Activity On Create Message In PlugIn

Posted by Ali Khan on February 19, 2010

Here is a simple code to close the service activity in a MS CRM Plugin.

  1: SetStateServiceAppointmentRequest req = new SetStateServiceAppointmentRequest();
  2: req.ServiceAppointmentState = ServiceAppointmentState.Closed;
  3: req.ServiceAppointmentStatus = 8;
  4: req.EntityId = new Guid(context.OutputParameters["id"].ToString());
  5: SetStateServiceAppointmentResponse resp = (SetStateServiceAppointmentResponse)crmService.Execute(req);

But the above code will work perfectly only if the message is Post Update but doesn’t work if the message is Post Create means it doesn’t close the service activity. Strangely, it doesn’t give any error as well. To add to my surprise, if you had configure any plugin on “SetState” or “SetStateDynamic” for serviceappointment even those plugin will be trigger, but the state of the service activity will not change. Why?, i am not sure.

But does this means we cannot close service activity on the “Create” message?, well the trick is to register the above plug-in as Asynchronous mode (as shown below). now the above message will Close the Service Activity even on the Create Message.

image

Advertisements

2 Responses to “Close Service Activity On Create Message In PlugIn”

  1. William Harry said

    I have been reading a few of your posts and have enjoyed it. Keep it up

  2. how to get a blog…

    Close Service Activity On Create Message In PlugIn « Muhammad Ali Khan…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: