If we use an alias in our fetchxml query it will not retrieve the alias attribute like the default query.
String inputstdssAttendeeFetchXML = $@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='std_stdssattendee' >
<attribute name='std_attendeeroleid' />
<filter>
<condition attribute='std_stdstdssid' operator='eq' value='{ inputstdss.GetAttributeValue<Guid>("std_stdstdssid")}' />
<condition attribute='statecode' operator='eq' value='0' />
<condition attribute='std_attendeeroleid' operator='not-null' />
</filter>
<link-entity name='std_stdattendee' from='std_stdattendeeid' to='std_stdattendeeid' link-type='inner' alias='stdattendee' >
<link-entity name='contact' from='contactid' to='std_contactid' link-type='inner' alias='contact' >
<attribute name='contactid' />
</link-entity>
</link-entity>
</entity>
</fetch>";
var inputstdssAttendeeresult = localContext.OrganizationService.RetrieveMultiple(new FetchExpression(inputstdssAttendeeFetchXML));
if (inputstdssAttendeeresult.Entities.Any())
{
foreach (Entity inptstdssAtten in inputstdssAttendeeresult.Entities)
{
Guid contactId = (Guid)inptstdssAtten.GetAttributeValue<AliasedValue>("contact.contactid").Value;
}
}
Comments
Post a Comment