cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Perform an Unbound Action SendEmailFromTemplate

Hi Guys,

 

I'm trying to send email from CDS/Dynamics 365 CE from Flow.

Why Dynamics 365 e-mail because the emails need to be tracked in Dynamics and that isn't possible via the Outlook connector for example.

 

So there is an Unbound Action called SendEmailFromTemplate in Dynamics 365 which basically does everything for you.

You only need to make the template and off you go. However in Power Automate this Action doesn't seem to work as intended.

 

Once a Day I check all contract that a certain date is today.
For all those Contract I want to send an email to the owner of the record.

So I do the following.

FlowOVerview.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

However When I try to Save the Flow it gives me an Error Stating the following:

 

Request to XRM API failed with error: 'Message: Flow client error returned with status code "BadRequest" and details "{"error":{"code":"InvalidOpenApiFlow","message":"Het opslaan van de stroom is mislukt met de code OpenApiOperationParameterValidationFailed en het bericht Input parameter 'item' validation failed in workflow operation 'Perform_an_unbound_action': The parameter with value '\"@items('Apply_to_each')?['_ownerid_value']\"' in path 'item/Target' with type/format 'String' is not convertible to type/format 'Object'.."}}". Code: 0x80060467 InnerError: Type: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] Message: Flow client error returned with status code "BadRequest" and details "{"error":{"code":"InvalidOpenApiFlow","message":"Het opslaan van de stroom is mislukt met de code OpenApiOperationParameterValidationFailed en het bericht Input parameter 'item' validation failed in workflow operation 'Perform_an_unbound_action': The parameter with value '\"@items('Apply_to_each')?['_ownerid_value']\"' in path 'item/Target' with type/format 'String' is not convertible to type/format 'Object'.."}}". StackTrace: at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Update(Entity entity, InvocationContext invocationContext, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, Boolean checkForOptimisticConcurrency, Dictionary`2 optionalParameters) at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Update(Entity entity, UpdateOption updateOption) at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.UpdateEdmEntity(CrmODataExecutionContext context, String edmEntityName, String entityKeyValue, EdmEntityObject entityObject) at Microsoft.Crm.Extensibility.OData.EntityController.PatchEntityImplementation(String& entityName, String key, EdmEntityObject entityDelta) at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties) at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext() InternalException: '.

 

To give a summary of the Error it basically says: I can't convert the Target parameter: Items('Apply_to_each')?[_ownerid_value'] (string) to Object.

 

When I look at the specification of the Action it requires "Target" to be some sort of crmbaseentity ( just like the Regarding which works fine). 

 

Can someone help me with this?

 
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

Re: Perform an Unbound Action SendEmailFromTemplate

With the help of the wonderful Elaiza Benitez I've got it to work.

 

So you have to construct the Target and Regarding objects yourself.

 

The working version looks something like this:

FlowWorking.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Look at Elaizas YouTube channel and in particular this video to also get this working:

https://www.youtube.com/watch?v=M1eZER1cEuE

 

Thanks for all the help

View solution in original post

4 REPLIES 4
Highlighted
Microsoft
Microsoft

Re: Perform an Unbound Action SendEmailFromTemplate

Hi ,

 

The error message is actually pretty clear, the Traget parameter requires a data type as entity, I am adding below documentation explaining in details about this specific outbound action SendEmailFromTemplate and the data type crmbaseentity.

 

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/sendemailfromtemplate?view=...

 

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/crmbaseentity?view=dynamics...

 

For example, you want to send email to User A, you should pass a complete User Object (UserA) to the Target parameter, but not UserA.emailaddress to the Target parameter, where UserA.emailaddress is a string value but not an entity value.

 

From your screenshot, I could see that you are doing the correct thing for Regarding, as you are passing the complete object (Order) to Regarding, but not something like Order.orderid.

 

If the reply helps resolves your issue, please mark it as a solution.

 

Regards,

Erica

 

Highlighted
Frequent Visitor

Re: Perform an Unbound Action SendEmailFromTemplate

Hi @EricaBao ,

 

 

I'm doing the exact same this for both regarding and target. I'm passing in the Contract record, items('Apply_to_each').['salesorderid'] to the Regarding part and the Owner of the Contract record items('Apply_to_each').['_ownerid_value'] to the Target parameter. Which are both GUIDs of records
Even if I Retrieve the Systemuser Record that is the owner separately and pass that to the Target parameter I get the same error.

FlowOverview2.png

 

 

When I get the User record There is also a Body property from that action. When I use that which is the whole Odata Entity object and put that in the regarding field I can save the flow but when I then Test my flow it gives the following error on the Unbound action:

 

An error occurred while validating input parameters: Microsoft.Crm.CrmHttpException: Resource not found for the segment 'c543cad5-6e79-ea11-a811-000d3a2c5614'.\r\n at Microsoft.Crm.Extensibility.OData.CrmEdmEntityReference.CreateCrmEdmEntityReference(Uri link, IEdmModel edmModel, CrmODataExecutionContext context, EntitySetSegment& entitySetSegment)\r\n at Microsoft.Crm.Extensibility.ODataV4.ODataParameterReaderExtensions.TryReadFlowPrimitiveData(ODataParameterReader oDataParameterReader, ODataDeserializerContext readContext, CrmEdmEntityObject& result)\r\n at Microsoft.Crm.Extensibility.ODataV4.ODataParameterReaderExtensions.TryReadFlowPrimitive(ODataParameterReader oDataParameterReader, ODataDeserializerContext readContext, CrmEdmEntityObject& result)\r\n at Microsoft.Crm.Extensibility.ODataV4.CrmODataActionPayloadDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)\r\n at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)"

 

This Id is the Primary Id of The "Contract" record I referenced at the Regarding parameter. Trying to get this Contract Record as a single record and basing in the whole body again gives me the same error.

 

 

Highlighted
Microsoft
Microsoft

Re: Perform an Unbound Action SendEmailFromTemplate

Hi,

 

I seems to be able to reproduce the issue, can you submit a support request sharing your flow ID and run ID for some further investigation from support professional resources? 

Highlighted
Frequent Visitor

Re: Perform an Unbound Action SendEmailFromTemplate

With the help of the wonderful Elaiza Benitez I've got it to work.

 

So you have to construct the Target and Regarding objects yourself.

 

The working version looks something like this:

FlowWorking.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Look at Elaizas YouTube channel and in particular this video to also get this working:

https://www.youtube.com/watch?v=M1eZER1cEuE

 

Thanks for all the help

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (10,360)