It became a typical scenario – Email Quote or Invoice to customer in PDF format. When you’re on premise – it’s not a big problem – develop report, publish it to CRM, publish it to Reporting Services and use Reporting Services to render report in PDF format. But what to do when you’re online? One of new steps introduced in latest version of Ultimate Workflow Toolkit helps you to automate this process.
I used CloudConvert cloud service for this purpose (please don’t consider this as an advertisement – I don’t get any royalties). So to use this step you will have to subscribe for some plan with CloudConvert. If you do less than 25 conversions per day then you can go with “Free Plan”. I will not provide registration details in this post.
As a first step add generation of “Invoice Template” to Word using OOB functionality – “Perform Action” step – “SetWordTemplate”:
After that add “UWT: Annotation: Convert File” step and configure it:
Set reference to source record, enter the name of document that was generated on the previous step and enter name of file that you want to get as an output – in my case I wanted Word Document to be converted to PDF. Also you can define if you want to store converted document or replace original one using “Replace Original File” radiobutton.
On the next step create email without sending it.
After that add “UWT: Email: Attach Notes from Record to Email and Send” step and configure it:
Set “Record Reference” to reference of record word template was generated for, add a filter that includes filter by filename, set “Send Email” to “True” and populate Email lookup with email you created previously.
Save and activate workflow. Let’s see it in action:
Hi,
I am trying to use Email Invoice in PDF format workflow, but it is not attaching the document. It only sends an email.
Can you please help me on this.
Thanks
Hammad,
Can you please provide screenshot of your workflow?
Andrew
Hi Andrew,
Thanks for you response.
Firstly, I am getting this error when i am converting the document which is your second step:
Message: An unexpected error occurred from ISV code. (ErrorType = ClientError) Unexpected exception from plug-in (Execute): UltimateWorkflowToolkit.CoreOperations.Annotation.ConvertFile: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Crm.Sandbox.SandboxCodeUnit.ProcessException(Exception originalException, IExecutionContext context, SandboxClient client, SandboxCallTracker callTracker, Boolean isSafeToRetry, DateTime performanceExecutionStartTime, SandboxTracker tracker, Guid parentExecutionId, CrmException& crmException, String& assemblyContents)
at Microsoft.Crm.Sandbox.SandboxCodeUnit.c__DisplayClass24_0.b__0()
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable`1 additionalCustomProperties)
at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action)
at Microsoft.Xrm.RemotePlugin.CrmProvider.RemotePlugin.Execute(IServiceProvider serviceProvider)
at Microsoft.Xrm.RemotePlugin.CrmProvider.RemotePluginContainer.Execute(IServiceProvider serviceProvider)
at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)
— End stack trace —
Secondly, i can’t attach the screen shot over here.
I am explaining what i am doing:
1- Created the workflow on invoice level,when invoice generated
2- Action: SetWordTemplate Entity -> i have invoice template, (Invoice1.docx)attached
-> Target : Invoice
3- UWT: Annotation:Convert file -> Resulting file name: Invoice.pdf
-> Replacing Orignal file: True
-> Record Reference: RecordUrl(Invoice)
-> Currentfilename: Invoice1.docx
Right now, it’s not going forward from this step: it gives the above mentioned error.
4- Create Email -> From and To mentioned but without body
5- UWT -> Email Attach Notes From Record to Email and Send -> Record reference : RecordURL(Invoice_
-> Document filter:
-> Send Email = True
-> Email : {Email Message(Create (Email)}
Much Appreciated.
I am struggling to send the email with attachments, but.
Thanks.
Have you created a key and added it to settings as it is described here – https://github.com/a33ik/UltimateWorkflowToolkit/wiki/Convert-File-(from-attachments) ?
Hi,
Thanks Andrew. Much appreciated.
It’s working now. I tried below lines to attach two documents, but i got an error: Changes to attachments for an email in pending or sending status is not allowed.
UWT: Email:Attach Notes from Record to Email and Send
UWT: Email:Attach Notes from Record to Email and Send
Failed. You do not have enough privileges to access the Microsoft Dynamics 365 object or perform the requested operation. For more information, contact your Microsoft Dynamics 365 administrator. Started On: 1/31/2019 4:54 PM
In the first “Attach Notes” action uncheck flag “Send Email”.
Thanks Andrew. You are a star 🙂
You made my day.
Thanks once again.
Hi,
I’m trying to convert an attachment from a word doc to HTML, and I get the following error –
File CVTest.docx is not available for current record
Any ideas?
Thanks!
Hello Cameron,
Can you please post the screenshot of the Convert Document step and screenshot that shows that this document really exists under the record?
Andrew
Sorry how do I post a screenshot, it doesn’t let me paste it in?
Cameron,
You can store screenshots somewhere (onedrive or so) and put links here.
Andrew
Hi Andrew,
Below are screenshots of the Workflow settings and the Note with the attachment
https://docs.zoho.com/file/g8kn51c7d53ae7e3442a38b226b909a283349
https://docs.zoho.com/file/g8kn5d3fb4587e804402db257dd20238e2a93
Oh. I see. Conversion step looks for an attachment regarding some record so you should pass reference to a parent record regarding which annotation is created. Something like this – https://butenko.pro/wp-content/uploads/2019/08/ConvertWorkflowStep.png
Thanks Andrew,
I’ve changes it to the following –
https://docs.zoho.com/file/g8kn56d0c236c21b249e6a41cd084d74bffd4
But receive this error –
An unexpected error occurred from ISV code. (ErrorType = ClientError) Unexpected exception from plug-in (Execute): UltimateWorkflowToolkit.CoreOperations.Annotation.ConvertFile: System.NullReferenceException: Object reference not set to an instance of an object.
Plugin Trace:
[UltimateWorkflowToolkit.CoreOperations: UltimateWorkflowToolkit.CoreOperations.Annotation.ConvertFile]
[UWT: Annotation: Convert File]
Value of ‘Resulting File Name’ attribute equals to test.html
Value of ‘Replace Original File’ attribute equals to True
Value of ‘Record Reference’ attribute equals to https://hwqdev.crm6.dynamics.com:443/main.aspx?etc=10428&id=f5e3645b-49c5-e911-a97c-000d3ad1cc81&histKey=867065092&newWindow=true&pagetype=entityrecord
Value of ‘Current File Name’ attribute equals to CVTest.docx
Value of ‘Throw an Exception on Error’ attribute equals to True
Error Message:
Unhandled exception:
Exception type: Microsoft.Crm.CrmException
Message: An unexpected error occurred from ISV code. (ErrorType = ClientError) Unexpected exception from plug-in (Execute): UltimateWorkflowToolkit.CoreOperations.Annotation.ConvertFile: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Crm.Sandbox.SandboxCodeUnit.ProcessException(Exception originalException, IExecutionContext context, SandboxClient client, SandboxCallTracker callTracker, Boolean isSafeToRetry, DateTime performanceExecutionStartTime, SandboxTracker tracker, Guid parentExecutionId, CrmException& crmException, String& assemblyContents)
at Microsoft.Crm.Sandbox.SandboxCodeUnit.c__DisplayClass24_0.b__0()
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable`1 additionalCustomProperties)
at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action)
at Microsoft.Xrm.RemotePlugin.CrmProvider.RemotePlugin.Execute(IServiceProvider serviceProvider)
at Microsoft.Xrm.RemotePlugin.CrmProvider.RemotePluginContainer.Execute(IServiceProvider serviceProvider)
at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)
— End stack trace —
It looks good for me. Next question – have you entered CloudConvert key. It’s described here – https://github.com/a33ik/UltimateWorkflowToolkit/wiki/Convert-File-(from-attachments)
Thanks Andrew that’s worked a treat!
With the CloudConvert is it possible to get by on the free account? I imagine our volumes will be pretty low.
Cameron,
Please read 2-nd paragraph of this post.
Andrew
Sorry I thought I’d already shared this? Did you get them?
https://docs.zoho.com/file/g8kn5d3fb4587e804402db257dd20238e2a93
https://docs.zoho.com/file/g8kn51c7d53ae7e3442a38b226b909a283349
Hi Andrew,
I’ve been using your workflows to convert word docs to HTML, and has been working great.
Do you have a plugin version of this?
Thanks.
Cameron,
There is no plugin option but you can build (if you’re developer) your own using the code I use in “Convert” activity – https://github.com/AndrewButenko/UltimateWorkflowToolkit/blob/master/CoreOperations/Annotation/ConvertFile.cs
Thanks,
Andrew
Hey Andrew,
I followed the instructions but it seems I get an error message.
Plugin Trace:
[UltimateWorkflowToolkit.CoreOperations: UltimateWorkflowToolkit.CoreOperations.Annotation.ConvertFile]
[UWT: Annotation: Convert File]
Error Message:
Unhandled Exception: Microsoft.Crm.CrmException: System.Runtime.Serialization.SerializationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #2B3888C1
at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)
at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)
I have the API Key in our CRM, so is there something else I’m missing?
Hello Michael,
Thanks for using my toolkit. Can you please provide screenshot of the step from the workflow (I know it’s not possible to put screenshots here but you can host it somewhere and drop a url here).
Thanks,
Andrew
Importing the latest release results in an error. Are you able to create a CDS-only release too?
Plugin Assemblies import: FAILURE. Error: Plugin: UltimateWorkflowToolkit.CoreOperations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=47b099d1948ebf4d of PluginTypeName: Microsoft.Crm.Entities.PluginType and PluginTypeNode: caused an exception.: Plugin Types import: FAILURE. Error: Plugin: UltimateWorkflowToolkit.CoreOperations, Version=1.0.0.0, Culture=neutral, PublicKeyToken=47b099d1948ebf4d of PluginTypeName: Microsoft.Crm.Entities.PluginType caused an exception.: Invalid CrmReferenceTarget: The entity incident doesn’t exist. Property: Case
Kevin,
I’ll reactivate my work on CDS-compatible version of toolkit.
Thanks,
Andrew
Hi Andrew,
I followed the instructions and added the API key, but I’m getting this message. Our system is a on-premise IFD, would that impact the way the files are converted?
Unexpected exception from plug-in (Execute): UltimateWorkflowToolkit.CoreOperations.Annotation.ConvertFile: System.Net.WebException: The remote server returned an error: (403) Forbidden.
https://gtarnet-my.sharepoint.com/personal/michael_tamparealtors_org/Documents/PDF%20FIle%20Convert%20setup%20step.JPG
My mistake, here is the link
https://gtarnet-my.sharepoint.com/:i:/g/personal/michael_tamparealtors_org/EeIE4kaTxxpBtsEStijoLcABpKsJiH85J9IFSN_uicSBhQ?e=hCCt0V
Michael,
It seems that credentials are not valid.
Andrew
Hi Andrew,
Can you clarify a bit more?
Thank you
Michael,
Can you please confirm that credentials you used are valid and https://api.cloudconvert.com domain is whitelisted from your dynamics server.
Andrew
Hi Andrew,
I figured out the issue, the API Key was bad and had to create another account to get another key, after that it worked.
Thanks!