Loading
Omnistudio Document Generation
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Map Image Tokens in the Omnistudio Data Mapper for Server-Side Omnistudio Document Generation

          Map Image Tokens in the Omnistudio Data Mapper for Server-Side Omnistudio Document Generation

          Use image tokens in a Microsoft Word or Microsoft PowerPoint document template to insert dynamic images in generated DOCX and PDF files. The image token must start with IMG_, such as {{IMG_header}}. Salesforce supports single-image, multiple-image, and loop-image tokens. Use Data Mappers to extract images from the org and define their height and width.

          Required Editions

          Available in: Lightning Experience
          Available in: Professional, Enterprise, Unlimited, and Developer Editions
          User Permissions Needed
          To map tokens in the Data Mapper: DocGen Designer
          1. Create a Microsoft Word document and add image tokens.
            Place image tokens anywhere within the document template, such as paragraphs, tables, and text boxes. Use a token in a header or a footer, or within a repeating content section to pass an array of images. Here's an example of a DOCX document with image tokens.
            A document template that has image tokens inserted within a header, table, and body of a document
          2. Create a Microsoft Word template.
            1. Select Data Mapper as the token mapping method.
            2. Enter a mapping Data Mapper bundle name.
              The Data Mapper Transform maps the field with the ID to the token in the document template. The Data Mapper Transform then transforms the tokens with actual data in the document.
            3. Enter a Data Extract Data Mapper bundle name.
              The Data Mapper Extract retrieves the field with the ID that identifies the image to be used in the tokens.
          3. To open the Data Mapper Extract on a new browser tab, click the Dataraptor link icon icon next to the Data Extract Data Mapper Bundle Name field.
            1. Create a Data Mapper Extract.
            2. Define the Initial Extractions.
            3. From the list of Salesforce object tables, select the option based on where you uploaded your image.
              • Files: ContentDocument
              • Notes & Attachments: Attachment
              • Documents: Contract Document
                Important
                Important

                All images intended for rendering in the same generated document must be stored in a single repository.

              The EXTRACT tab of the Data Mapper Extract where we specified the objects to be queried in the Extract Output Path and the filters to be used for the extraction

              In this example, we use the content document table to retrieve the content ID of the image from the object by using the title as a filter.

              Set the Extract Output Path to contractObject:<contentdocumentname> and the Title filter to contractObject:<custom image field API name to map the content document with the custom image field ID. For example, contractObject:ins_238__Header__c.

              Note
              Note

              Here, ins_238__Header__c is the image API field name where the image is stored. With this image name, the system queries the content document table to fetch the content ID. Alternatively, use the Object ID to pass to the Data Mapper Extract.

              Important
              Important

              For images uploaded in documents, you must use name as the filter instead of the title filter.

            4. Define the Data Mapper Extract Output.
            5. In Extract JSON Path, select the source field for extraction.
            6. In Output JSON Path, specify the output path.
            7. Repeat the steps to add all the tokens in the document template with a source field.
              Data mapping from the extraction step JSON to the output JSON on the OUTPUT tab
            8. To confirm that the response pane shows a JSON structure containing the desired output, on the PREVIEW tab, enter the Salesforce object ID and click Execute.
              PREVIEW tab showing a JSON structure containing the desired output. The image ID is pulled from the desired objects.
            9. On the Output tab, copy the Current JSON Output value, and save it for using it later in your Data Mapper Transform.
              The Current JSON Output pane shows the structure that your output mappings specify.
          4. To open the Data Mapper Transform on a new tab, click the Link icon icon next to the Mapping Data Mapper Bundle Name field.
            1. Create a Data Mapper Transform.
            2. Additionally, define formulas in a Data Mapper to specify the height and width of the images.

              When you define a formula, map its output to the output JSON (for extracts and transforms). See Use Formulas in Omnistudio Data Mappers.

              Note
              Note

              To maintain the original aspect ratio of an image, define either the height or the width, but not both.

              • If neither height nor width is defined, the image is displayed at its original size, up to a maximum of 350 px (width) × 400 px (height) on an A4 portrait page.
              • If you define only one dimension (height or width), the image is proportionally scaled based on its original aspect ratio. For example, an image that is originally 100 × 100 px and has height set to 20 will be scaled to 20 × 20 px.
              • If you define both height and width, the image is rendered using those exact values, up to a maximum of 600 px × 800 px on an A4 portrait page. If the original image is larger, it will be scaled down to fit the defined dimensions.
              The defined formulas in a Data Mapper. For example, the Formula tab has 200 and Formula Result Path field has footer_width.
            3. On the TRANSFORM tab, in the Input JSON panel, paste the Current JSON Output code that you copied from the Data Mapper Extract.
            4. Click Quick Match.
              The fields in the Input Mappings column come from the JSON code that you pasted into the Input JSON panel and the formulas that you defined on the Formulas tab. The fields in the Output Mappings column come from the document template.
              The Input Mappings and Output Mappings columns
              Note
              Note

              For each image token in the document template, there are three output mappings: height, source (src), and width. The src is mandatory because it uses the image ID. The height and width are optional. If you don't define the height and width, the image renders in its original size in the document.

            5. Drag fields from the Input column to the Output column to match the fields.
              The Matched Mapping column populated when the fields from the Input column to the Output column are matched
            6. Save your changes.

              The Transform tab is populated. The Input JSON path matches the output from the Data Mapper Extract. The Output JSON path matches the tokens in the document template.

              The populated TRANSFORM tab
            7. Click Edit  and change the Output Type toJSON, and then save your changes.
            8. Go to the PREVIEW tab, and verify the Object source (src) for the image tokens.
              The PREVIEW tab where the mapping you provided is executed.
              For some image tokens only the source is listed and for some image tokens both source, width, or height is available.
           
          Loading
          Salesforce Help | Article