I think this is not possible but I just wanted someone to confirm.
I want to be able to add private notes to a ticket using a Flow as far as I can see there is no connector for this and now way to use the "Create Comment" connector to do this. Am I correct or am I missing something?
Hi @NG-Helpdesk,
This is in fact quite possible.
You only need to add a small JSON object specifying the comment type in the "Comment Custom Fields" section of the "Create a Comment" action:
Request to XRM API failed with error: 'Message: Flow client error returned with status code "BadRequest" and details "{"error":{"code":"InvalidOpenApiFlow","message":"Flow save failed with code 'OpenApiOperationParameterValidationFailed' and message 'Input parameter 'comment' validation failed in workflow operation 'Create_a_comment': The parameter with value '"Private note"' in path 'comment/customFields/CommentType' with type/format 'String' is not convertible to type/format 'Object'.'."}}". Code: 0x80060467 InnerError: Type: System.ServiceModel.FaultException1[[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":"Flow save failed with code 'OpenApiOperationParameterValidationFailed' and message 'Input parameter 'comment' validation failed in workflow operation 'Create_a_comment': The parameter with value '\"Private note\"' in path 'comment/customFields/CommentType' 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, Dictionary2 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.Crm.Extensibility.OData.CrmODataUtilities.<>c__DisplayClass10_02.<InvokeActionAndLogMetric>b__0() at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func1 func, IEnumerable1 additionalCustomProperties) at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func1 func) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.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.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.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.d__1.MoveNext() InternalException: '.
This works fine without the JSON for private comment but seems I cant have both a dynamic Ticket ID and the Private comment JSON.
Surely, the dynamic Ticket ID could not be the issue here. Please try removing the "Create a comment action" and adding it back again. It might be some glitch in the Power Automate.
Please also make sure that your JSON is valid:
I created the simplest version of this flow I could to ensure nothing else in my flow could be causing the issue. I made an instant flow with manual trigger and a create ticket followed by a create comment and it still errored on me when I try to save it:
I get this error:
Flow save failed with code 'OpenApiOperationParameterValidationFailed' and message 'Input parameter 'comment' validation failed in workflow operation 'Create_a_comment': The parameter with value '"Private note"' in path 'comment/customFields/CommentType' with type/format 'String' is not convertible to type/format 'Object'.'.
It seems to not like "Private note". Could it have another name in my helpdesk istance? (We have not renamed anything)
{"error":"Failed to create Comments list item: {"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"An unexpected 'StartObject' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected."}}}"}
For anyone else looking through this thread in the future. The issue I'm experiencing seems to be a Microsoft issue with Power Automate in my tenancy. This was determined thanks to extensive testing carried out by Plumsail. I will now raise this with Microsoft support.
But for most normal situations the solution first offered by @v.uspenskii is correct and will give you a private comment.
After over a month with Microsoft support, they finally found a solution to this. They told me it is a known error that randomly happens in some tenancies that only the back end team of Power Automate is aware of and they are working to fix it but have not found out what causes it yet.
The temporary solution to it is to do this:
Inside the string expression is this code:
string('Private note')
Then it works.
I thought I would post this here in case any other users come up against this or if there are similar issues in the future it might help.