|
![]() |
#1 |
Участник
|
Подскажите пожалуйста, из за чего ошибка.
Компилятору не нравиться последняя строка -> proxy.Create(sq); и выдает такую ошибку: An unhandled exception of type 'System.ServiceModel.FaultException`1' occurred in Microsoft.Xrm.Sdk.dll Additional information: The expected returnedTypeCode 3 did not match the return type 1 on fetchXml Вот код: X++: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using System.ServiceModel.Description; using System.Runtime.Serialization; // These namespaces are found in the Microsoft.Xrm.Sdk.dll assembly // found in the SDK\bin folder. using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Client; using Microsoft.Xrm.Sdk.Query; namespace CreateView { class Program { static void Main(string[] args) { // Подключаемся к CRM ClientCredentials credentials = new ClientCredentials(); credentials.Windows.ClientCredential = new System.Net.NetworkCredential("Администратор", "12345", "crm.dev"); Uri uri = new Uri("http://192.168.57.50:80/NoName/XRMServices/2011/Organization.svc"); OrganizationServiceProxy proxy = new OrganizationServiceProxy(uri, null, credentials, null); proxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior()); IOrganizationService service = (IOrganizationService)proxy; // Create the view. string layoutXml = @"<grid name='resultset' object='1' jump='accountid' select='1' preview='1' icon='1'> <row name='result' id='accountid'> <cell name='name' width='150' /> <cell name='customerid' width='150' /> <cell name='primarycontactid' width='150' /> <cell name='telephone1' width='150' /> </row> </grid>"; //fetch example string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='account'> <attribute name='name' /> <attribute name='primarycontactid' /> <attribute name='telephone1' /> <attribute name='accountid' /> <order attribute='name' descending='false' /> <filter type='and'> <condition attribute='name' operator='eq' value='qwe' /> </filter> </entity> </fetch>"; SavedQuery sq = new SavedQuery(); sq.Name = "A New Custom Public View"; sq.Description = "A Saved Query created in code"; sq.ReturnedTypeCode = "opportunity"; sq.FetchXml = fetchXml; sq.LayoutXml = layoutXml; sq.QueryType = 0; Console.WriteLine("A new view"); proxy.Create(sq); } } } |
|
![]() |
#2 |
Участник
|
У Вас fetch и layout для сущности
SavedQuery для Надо бы определиться ![]()
__________________
Читайте SDK!!! |
|
|
За это сообщение автора поблагодарили: Aliwer (1). |