Generate a PDF with an Omniscript

Downloads

GitHub: Generate a PDF with an Omniscript

Overview

This post is about how to generate a PDF with an Omniscript. This example gets opportunity name and displays it in a document which is stored in the opportunity record.

Steps

Step 1. Create Dataraptor to extract information

Step 2. Create Dataraptor to transform extracted information into Vlocity Document template format

Step 3. Create Vlocity Document template

Step 4. Create Omniscript

Step 1. Create Dataraptor to extract information

Open ‘Vlocity DataRaptor Designer’ tab and click on ‘New’ button. Fill the fields with the following values and click on ‘Save’.

Screen Shot 2018-09-03 at 17.18.51

Click on the ‘Extract’ tab and get the Opportunity object filtered by ‘opportunityId’.

Screen Shot 2018-09-03 at 17.19.41

Click on ‘Output’ tab and get the opportunity id and the name fields.

Screen Shot 2018-09-03 at 17.20.11

Screen Shot 2018-09-03 at 17.20.18

Step 2. Create Dataraptor to transform extracted information into Vlocity Document template format

Open ‘Vlocity DataRaptor Designer’ tab and click on ‘New’ button. Fill the fields with the following values and click on ‘Save’.

Screen Shot 2018-09-03 at 17.21.49

Click on the ‘Transform’ tab and set the opportunity name. (NOTE: do NOT include ‘:‘ in the output variable name because it will be not displayed in the vlocity template document).

Screen Shot 2018-09-03 at 17.22.49

Step 3. Create Vlocity Document template

Open ‘Vlocity Document Template’ tab and click on ‘New’ button. Fill the fields with the following values. The ‘Mapping Dataraptor Bundle Name’ field is the dataraptor which was created above.

Screen Shot 2018-09-03 at 17.29.33

Click on ‘Edit Section’ button and create a context section. Select ‘Add New Section -> ‘Context’.

Screen Shot 2018-09-03 at 17.32.44

The section is called ‘Example’. Fill the ‘Section Content’ with the value Opportunity name: %%OpportunityName%% and click on ‘Save Section’ button. In vlocity template documents, the variables names are added between percentage symbols. For instance: %%myVariableName%%.

Screen Shot 2018-09-03 at 17.37.02

Click on ‘Activate’ button.

Step 4. Create Omniscript

Open ‘Vlocity OmniScript Designer’ tab and click on ‘New’ button. Fill the fields with the following values and click on ‘Save’.

Screen Shot 2018-09-03 at 17.40.39

Go to ‘CUSTOM HTML TEMPLATES’ section in the script configuration and copy and paste this script.

Screen Shot 2018-09-03 at 17.46.07

Drag and drop a ‘Set Values’ action. Create a variable called ‘opportunityId’ and add an opportunity id to test.

Screen Shot 2018-09-03 at 17.49.11

Drag and drop a ‘Set Values’ action. Define the following values:

  • documentName: document name when you download it.
  • documentParentId: record id will be linked the document to get the information. In this example, it is the ‘opportunityId’ set previously.
  • templateId: vlocity document template Id.

Screen Shot 2018-09-03 at 17.50.24

Drag and drop a ‘DataRaptor Extract Action’ action. Set ‘DataRaptor Interface’ field as ‘POC: Get Opportunity information’ and create one row in the input parameters. Set ‘Data Source’ and ‘Filter Value’ fields as ‘opportunityId’.

Screen Shot 2018-09-03 at 17.53.58

Drag and drop a ‘Remote Action’ action. Call the apex class which will create the document. Fill the fields with the following values:

  • Remote Class: ObjectDocumentService
  • Remote Method: createObjectDocument
  • Remote Options:
    • input: %Opportunity%
    • templateId: %templateId%

Screen Shot 2018-09-03 at 17.56.38

Drag and drop a ‘Step’ group.

Screen Shot 2018-09-03 at 18.03.39

Drag and drop a ‘Input Block’. The ‘HTML Template Id’ has to be ‘iframe.html’.

Screen Shot 2018-09-03 at 18.05.07

Click on ‘Preview’ tab. Click on ‘+’ button and select ‘Generate PDF’. The PDF will have been generated.

Screen Shot 2018-09-03 at 18.07.16

