change the content in word(.docx) file

Abhijeet0610
Tera Contributor

I am doing an integration with MS word by clicking on UI action it is opening my template which i have stored in sys_attachment table to MS word online editor on my SharePoint . now i want to auto populate some data like caller and short description .

Abhijeet0610_1-1727263999606.png

these "caller_name" and "short_description" are my placeholders which i want to change .
Thanks and regards,
Abhijeet Singh

 

 

1 REPLY 1

John Martin2
Tera Expert

Autopopulating from ServiceNow tables into MS Word templates can only be done with a combination of DTech Apps ServiceNow certified applications DocIntegrator and DocGenerator.  Go check them out on the ServiceNow store.

 

Here is a bit more information:

DTech Apps ServiceNow certified applications DocIntegrator and DocGenerator can work together beautifully to achieve the automatic population of data from ServiceNow (like Caller and Short Description) into your MS Word Online template hosted on SharePoint, triggered by a UI Action. Here's how:

1. DocIntegrator: The Connection Bridge

  • Secure SharePoint Access: DocIntegrator establishes a secure and authenticated connection between your ServiceNow instance and your organization's SharePoint Online environment. This is crucial for accessing the template and potentially saving the generated document later.
  • Retrieving the Template URL: Your UI Action currently opens the template in MS Word Online. DocIntegrator can help ensure this URL is dynamically constructed or retrieved based on the template location in SharePoint.

2. DocGenerator: The Data Population Engine

  • Template Design with Placeholders: You'll use DocGenerator's features (or standard MS Word content controls) to define placeholders within your Word template for the data you want to auto-populate (e.g., {{Caller}}, {{Short Description}}).
  • Data Mapping: DocGenerator allows you to map fields from the current ServiceNow record (where the UI Action is clicked, like an Incident or Request) to these placeholders in your Word template.
  • Generating the Document: When the UI Action is clicked:
    1. DocGenerator retrieves the template: Instead of directly opening the sys_attachment in Word Online, the UI Action will trigger a DocGenerator process. DocGenerator, using DocIntegrator's connection, can access the template file in your SharePoint library.
    2. Data Extraction: DocGenerator retrieves the values of "Caller" and "Short Description" from the current ServiceNow record.
    3. Placeholder Replacement: DocGenerator merges the extracted data into the Word template, replacing the {{Caller}} and {{Short Description}} placeholders with the actual values.
    4. Opening in Word Online (or Saving to SharePoint):
      • Option A (Direct Open): DocGenerator can generate a temporary, data-populated version of the document in SharePoint and then redirect the user's browser to open this temporary document in Word Online.
      • Option B (Save and Open): DocGenerator can save the populated document to a designated SharePoint library (potentially linked back to the ServiceNow record using DocIntegrator) and then provide the user with a link to open it in Word Online.

Simplified Workflow:

  1. User clicks UI Action in ServiceNow.
  2. UI Action triggers a DocGenerator process.
  3. DocGenerator (via DocIntegrator) accesses the template in SharePoint.
  4. DocGenerator retrieves "Caller" and "Short Description" from the current ServiceNow record.
  5. DocGenerator merges the data into the template.
  6. DocGenerator either:
    • Creates a temporary populated document in SharePoint and redirects the user to open it in Word Online.
    • Saves the populated document to SharePoint and provides a link to open it in Word Online.

Benefits of Using DocIntegrator and DocGenerator:

  • Seamless Integration: Both are ServiceNow-certified applications designed to work together and with the platform.
  • Automated Data Population: Eliminates manual data entry, saving time and reducing errors.
  • Template Management in SharePoint: Keeps your templates in a centralized and easily manageable location.
  • Flexibility: Offers options for directly opening in Word Online or saving the generated document back to SharePoint.
  • Enhanced User Experience: Provides a smoother and more efficient document generation process directly from ServiceNow.