Blog, CRM Extensions, Ultimate Workflow Toolkit

UWT: Email Invoice in PDF format

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:

7 Comments on “UWT: Email Invoice in PDF format

  1. 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

      1. 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.

        1. 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

Leave a Reply to hammad Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.