Hi guys,

I am trying to programmatically close a phonecall activity, but I must
be missing something. I get a "Server was unable to process request."
(Not entirely descriptive!)

My code looks as follows:

private void CloseCall(string callId)
{
using (CrmService svc =
ServiceFactory.GetWebService<CrmService>())
{
ColumnSet cols = new ColumnSet();
cols.Attributes = new string[] {"activityid",
"statecode",
"statuscode"};
phonecall entity =
(phonecall)svc.Retrieve(EntityName.phonecall.ToString(), new
Guid(callId), cols);
entity.statecode.Value = PhoneCallState.Completed;
entity.statuscode.Value = 2;
svc.Update(entity);
}
}

What am I missing? Would it be enough to just set the Value property of
the statuscode field to 2?

Thanks again for all the help!

--
Ernst Kuschke
MVP - C#
http://dotnet.org.za/ernst

Re: Programmatically closing an Activity by Jeffry

Jeffry
Fri Aug 25 05:55:35 CDT 2006

You can't change the statecode field. You have to use the
SetStatePhoneCallRequest message.

Also, wrap your call to the webservice in a try/catch, catch the
SoapException and read the Detail.InnerXml. That will give you a more
descriptive error message (most of the time anyways :)

HTH,

--
Jeffry van de Vuurst
CWR Mobility
www.cwrmobility.com
--
"Ernst Kuschke (C# MVP)" <ernst.k@gmail.com> wrote in message
news:1156499085.821711.233670@m73g2000cwd.googlegroups.com...
> Hi guys,
>
> I am trying to programmatically close a phonecall activity, but I must
> be missing something. I get a "Server was unable to process request."
> (Not entirely descriptive!)
>
> My code looks as follows:
>
> private void CloseCall(string callId)
> {
> using (CrmService svc =
> ServiceFactory.GetWebService<CrmService>())
> {
> ColumnSet cols = new ColumnSet();
> cols.Attributes = new string[] {"activityid",
> "statecode",
> "statuscode"};
> phonecall entity =
> (phonecall)svc.Retrieve(EntityName.phonecall.ToString(), new
> Guid(callId), cols);
> entity.statecode.Value = PhoneCallState.Completed;
> entity.statuscode.Value = 2;
> svc.Update(entity);
> }
> }
>
> What am I missing? Would it be enough to just set the Value property of
> the statuscode field to 2?
>
> Thanks again for all the help!
>
> --
> Ernst Kuschke
> MVP - C#
> http://dotnet.org.za/ernst
>



Re: Programmatically closing an Activity by Ernst

Ernst
Mon Aug 28 04:15:56 CDT 2006

Thanks Jeffry. I do have try...catch blocks around my code ;o)
Unfortunately the InnerException is null in this case.
I'll pass an SetStatePhoneCallRequest to the Execute webmethod,
thanks!!!

-Ernst

Jeffry van de Vuurst wrote:
> You can't change the statecode field. You have to use the
> SetStatePhoneCallRequest message.
>
> Also, wrap your call to the webservice in a try/catch, catch the
> SoapException and read the Detail.InnerXml. That will give you a more
> descriptive error message (most of the time anyways :)
>
> HTH,
>
> --
> Jeffry van de Vuurst
> CWR Mobility
> www.cwrmobility.com
> --
> "Ernst Kuschke (C# MVP)" <ernst.k@gmail.com> wrote in message
> news:1156499085.821711.233670@m73g2000cwd.googlegroups.com...
> > Hi guys,
> >
> > I am trying to programmatically close a phonecall activity, but I must
> > be missing something. I get a "Server was unable to process request."
> > (Not entirely descriptive!)
> >
> > My code looks as follows:
> >
> > private void CloseCall(string callId)
> > {
> > using (CrmService svc =
> > ServiceFactory.GetWebService<CrmService>())
> > {
> > ColumnSet cols = new ColumnSet();
> > cols.Attributes = new string[] {"activityid",
> > "statecode",
> > "statuscode"};
> > phonecall entity =
> > (phonecall)svc.Retrieve(EntityName.phonecall.ToString(), new
> > Guid(callId), cols);
> > entity.statecode.Value = PhoneCallState.Completed;
> > entity.statuscode.Value = 2;
> > svc.Update(entity);
> > }
> > }
> >
> > What am I missing? Would it be enough to just set the Value property of
> > the statuscode field to 2?
> >
> > Thanks again for all the help!
> >
> > --
> > Ernst Kuschke
> > MVP - C#
> > http://dotnet.org.za/ernst
> >


Re: Programmatically closing an Activity by Jeffry

Jeffry
Mon Aug 28 05:29:24 CDT 2006

Hi Ernst,

You don't want the InnerException in this case, but the Detail property of
the SoapException. Unfortunately, CRM hides all the original exceptions and
just returns a new SoapException. You can find the original exception in the
log files when you enable tracing on the server.

--
Jeffry van de Vuurst
CWR Mobility
www.cwrmobility.com
--
"Ernst Kuschke (C# MVP)" <ernst.k@gmail.com> wrote in message
news:1156756556.154056.144530@m79g2000cwm.googlegroups.com...
> Thanks Jeffry. I do have try...catch blocks around my code ;o)
> Unfortunately the InnerException is null in this case.
> I'll pass an SetStatePhoneCallRequest to the Execute webmethod,
> thanks!!!
>
> -Ernst
>
> Jeffry van de Vuurst wrote:
>> You can't change the statecode field. You have to use the
>> SetStatePhoneCallRequest message.
>>
>> Also, wrap your call to the webservice in a try/catch, catch the
>> SoapException and read the Detail.InnerXml. That will give you a more
>> descriptive error message (most of the time anyways :)
>>
>> HTH,
>>
>> --
>> Jeffry van de Vuurst
>> CWR Mobility
>> www.cwrmobility.com
>> --
>> "Ernst Kuschke (C# MVP)" <ernst.k@gmail.com> wrote in message
>> news:1156499085.821711.233670@m73g2000cwd.googlegroups.com...
>> > Hi guys,
>> >
>> > I am trying to programmatically close a phonecall activity, but I must
>> > be missing something. I get a "Server was unable to process request."
>> > (Not entirely descriptive!)
>> >
>> > My code looks as follows:
>> >
>> > private void CloseCall(string callId)
>> > {
>> > using (CrmService svc =
>> > ServiceFactory.GetWebService<CrmService>())
>> > {
>> > ColumnSet cols = new ColumnSet();
>> > cols.Attributes = new string[] {"activityid",
>> > "statecode",
>> > "statuscode"};
>> > phonecall entity =
>> > (phonecall)svc.Retrieve(EntityName.phonecall.ToString(), new
>> > Guid(callId), cols);
>> > entity.statecode.Value = PhoneCallState.Completed;
>> > entity.statuscode.Value = 2;
>> > svc.Update(entity);
>> > }
>> > }
>> >
>> > What am I missing? Would it be enough to just set the Value property of
>> > the statuscode field to 2?
>> >
>> > Thanks again for all the help!
>> >
>> > --
>> > Ernst Kuschke
>> > MVP - C#
>> > http://dotnet.org.za/ernst
>> >
>