Click on ‘Download’ and check the document. It will display ‘Document name:’ and the opportunity name. In this example, the name is ‘Test Opportunity’.

Screen Shot 2018-09-03 at 18.08.59

Go to opportunity record. The PDF is stored in the ‘Notes & Attachments’ related list.

Screen Shot 2018-09-03 at 18.14.00

 

25 thoughts on “Generate a PDF with an Omniscript

  1. Hi Michele,
    Download the file from Github (the link is on the top of the page) and upload it in your org.
    Let me know if is solved your problem.
    Thanks

    Like

    1. Excellent post Ignacio.

      One question, how can I import to my org the gitHub example you included to download?

      Thanks!

      Like

      1. Hi Sebastian,

        Thanks for your feedback. You have to open any Vlocity tab, for example ‘Vlocity Dataraptor Designer’ and should be a button to import it.

        Let me know if that worked

        Thanks

        Like

  2. Hello Ignacio,
    Good job! , I followed the steps, but when I click Preview I get this error: {{objDocCreationService.objDocLabel}}. Do you know what could be wrong?

    Like

    1. Hi Valery,

      Thanks a lot!. Can you verify that the format is the right one, please? The variables are in the template like %%OpportunityName%% and in the omniscript like %OpportunityName%

      Like

  3. Hi Ignacio,
    Thanks for the solution. I’ve downloaded the script from github and imported. and also adjusted id’s and values according to my org. But in prieviewits showing “Url does not exist” error.
    “URL No Longer Exists
    You have attempted to reach a URL that no longer exists on salesforce.com.”

    Any fix?

    Like

    1. Hi Ventaka,

      Try to follow the steps and update the values that you think it is not pointing correctly.

      Regards,
      Ignacio

      Like

  4. i follow the steps but when i click on preview its show one image. Can you please hel me here.

    Thanks in Advance!!

    Like

    1. Hi Hermant,

      Thanks for your question. The image should be the result that you should expect. If it is a blank image, please verify that you have set the parameters correctly to show what you expect. You have to respect the Vlocity format or the values will be not render

      Regards,
      Ignacio

      Like

  5. Hi Ignacio,

    I managed to get it working fine in Omniscript designer. I currently getting an issue with the OmniScript when it placed within a Visualforce page I get shown this error – {{objdoccreationservice.objdoclabel}} do I need some values within the visualforce so {{objdoccreationservice.objdoclabel}} has something?

    Best regards,

    Jon

    Like

    1. Hi Jon,

      Thanks for your comment. Sorry I don’t have experience adding the omniscript inside a visualforce. I don’t know if it is possible or not. Try to render in other area without using a visualforce,

      Good luck!
      Regards,
      Ignacio

      Like

  6. Hi Ananya,

    Thanks for your comment, Like any tool, this have some limitations but I am not sure which kind of limitation you could face in your requirements. I would recommend you to ask Vlocity support to see if you cannot meet some pf your requirements.

    Good luck!
    Regards,
    Ignacio

    Like

  7. Thanks Ill give it try, on a separate note regarding the generate PDF. Have you come across this “Input object is not a key-value pair”. I am trying to find out what it means but can’t seem to find anything on this error.

    Like

  8. Dear Ignacio,

    I have followed the exact steps as mentioned by you in the given post. However, i am not able to see the download option in preview. I checked the debug and data section in Omniscript preview, the document is getting generated (new doc id is created every time).

    Looks like some iframe issue. I am using cmt org. Could you please help me resolve this issue?

    Regards,
    Priyanka

    Like

  9. Dear Ignacio,

    I have followed all the steps mentioned in your post but can’t see the download window. I am using communication and media org. I suspect that there might be some issue with CUSTOM HTML TEMPLATE settings.

    In LWC preview, debug – i can see document id getting generated. But successfully generated pdf document and download is not coming.

    Could you please help me with this at your earliest?

    Best Regards,
    Priyanka

    Like

    1. Hi Priyanka,

      Thanks for your comment. This post is a little old and the pdf generation used to cause plenty of issues in the past. I would recommend you to open a case with Vlocity because they should know how to solve the problem

      Good luck!

      Like

  10. Dear Ignacio, we are recruiting talented SFDC developers with Vlocity experience. Your article caught our attention. Could we arrange a zoom to see if there is a fit? -Eric

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s