Objective:
This tutorial teaches you how to combine the power of Youreka and Conga Composer to generate customized PDFs from Youreka forms.
Before you get started:
These articles might be helpful before you read this one:
In this tutorial, you will learn how to use Conga Composer to create a PDF of a Youreka form, which is formatted based on specific business requirements.
Use Case:
Darn It Insurance is a company based in Denver, Colorado that is responsible for processing claims from customers whose cars have been broken into by bears.
When a customer has a bear break into their car, they submit a case to Darn It's customer service team. From there, the customer service team sends a field rep out to assess the damage to the car. That field rep needs to complete a detailed survey of the condition of the car, which ultimately helps Darn It accurately document damages and process the claim.
After the field rep completes the assessment, a copy of that form needs to be sent to the customer in the form of a PDF. Darn It Insurance wants their PDFs to look like the following:
Specific Business Requirements:
- Business users will fill out a Youreka form which ties to the Case object in Salesforce
- Those same business users will need to be able to create a summarized document (PDF) from that Case and the associated Form to send to the customer.
- The users need the ability to create a PDF manually from the Case record
- The resulting PDF needs to have both form data, as well as other important legal information, which has been provided to us as we build out the solution.
- The resulting PDF needs to have the Darn It Insurance logo on it.
- The resulting PDF will need to include an appendix with all of the photos captured in the Youreka form.
Tech Stack:
Below is a list of the technologies that we will be using to accomplish this:
- Salesforce Service Cloud
- Youreka
- Conga Composer
Implementation Steps:
In the following tutorial, we will accomplish this entire use case from A to Z, using the following steps:
- Configure the Case object to work with Youreka
- Create a Form Template that creates/updates Case records
- Create a Conga Solution to house all of the document generation technology
- Create a Conga Template document, based on sample PDF provided in requirements gathering
- Two Minor Configuration Tweaks in Salesforce
- Create Conga Queries to obtain all of the data necessary for our final PDF
- Return to the Conga Solution record and add Conga Queries
- Return to the Conga Template document, and add the Conga Queries
- Create a Conga Template record in Salesforce
- Add Conga Template to Conga Solution
- Create a Conga Email Template For Users to Deliver the Documents via Email
- Add the Conga Email Template to Conga Solution
- Customize with Parameters
- Add the Conga Solution Button to the Page Layout
- Test
Step 1: Configure the Case Object to Work With Youreka
Youreka's forms are capable of interacting with Salesforce objects through the use of lookup relationships. This means that with lookup relationships, Youreka can map information to and from any other object in your Salesforce environment. Luckily, out of the box, Youreka is already equipped to work with Cases - which is the primary object we'll be using in this tutorial. The only thing we must do from this point is make sure that Youreka's Form object is on the Case page layout!
You can optionally add the Discoveries related list to the Case page layout. However, we will not be using Discoveries in this tutorial.
Step 2: Create a Vehicle Damage Assessment Form Template
We need a form that our field reps can use to assess the damage of the cars that our customers own. We'll use the Youreka Form Template Builder to design the perfect form for our damage assessment.
Visit the App Launcher, type Form Templates, and then create a new Form Template record.
Create a Form Template, using field links to the Case object, as well as questions that inquire about each side of the vehicle, and the overall situation. Below are screenshots of our vehicle assessment form.
After the Form Template is complete, click Save and then Publish.
At this point in the exercise, it's best to create a sample Case and sample Form (using this Form Template) that we can test with throughout the rest of the tutorial. We suggest doing this now.
Step 3: Create a Conga Solution
At this point, we're going to assume that you have already installed Conga Composer into your Salesforce environment, provisioned licenses to the correct users, and gone through the basic setup steps of the application. If not, take some time now to set up Conga Composer.
Once you have set up Conga Composer, the first thing we need to do is create a Conga Solution which will house all of our document generation technology. You can create a Conga Solution record in Salesforce by visiting the Conga Solution tab and click New. With that said, we advise you to go through the Conga Quick Start menu to quickly create a solution record. A screenshot of that can be seen below.
- Name your Conga Solution Vehicle Damage Assessment
- Select Case as the Salesforce Object
- Select a sample Case record (it's best to use the one that you just created in the last step!)
- Optionally, add a description to your Conga Solution
Click Create and then simply click through the chevrons at the top of the screen. You won't need any of them just yet. This means that you can leave everything on the Gather Data, Add Templates, Assign Behaviors, etc. entirely blank. The point of this exercise was that you used the Conga Quick Start to generate a Conga Solution record, and if you filled out the first page, you've successfully done that.
Step 4: Prepare Your Conga Template Document
At this point, we want to spend some time on the actual document that we'll be generating with Conga. To begin, let's have a look at the document that Darn It Insurance gave us - the document that we are striving to generate with Conga Composer. The sample document can be seen below (with some extra numbering which we will use in the paragraph below to describe the document structure.
Remember, Conga Composer is great at combining documents with hardcoded values, as well as queried data from Salesforce to get a unique PDF every time you run the process. So let's break down what we see here on the document:
- The first bit of text, in our example, is hardcoded text that never changes. In other words, we added this to our template and it will look the same for every PDF recipient.
- The second bit of text is a collection of data points that are merged onto the document. These data points come from the Case object.
- The third element on the page is a table of data points from Salesforce. These records come from the Answer object. The Answer object is created when you install the Youreka managed package, and it is what stores all of the individual responses to each question. For more information on this, see the Youreka ERD article. These are the specific questions and answers from a Form record in Salesforce.
- The fourth element on the page is a static image of the front of a car. This image never changes in our example.
- The fifth element on the page is also a static image of a rear-view mirror of a car. This image also never changes in our example.
- The sixth element is similar to the third. It is a table of Answer records which are directly associated with the Form that is filled out by the field rep. These are a subset of answers which are related to the rear-side inspection of the vehicle.
As a part of this step, spend some time on your word document and get it to a point where you clearly understand which elements will always exist on the document, and which elements will require queries from Salesforce. If you want to use our template, it is available in the attachments section of this article.
Note: To include e-signatures in your PDF, you will want to enable the Save E-Sig as JPG custom setting. See how here.
Next, we will build some queries that Conga Composer will use to gather the correct data from Salesforce and add to the document.
Step 5: Two Small Salesforce Configuration Items
Let's take a break for a few smaller tasks that are A.) easy to accomplish, and B.) necessary for our final solution.
1. Create a text formula field on the Answer object in Setup->Object Manager->Answer->Fields and Relationships. Call this field Section Name, and have it represent the Section label on the related Section object. You can use the snippet below as your formula.
This step is important because, in our use case, we're going to have questions and answers from different sections in various areas on our document. So our queries (in the next step) will need the Section label in order to snag the right data from Salesforce.
disco__Question__r.disco__Section__r.Name
2. Create a text formula field on the ContentVersion object Setup->Object Manager->Content Version->Fields and Relationships. Call this field Image URL. Use the following snippet as your formula.
LEFT( $Api.Enterprise_Server_URL_100, FIND( ".com", $Api.Enterprise_Server_URL_100 ) + 4)& "sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=" & Id
This is an important step because Darn It Insurance wants photos on their final PDF. Because Youreka stores the photos captured in the Youreka Mobile app as Salesforce Files, we'll use the Content Version object in Salesforce to query those photos.
Step 6: Create Conga Queries
There's no way around it. This step is going to be meticulous. If you don't have experience with SOQL (Salesforce Object Query Language), there might be times where you are challenged, but as being someone who personally comes from purely a declarative-focused, admin background, I can assure you that you will not only succeed if you follow these instructions, but you might also learn something new. For those of you who have experience with Conga Queries or SOQL in general, you'll cruise right along here. Let's dig in.
As stated above, in order to get the right data merged onto our document, we need to query information from Salesforce. But before we jump right in and create some queries, we need to think strategically and plan out which queries we will need in order to be successful. Let's have another look at our Vehicle Damage Assessment form template, alongside the final document we're hoping to generate.
- The Number 1s in the two images above correspond. They both contain Case data. This information can be accessed by querying the Case object.
- The Number 2s above also correspond. Technically speaking, we will want to query the Answer object in this query. Specifically, we'll want to query the answers to questions that are in the Vehicle Damage Assessment, in the section titled Front of Vehicle. It's very specific, but this specificity will get us exactly what we need for our document.
- The Number 3s above correspond in the same way that the 2s do. We're going to need a query of Answer records - answers to questions that are in the Vehicle Damage Assessment, in the section titled Rear of Vehicle.
So far, each of these will require a separate query. We will build each of them in Conga Composer's nifty Query Builder in Salesforce. Visit the Conga Queries tab, and let's create some Conga Queries.
Create a new Conga Query record (as seen below). Add a name, and a description. If you want to follow along using the Conga Query builder (which is advised, because you'll learn a lot and be better for it), save the record while leaving the SOQL Select Statement field blank. If you want to cheat and just use our queries (maybe you're short on time?), feel free to drop this snippet of code in the SOQL Select Statement:
SELECT disco__Answer__c, disco__Question__c, disco__Question_Value__c,
disco__Question__r.disco__Label__c,
disco__Question__r.disco__Type__c,
disco__Question__r.Section_Label__c
FROM disco__Answer__c WHERE disco__Form__r.disco__Form_Case__c = '{pv0}'
AND disco__Question__r.Section_Label__c LIKE '%Front%'
AND Question_Type__c != 'Attachment/Photo' ORDER BY Question_Order__c ASC
If you are going to use the Conga Query Builder, navigate to your newly created Conga Query record, and click on the Conga Query Builder button.
Before we start, think to yourself. "I'm about to query the Salesforce database. I need to query the Answer object (which stores all of the Youreka form responses). I need those Answers to be only for a specific Form in Salesforce, I only want them to be for questions in the Front of Vehicle section of my form template, and I want them to be in the same order they appeared on the Youreka form.". With this in mind, follow the prompts in the Query Builder.
Select the Answer object, then click Next.
In Step 2 of 4, select the following fields from the Answer object:
- Answer
- Question
- Question Value
Additionally, click on the Lookup: Question option. Select the following fields:
- Question Type
- Section Label
In Step 3 of 4, enter the following information (which corresponds to the numbers below):
- This will ensure that the query will only capture Answers for the Form which is related to the Case record that all of this technology will be running off of. There could be a thousand forms in Salesforce, but we only want the answers to this form, the form that is related to this specific Case. Leave the value blank, Conga Composer auto-populates this in a later step.
- Specify the Section Name. We don't want all of the Answers to return. We just want the Answer records that exist inside the section about the front of the vehicle. This criteria slims down the query to pull just those Answer records, and no more.
- We want to exclude Attachment/Photo questions from our query. We'll handle those later. If you notice from our Form Template that we created in Step 2, we added the option to take photos in each section of our form. At this moment, we want to exclude those from this query.
- Finally, we have the ability to define the SORT ORDER of these Answer records as they are queried. Based on our customer's requirements, we can use the Order field on the question object. Set it to ASC (ascending). This basically ensures that the Answers will be queried in the same order that they were asked in the Form itself. In other words, the query will return the Answers just as they were presented to the user who filled out the form.
In Step 4 of 4, you can test your query. This can be helpful in knowing whether or not the query was built properly. If you want to test, which we absolutely advise, feel free to drop the sample Case ID (from the sample case you created in Step 2) in pv0 and click Preview. The results should look something like this:
What you just completed might have been the hardest part of the tutorial, so if your query comes back with this type of data, you should stand up and celebrate. If your query came back with an error, revisit the screens in the query builder, as well as walk back through the steps in this part of the tutorial and make sure you have everything right.
If your query returned results, we now need to CLONE that query for all of the other parts in our Form Template that have answers we want to populate on the document. Clone the first query you created, and then slightly alter the SOQL Select Statement in each, just as you see below.
Query Name | SOQL Select Statement |
VDA Front | SELECT disco__Answer__c, disco__Question__c, disco__Question_Value__c, disco__Question__r.disco__Label__c, disco__Question__r.disco__Type__c, disco__Question__r.Section_Label__c FROM disco__Answer__c WHERE disco__Form__r.disco__Form_Case__c = '{pv0}' AND disco__Question__r.Section_Label__c LIKE '%Front%' AND Question_Type__c != 'Attachment/Photo' ORDER BY Question_Order__c ASC |
VDA Rear | SELECT disco__Answer__c, disco__Question__c, disco__Question_Value__c, disco__Question__r.disco__Label__c, disco__Question__r.disco__Type__c, disco__Question__r.Section_Label__c FROM disco__Answer__c WHERE disco__Form__r.disco__Form_Case__c = '{pv0}' AND disco__Question__r.Section_Label__c LIKE '%Rear%' AND Question_Type__c != 'Attachment/Photo' ORDER BY Question_Order__c ASC |
VDA Left | SELECT disco__Answer__c, disco__Question__c, disco__Question_Value__c, disco__Question__r.disco__Label__c, disco__Question__r.disco__Type__c, disco__Question__r.Section_Label__c FROM disco__Answer__c WHERE disco__Form__r.disco__Form_Case__c = '{pv0}' AND disco__Question__r.Section_Label__c LIKE '%Left%' AND Question_Type__c != 'Attachment/Photo' ORDER BY Question_Order__c ASC |
VDA Right | SELECT disco__Answer__c, disco__Question__c, disco__Question_Value__c, disco__Question__r.disco__Label__c, disco__Question__r.disco__Type__c, disco__Question__r.Section_Label__c FROM disco__Answer__c WHERE disco__Form__r.disco__Form_Case__c = '{pv0}' AND disco__Question__r.Section_Label__c LIKE '%Right%' AND Question_Type__c != 'Attachment/Photo' ORDER BY Question_Order__c ASC |
VDA Final Summary | SELECT disco__Answer__c, disco__Question__c, disco__Question_Value__c, disco__Question__r.disco__Label__c, disco__Question__r.disco__Type__c, disco__Question__r.Section_Label__c FROM disco__Answer__c WHERE disco__Form__r.disco__Form_Case__c = '{pv0}' AND disco__Question__r.Section_Label__c LIKE '%Final%' AND Question_Type__c != 'Attachment/Photo' ORDER BY Question_Order__c ASC |
You should now have five (5) Conga queries in Salesforce, and all of them are very similar, except for the fact that they are pull answers from different sections of the Youreka form.
At this point, we have one more query to create, and then I promise we're done. This final query is for the photos. If we remember, Darn It Insurance wants the field reps to capture photos in the field, and each of those photos should be visible in an Appendix at the end of the PDF.
For this one, don't worry about using the Conga Query Builder. Create a Conga Query record, name it VDA Photos, and manually add this snippet to the SOQL Select Statement:
SELECT ContentDocument.LatestPublishedVersion.Image_URL__c FROM ContentDocumentLink
WHERE LinkedEntityId In
(SELECT Id FROM disco__Form__c WHERE disco__Form_Case__c = '{pv0}')
This query calls for all of the photos that are related to the Form record that is related to our Case. We're calling for the Image URL field that we created a few steps ago, which will allow the photos to render on our final PDF (more on this later).
Fun fact: We're getting really creative with our snippet above, using a nested SOQL query, while using what is called a Semi Join operator. Put that in your back pocket for the next time you are on Jeopardy and Trebek is asking you questions about relational databases.
The details aren't important, but just know that anytime someone fills out a form that's related to a Case in Salesforce - and they took photos while filling out the form, the resulting PDFs will now contain those photos.
You should now have six (6) Conga Queries records created:
- VDA Front
- VDA Rear
- VDA Left
- VDA Right
- VDA Final Summary
- VDA Photos
If you don't have six queries created, go back through this section and check your work. If those queries aren't testing properly, go back and check your work. You really want to make sure you get this section right before proceeding.
Step 7: Return to the Conga Solution record and add the Conga Queries
Navigate back to the Conga Solution record you created in Step 3. Select Add Query Data.
Add all six Conga Queries to the solution, one at a time. For each, pay very special attention to the Query Alias values. If you're following along with this tutorial line for line, you should copy mine directly. If you're building your own Conga Solution, just make sure that you keep your alias values organized and intuitive. They are necessary later in this process, and if you misspell them even by one letter, you will struggle to troubleshoot. My query alias values are as follows:
- vdafront
- vdarear
- vdaleft
- vdaright
- vdafinalsummary
- vdaphotos
You should now have six (6) Conga Queries added to your Conga Solution. If you do not, go back through this step and make sure you have properly added all of the queries to the solution.
Step 8: Return to the Conga Template document, and add the Conga Queries
In this step, we're going to use those queries that we just created, and make it so that our Word Document that we created earlier in this tutorial can properly receive those queried data.
Open two screens. On one screen/window, open up the Word Document that we will be using for our Conga Template (we started working with this Word Document in Step 4). Remember, a Conga Template is essentially a collection of documents that Conga will use to merge data onto.
In the other window, open the Conga Template Builder. The Conga Template Builder takes the queries that you just created a few minutes ago, and gives you the values that you need to paste in your Word Document. In order to properly merge the right data onto the right spot on the document, Conga needs you to paste certain merge values onto the template. The Template Builder is where you get those values.
If you watch the GIF below, it shows you the click path for accessing the Template Builder. From your Solution record, click Access Template Builder. From here, select Tools and Settings, and then select Template Builder.
Using the menu, collect all of the information you'll need on your template. This can be done by selecting a data point on the left, and moving it to the right side of the screen.
In our example, this includes Case data (Case Contact, Case Subject, Cast Owner Full Name, etc)., as well as the queries that we built a few steps ago.
Additionally, for our example, make sure that you are capturing the Question Label, and the Answer from each of the Answer object queries that we created. For the Photo query, grab the Image URL value.
After you have all of the data you need in the right side of the screen, select Create and Download a New Template on the bottom of the screen.
Use the resulting document to copy and paste each piece of queried data onto your Conga Template document. It should look something like the image below. Keep in mind that as you add your merge fields, the document might very well get ugly, but that's okay. As we test, you will see that it cleans up nicely when real Salesforce data is merged in!
Do this for each section on your template. You should use every query that we built in the previous steps. Finally, for the image query, make sure that it appears like shown below. Manually add the "IMAGE:" and "W=650" to the query statement after you paste it onto your Word Document.
Step 9: Create a Conga Template record in Salesforce
When you are finished with your template and all of the queries have been placed, save your document. Return back to Salesforce, and create a new Conga Template record by visiting the Conga Templates tab and clicking New.
Name your Conga Template Vehicle Damage Assessment. Then upload your Word Document to the Notes & Attachments related list. Conga Composer will use this document when the document generation process fires.
Step 10: Add the Conga Template to your Conga Solution
Return back to your Conga Solution record and click the Add Templates button. Select the Vehicle Damage Assessment that we just created in Step 9.
Step 11: Create a Conga Email Template For Users to Deliver the Documents via Email
Not only is Conga capable of generating documents, but it is capable of creating email messages for delivering those documents. Because Darn It Insurance wants to email the PDFs to customers from the Case, we'll use this step to configure a Conga Email Template.
Visit the Conga Email Templates tab and create a new record. Name the record Vehicle Damage Assessment Email. Use the Advanced Editor button to create your email subject and body.
Within the Advanced Editor, create all of the copy that you intend for the recipient to see in the email. You can include images (such as a company logo), as well as merge data (using the same values you used from the Conga Template Builder in Step 8).
Step 12: Add the Conga Email Template to Conga Solution
Return back to your Conga Solution record, and select the Add Conga Email Template button. Select the email template we just created in Step 11.
Step 13: Customize with Parameters
The final step before we finish our Conga Solution is to customize it with parameters. Parameters can be added to each Conga Solution to slightly tweak the way it behaves. We're going to add four parameters to our solution, to make sure that Darn It Insurance's final solution is working smoothly. For a full list of parameters that can be used, visit Conga's Knowledge Base.
You can add parameters to a Conga Solution by visiting the Conga Solution record and clicking on the Customize with Parameters button. Click in, and add the following parameters.
- EmailRelatedToID={!Case.Id}. We're going to add this parameter because Darn It Insurance's Salesforce system administrator wishes to have all of these Conga emails to be logged to Salesforce. By adding this parameter, Conga will automatically log the email to Salesforce, and append it to the Case record.
- EmailToID={!Case.ContactID}. We're going to add this parameter to our solution so that the email recipient is automatically defined. By adding this parameter, the emails with our documents will always be sent to the Contact that is associated with the Case.
- DefaultPDF=1. This parameter ensures that the resulting document is converted from a Word Document to a PDF before it is sent out to the customer.
- DS7=12. This parameter ensures that the entire solution works automatically after the button is clicked, without any manual intervention by the Salesforce user.
After these parameters are included, click Update Button/Create Button on the top of the Conga Solution page. This will automatically create a custom button on the Case object that we can use to launch the solution. Once users click this button, the entire thing should work seamlessly. The queries will run, the data will be aggregated from the form and case, the information will be merged onto the Conga Template document that we configured, and an email will be sent to the customer with that document as an attachment.
Step 14: Add the Conga Solution button to the Case Page Layout
Visit Setup->Object Manager->Case->Page Layouts. From here, add the Conga Solution button to the Case Page Layout for your users to begin using.
Step 15: Test!
We're at the final step! Visit any Case record in Salesforce, make sure that a Vehicle Damage Assessment form has been filled out (either on Desktop, or on the Youreka Mobile App), and is visible in the Forms related list. Make sure that your email address (or any test email address) is associated with the Contact on the Case. Click the Conga Solution button that we just added to the page layout in Step 14. The result should be that the user is quickly taken to a Conga loading page, where the Conga Solution is working its magic. The user will be promptly taken back to the Case page. Meanwhile, and email will be sent, using our Conga Email Template. Attached to that email will be the document (PDF) that we configured throughout this tutorial. It will have Case information, as well as information from each section in the form. Finally, it will have the photos from the Youreka form added in the appendix.
Comments
0 comments
Please sign in to leave a comment.