アドレスレコードを作成しようとしていますが、エラーが発生し続けます。MS CRM:アドレスレコードを作成すると無効な属性値型エラーが発生する
public const int OBJECT_TYPE_CONTACT = 2;
int addressTypeCode = 3; //Primary Address
if (i == 2) addressTypeCode = 1; //Billing Address
if (i == 3) addressTypeCode = 2; //Shipping Address
Entity newAddress = new Entity("customeraddress");
newAddress.Attributes["parentid"] = new EntityReference("contact", existingContact.Id);
newAddress.Attributes["addresstypecode"] = addressTypeCode;
newAddress.Attributes["objecttypecode"] = OBJECT_TYPE_CONTACT;
newAddress.Attributes["line1"] = "temp1";
newAddress.Attributes["line2"] = "temp2";
newAddress.Attributes["line3"] = "temp3";
newAddress.Attributes["city"] = "temp3";
newAddress.Attributes["stateorprovince"] = "temp3";
newAddress.Attributes["postalcode"] = "temp3";
newAddress.Attributes["country"] = "temp3";
Guid id = service.Create(newAddress);
エラーがobjecttypecodeを設定する行にスローを次のように
The application terminated with an error.
Code: -2147220989
Message: Incorrect attribute value type System.Int32
コードです。私はエラーコードが "無効な引数"を意味することを知っています。解決策2では連絡先を参照するので、問題の内容はわかりません。
エラーは、実際には 'Guid id = service.Create(newAddress);'という行を投げています。 'Entity'クラスは型の認識を持たないので、そのエラーは' Entity.Attributes'コレクションの項目を追加/変更することは決してありません。 'CrmSvcUtil.exe'の初期バインドタイプを使用すると、警告をタイプすることができます。 – Nicknow