Hi all,
I am trying to create a custom workflow that generates a list of resource account id and e-mail address (custom field added to bookableresource entity), then send out custom html e-mail using this list. This is for Dynamic 365 V8.2 cloud version. I created an EntityCollection based on fetchxml but I get error message in visual studio when I tried to get field value in each row from the EntityCollection, I read through below MSDN tutorial:
msdn.microsoft.com/.../gg328149.aspx
and tried below so far:
string accountid = bookedResource.Attribute["accountid"]; (Microsoft.xrm.sdk.Entity does not contain definition for attribute...)
string accountid = bookedResource["accountid"]; (cannot implicit convert object to string...)
Below is my code, can anyone tell me how to do this?
//retrieve resource account ID and e-mail that has open work order and has e-mail data stored under bookableresource entity
const string fetchVendor = @"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true' >
<entity name='bookableresource' >
<attribute name='accountid' />
<attribute name='bookableresourceid' />
<attribute name='jt_bookingemail' />
<filter>
<condition attribute='jt_bookingemail' operator='not-null' />
</filter>
<link-entity name='bookableresourcebooking' from='resource' to='bookableresourceid' >
<link-entity name='msdyn_workorder' from='msdyn_workorderid' to='msdyn_workorder' >
<filter>
<condition attribute='msdyn_substatusname' operator='eq' value='OPEN' />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>
";
EntityCollection vendorCollection = service.RetrieveMultiple(new FetchExpression(fetchVendor));
foreach (Entity bookedResource in vendorCollection.Entities)
{
string accountid = bookedResource["accountid"];
string jt_bookingmail = bookedResource.GetAttributeValue['jt_bookingmail'];
//pass account id and e-mail string into method that create and send out e-mails
};