Add a Private Note Using Power Automate

Hi,

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?

Thanks in advance.

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:

1 Like

Hi @v.uspenskii,

Thanks this is very helpful but this works fine for static Ticket ID's like you have but I want the ticket ID to by dynamic like this:


So it creates a ticket and then immediately adds a Private comment to that ticket. But When I do this and try to save it I get a error like this:

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.

Any ideas?

Thanks

@NG-Helpdesk, this is odd.
I've just tried your scenario without any problems:

image

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:

{
  "CommentType": "Private note"
}

It is weird.

I have tried removing it as you suggest and copy and pasted your JSON and the some thing happens.

It works fine for this:
image
And generates this:


As expected.

But as soon as I add the JSON:
image
It gives that error.

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)

Hello!

Please open the following URL: {{YOUR_HELPDESK_DOMAIN}}/Lists/Comments/

Then go to list settings and open the configuration of the "Type" column. In my case, it is as follows:

For me, the configuration of the JSON suggested by Vladimir works. Please share your column configuration with the URL visible as on my screenshot.

Also, just for checking, try the following JSON:

{
    "CommentType": {
        "Value": "Private note"
    }
}

Hi @Evgeniy,

Thanks for looking into this. My configuration is the same as yours:

Hi @Evgeniy,

Your JSON let me save the flow which is more than it was doing before. But it failed when I ran it with the following error:

{"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."}}}"}

I have requested additional information from you in a private message, please check.

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.

Hi @Evgeniy,

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:
image

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.