Generate the xml query using xrmtoolbox and try with this code sample.
String eventsessionFetchXML = $@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='baseevt_eventsession' >
<attribute name='baseevt_eventid' />
<attribute name='baseevt_sessionenddatetime' />
<attribute name='baseevt_sessionstartdatetime' />
<attribute name='baseevt_name' />
<attribute name='baseevt_description' />
<filter>
<condition attribute='baseevt_eventid' operator='eq' value='{inputEntity.Id.ToString()}' />
</filter>
</entity>
</fetch>";
var eventSessionresult = localContext.OrganizationService.RetrieveMultiple(new FetchExpression(eventsessionFetchXML));
if (!eventSessionresult.Entities.Any())
{
return; // don't do anything if there are not suitable Contacts
}
foreach (Entity eventSession in eventSessionresult.Entities)
{
EventSessionbasexy eventSessionbasexy = new EventSessionbasexy()
{
Name = eventSession.GetAttributeValue<string>("baseevt_name"),
};
// insert new record
eventSessionbasexy.Id = localContext.OrganizationService.Create(eventSessionbasexy.ToEntity<Entity>());
}
Comments
Post a Comment