##Build a new document and merge fields using Google Doc Connector##
A request that we have received on occasion is the need to dynamically populate a new document based off a templated word style document. This could even be described as doing a mail merge type of action into a new document where you specify which fields will get populated in the document by defined fields from a different system or process.
Let’s say we need to populate the document below using fields that come from another application like Smartsheet, Workfront, Salesforce, etc. whenever a new item is created. As you can see in the below image there field tags specific to each field that needs to be dynamically populated.
*The naming of these fields is important as each field MUST have a unique name.
Once you have your document template within Google Docs set up in this manner you are ready to tackle building your workflow. The key here will be finding the “ID” of the template that you want each new document to be built off it. The easiest way to find this is when you are viewing the document the URL will contain the ID you need to use:
The ID will look something like this: 1mXyukbM6i6y9bipR4ga7rC6Y3xayW67wYcnbBreanpp
Once you have the ID then you can work on setting up the merge of the fields using the “Replace Multiple Terms” from the list of all the new Google Docs actions:
The last part that is critical is that the number of fields that can be merged is extensible. The key is that the headers for each field that you create in the step should match exactly to the field headers from within the templated document you are using.
After you have labeled all of the fields within the document that you are looking to replace as part of the process you are ready to drag the input fields in and complete the step. When you are done you might have a workflow that looks something like below. Again, Smartsheet is just being used as an example, BUT this can be accomplished with any of our other systems assuming the use case warrants.
Have had success in this use case labeling the field inside the Google Doc Template using the format shown in the screenshot of the doc above.
Let’s hear from any of you how this could be used or if you have a variation on the use case you are interested in sharing.