I'm trying to run the common data service (current environment) unbound action "instantiatetemplate".
When I do though I get the following error:
The API 'commondataserviceforapps' returned an invalid response for workflow operation 'Perform_an_unbound_action' of type 'OpenApiConnection'. Error details: 'The API operation 'PerformUnboundAction' requires the property 'body' to be of type 'Array' but is of type 'Object'.'
Any ideas on what is going wrong, or how to fix this?
maybe Microsoft changed the output but I do not get this error message and am able to use the output of the "Perform an Unbound Action" to populate the email I am creating in this flow. instantiatetemplate has an output that is the email message body with the template parts filled in. NOTE: instantiatetemplate DOES NOT CREATE THE EMAIL YOU HAVE TO DO THIS.
The output body for me looks something like this:
Here's how it did it for a lead email template using the "Perform an Unbound Action" with instantiatetemplate:
Then I follow with a compose to get the 'description' returned from the "Perform an Unbound Action"
body('Create_Template_Message_from_Lead_Details_(InstantiateTemplate)')['value']?[0]?['description']
and the subject since the subject can have parts from the template:
I wrote a plugin wrapping the instantiate template action functionality and parsed the result into a string.
The c# code:
public class InstantiateTemplateWrapper : IPlugin { public void Execute(IServiceProvider serviceProvider) { // Obtain the tracing service ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService)); // Obtain the execution context from the service provider. IPluginExecutionContext context = (IPluginExecutionContext) serviceProvider.GetService(typeof(IPluginExecutionContext)); // The InputParameters collection contains all the data passed in the message request. if (context.InputParameters.Contains("TemplateId") && context.InputParameters.Contains("ObjectId") && context.InputParameters.Contains("ObjectType")) { // Obtain the organization service reference which you will need for // web service calls. IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); var templateId = Guid.Parse(context.InputParameters["TemplateId"].ToString()); var objectId = Guid.Parse(context.InputParameters["ObjectId"].ToString()); var objectType = context.InputParameters["ObjectType"].ToString(); var instTemplateReq = new InstantiateTemplateRequest { TemplateId = templateId, ObjectId = objectId, ObjectType = objectType }; var instTemplateResp = (InstantiateTemplateResponse)service.Execute(instTemplateReq); var email = instTemplateResp.EntityCollection.Entities.FirstOrDefault(); if (email != null) { var result = new InstantiateTemplateResult { Subject = email.GetAttributeValue("subject"), Description = email.GetAttributeValue("description") }; context.OutputParameters["JsonResult"] = JsonHelpers.Serialize(result); } } } } [DataContract] public class InstantiateTemplateResult { [DataMember] public string Subject { get; set; } [DataMember] public string Description { get; set; } }
I registered the above plugin, you can follow these steps to accomplish so: /tutorial-write-plug-in
I created an action InstantiatePluginPlus with the following parameters:
Input:
Output:
Here you can find how to create actions: create custom actions
I linked my plugin with my action, you can find the steps here: link plugin with action
And finally I called my custom action from my power automate flow:
Hi Mehdi El Emri,
Can you explain how you could do it?
Hi
Unfortunately, the CDS connector doesn't support actions that return a collection. I created my own connector to call the "InstatiateTemplate" action:
I haven't been able to resolve this issue yet. I haven't tried for a workaround yet, but my first inclination is to just keep the email template as a variable in Power Automate and use string replace steps to update the variable to use as the email body. Not a great solution, but the only one I've thought of to this point.
I am having this exact same issue. Were you able to resolve your issue or come up with a workaround?
Steps to get to the failure I'm seeing:
1. Create a new step within a Power Automate flow
2. Select the "Common Data Service (Current Environment)" connector
3. Select the "Perform an unbound action" action
4. For Action Name select "InstantiateTemplate"
a. Note, this is a action that is available for this connector + action by default and is not an action I created unique to my CRM
5. Set TemplateId/Object Type/ObjectId
6. Run flow and notice failure mentioned in original question
Let me know if any other information would be helpful in debugging or if there is any area I can do a better job clarifying.
Please share more information
The article you linked doesn't help me as instantiatetemplate is not an action I created so I can't control the output like mentioned.
Adis
136
Super User 2025 Season 1
Sohail Ahmed
81
Jonas "Jones" Melgaard
77
Super User 2025 Season 1