0

I'm trying to open a new phone activity in Microsoft Crm5 by clicking on a button in my windows application. I used Microsoft.xrm.sdk I already can open a new phone activity. I even set the subject and phone number, but I can't set "regardingto look up".

Here is my code:

var extraqs = string.Format("phonenumber={0}&subject={1}{2}", tel1,   HttpUtility.UrlEncode("Calling from "), HttpUtility.UrlEncode(customerName));
extraqs += "&regardingobjectidtype=customer";
extraqs += "&regardingobjectid={" + guid + "}";
extraqs += "&regardingobjectidname=" + customerName;
_url = string.Format("{0}/Activities/phone/edit.aspx?{1}", crmAddress, extraqs);

Process.Start(@"C:\Program Files\Internet Explorer\iexplore.exe", _url);

my regardingto lookup is the list of customers entity. If I remove regardingobjectidtype from parameters, I have no error, but my lookup is not set well. just show the customer name, and form cannot be register. when I add regardingobjectidtype in url parameters, I receive an error and form does not show.

2 Answers2

2

I finally found the answer,

First of all, I shouldn't use HttpUtility.UrlEncode() I should use Uri.EscapeUriString() for encoding url. Second, I should use pId instead of regardingobjectid and third I should set look up type = 1 not "account".

Here is the right code:

var extraqs = string.Format("phonenumber={0}&subject={1}{2}", tel1, "Calling from ", customerName);
extraqs += "&pType=1";
extraqs += "&pId={" + guid + "}";
extraqs += "&pName=";

extraqs += "&partytype=1";
extraqs += "&partyid={" + guid + "}";
extraqs += "&partyname=";

_url = string.Format("{0}/Activities/phone/edit.aspx?{1}", crmAddress, Uri.EscapeUriString(extraqs));
Community
  • 1
  • 1
0

Try to us following code:

var extraqs = string.Format("phonenumber={0}&subject={1}{2}", tel1,   HttpUtility.UrlEncode("Calling from "), HttpUtility.UrlEncode(customerName));
extraqs += "&pType=account";
extraqs += "&pId={" + guid + "}";
extraqs += "&pName=" + customerName;

Remember that there is no entity called 'customer'. account and contact are but not customer.

Andrew Butenko
  • 5,048
  • 1
  • 14
  • 13
  • Try to use something like: string extraqs = HttpUtility.UrlEncode(string.Format("phonenumber={0}&subject={1}{2}&pType=account&pId={3}&pName={2}", new string[] { tel1, "Calling from ", customerName, guid })); _url = string.Format("{0}/main.aspx?etn=phonecall&extraqs={1}", crmAddress, extraqs); Process.Start(@"C:\Program Files\Internet Explorer\iexplore.exe", _url); – Andrew Butenko Mar 04 '14 at 16:11