Dynamics crm Выражение запроса «Контакт» не содержит атрибута - PullRequest
0 голосов
/ 11 февраля 2020

Я использую код, показанный здесь, в моем рабочем процессе, но когда я его запускаю, я получаю следующую ошибку:

Сущность «Контакт» не содержит атрибута с Name = ''

List<Guid> PPLyonIds = new List<Guid>();

QueryExpression qe = new QueryExpression(Personne_physique.EntityLogicalName);
qe.ColumnSet = new ColumnSet("contactid");
qe.Criteria.AddCondition("fullname", ConditionOperator.In, nomsprenomscpdevtry.Cast<Object>().ToArray());

EntityCollection res = organisationProxy.RetrieveMultiple(qe);

IEnumerable<Personne_physique> personnes = res.Entities.Select(x => x.ToEntity<Personne_physique>());
PPLyonIds = personnes.Select(x => x.Id).ToList<Guid>();

logger.Debug(" nombre des ids" + PPLyonIds.Count);

List<Guid> respIds = new List<Guid>();

QueryExpression qee = new QueryExpression(Reponse_de_campagne.EntityLogicalName);
qee.ColumnSet = new ColumnSet("activityid");

LinkEntity personnePhyLink = qee.AddLink("contact", "contactid", "new_personnephysiquecible");

FilterExpression filter = personnePhyLink.LinkCriteria.AddFilter(LogicalOperator.And);
filter.AddCondition("contactid", ConditionOperator.In, PPLyonIds.Cast<Object>().ToArray());
filter.AddCondition("activityid", ConditionOperator.Equal, Guid.Parse("4B90DEA4-680C-EA11-80FE-005056B14DD3"));

qee.Criteria.AddFilter(filter);
qee.LinkEntities.Add(personnePhyLink);

EntityCollection rese = organisationProxy.RetrieveMultiple(qee);
IEnumerable<Reponse_de_campagne> reponses = rese.Entities.Select(x => x.ToEntity<Reponse_de_campagne>());

respIds = reponses.Select(y => y.Id).ToList();

logger.Debug(" nombre des ids" + respIds.Count);

и в моем Fetch XML это код

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="campaignresponse">
    <attribute name="subject" />
    <attribute name="regardingobjectid" />
    <attribute name="customer" />
    <attribute name="new_activitedecampagneparente" />
    <attribute name="new_retoursouscription" />
    <attribute name="new_concretisationtousproduits" />
    <attribute name="new_concretisation" />
    <order attribute="subject" descending="false" />
    <link-entity name="contact" from="contactid" to="new_personnephysiquecible" alias="ab" />
  </entity>
</fetch>
````
Cordially

1 Ответ

0 голосов
/ 13 февраля 2020
LinkEntity personnePhyLink = qee.AddLink("contact", "new_personnephysiquecible", "contactid");

Я считаю, что AddLink должен быть таким: («сущность», внешний ключ, первичный ключ). Как это в Fetch XML

...