Требуется показать список названий Unterweisung (тренингов) в форме Контакта в качестве подсетки. Пожалуйста, посмотрите на:
Есть ли способ отобразить их?
Я пытался добавить fetchXML
к форме grid v ie JS, но безуспешно, по двум причинам:
1) FetchXML
недопустимо, я полагаю, из-за поиска двухсвязных сущностей. Если это не поддерживается, весь подход неверен.
2) Даже если оставить фильтрацию только для одного объекта, d365 выдает ошибку Invalid FetchXML
при открытии контактной формы. FetchXML validators
указывают противоположное.
Предполагаемая полная выборка XML (недействительно):
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="new_schulungstyp">
<attribute name="new_name" />
<attribute name="createdon" />
<attribute name="new_schulungstypid" />
<attribute name="new_typ" />
<attribute name="new_intervall" />
<order attribute="createdon" descending="false" />
<filter type="and">
<condition attribute="statecode" operator="eq" value="0" />
</filter>
<link-entity name="new_new_schulungstyp_new_azttigkeit" from="new_schulungstypid" to="new_schulungstypid" visible="false" intersect="true">
<link-entity name="new_azttigkeit" from="new_azttigkeitid" to="new_azttigkeitid" alias="aa">
<link-entity name="new_new_profil_new_azttigkeit" from="new_azttigkeitid" to="new_azttigkeitid" visible="false" intersect="true">
<link-entity name="new_profil" from="new_profilid" to="new_profilid" alias="ab">
<link-entity name="new_contact_new_profil" from="new_profilid" to="new_profilid" visible="false" intersect="true">
<link-entity name="contact" from="contactid" to="contactid" alias="ac">
<filter type="or">
<condition attribute="contactid" operator="eq" value="currentContactIdInsertedViaJs" />
</filter>
</link-entity>
</link-entity>
</link-entity>
</link-entity>
</link-entity>
</link-entity>
<link-entity name="new_new_betriebsmittel_new_schulungstyp" from="new_schulungstypid" to="new_schulungstypid" visible="false" intersect="true">
<link-entity name="new_betriebsmittel" from="new_betriebsmittelid" to="new_betriebsmittelid" alias="ad">
<link-entity name="new_new_betriebsmittel_new_profil" from="new_betriebsmittelid" to="new_betriebsmittelid" visible="false" intersect="true">
<link-entity name="new_profil" from="new_profilid" to="new_profilid" alias="ae">
<link-entity name="new_contact_new_profil" from="new_profilid" to="new_profilid" visible="false" intersect="true">
<link-entity name="contact" from="contactid" to="contactid" alias="af">
<filter type="or">
<condition attribute="contactid" operator="eq" value="currentContactIdInsertedViaJs" />
</filter>
</link-entity>
</link-entity>
</link-entity>
</link-entity>
</link-entity>
</link-entity>
</entity>
</fetch>
JS код с единичным фильтром сущностей:
function filterTrainings(executionContext) {
var formContext = executionContext.getFormContext();
var guid = Xrm.Page.data.entity.getId();
var fullname = formContext.getAttribute("fullname").getValue();
//var fullName = formContext.getAttribute("fullname_d").getValue();
var fetchXML = "<fetch>";
fetchXML+= "<entity name='new_schulungstyp'>";
fetchXML+= "<attribute name='new_name' />";
fetchXML+= "<attribute name='createdon' />";
fetchXML+= "<attribute name='new_schulungstypid' />";
fetchXML+= "<attribute name='new_typ' />";
fetchXML+= "<attribute name='new_intervall' />";
fetchXML+= "<order attribute='createdon' descending='false' />";
fetchXML+= "<filter type='and'>";
fetchXML+= "<condition attribute='statecode' operator='eq' value='0' />";
fetchXML+= "</filter>";
fetchXML+= "<link-entity name='new_new_schulungstyp_new_azttigkeit' from='new_schulungstypid' to='new_schulungstypid' visible='false' intersect='true'>";
fetchXML+= "<link-entity name='new_azttigkeit' from='new_azttigkeitid' to='new_azttigkeitid' alias='aj'>";
fetchXML+= "<link-entity name='new_new_profil_new_azttigkeit' from='new_azttigkeitid' to='new_azttigkeitid' visible='false' intersect='true'>";
fetchXML+= "<link-entity name='new_profil' from='new_profilid' to='new_profilid' alias='ak'>";
fetchXML+= "<link-entity name='new_contact_new_profil' from='new_profilid' to='new_profilid' visible='false' intersect='true'>";
fetchXML+= "<link-entity name='contact' from='contactid' to='contactid' alias='al'>";
fetchXML+= "<filter type='and'>";
fetchXML+= "<condition attribute='contactid' operator='eq' value='"+guid+"' />";
fetchXML+= "</filter>";
fetchXML+= "</link-entity>";
fetchXML+= "</link-entity>";
fetchXML+= "</link-entity>";
fetchXML+= "</link-entity>";
fetchXML+= "</link-entity>";
fetchXML+= "</link-entity>";
fetchXML+= "</entity>";
fetchXML+= "</fetch>";
var grid = formContext.getControl("relatedTrainings");
if (grid == null) {
setTimeout(function () {
filterTrainings(executionContext);
}, 2000);
return;
} else {
grid.getGrid().setParameter("fetchXml", filterTrainings); //set the fetch xml to the sub grid
console.log("refresh............")
}
}