Friday, December 7, 2007

Change status of Phone Call / Email Activity In CRM3.0

Change status of Phone Call / Email Activity In CRM3.0


You can change status of any activity by two ways.

Here I am showing example of Phone Call activity.

First Way:

try
{
CrmService service = new CrmService();
service.Url = ConfigurationManager.AppSettings["Url"];
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

SetStatePhoneCallRequest state = new SetStatePhoneCallRequest();

// Set the properties of the request object.
state.PhoneCallState = PhoneCallState.Completed;
state.PhoneCallStatus = -1;
state.EntityId = new Guid(“Guid of activity”);

SetStatePhoneCallResponse stateSet = (SetStatePhoneCallResponse)service.Execute(state);

}
catch (Exception ex)
{
string ms = ex.Message;
}



Second Way :


try
{
CrmService service = new CrmService();
service.Url = ConfigurationManager.AppSettings["Url"];
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

incident changest=new incident();

Status st=new Status();
st.Value=11;//Status code u want to set.
changest.statuscode=st;

changest.incidentid=new Key();
Guid gd=new Guid(CaseId);

changest.incidentid.Value=gd;

service.Update(changest);

}
catch (Exception ex)
{
string ms = ex.Message;
}

No comments: