---
schema_version: "1"
id: 04881ddeb60bafdc76b6717287cd69f1c26828357bbdae54e96c14b9224cf86a
title: Sample Apex Trigger to Specify Documents or Templates
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/admin_files_quip_apex_trigger.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.admin_files_quip_apex_trigger.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: dafd087d19c81c29b09729753ed68b9d7139df8537f25d7a64b8f29cc22b48f6
description: Use an Apex trigger to programmatically specify a document or template in a custom URL field. You must add a field if you selected the Different templates for different records option when you added the Quip Document component to a Lightning page.
products:
  - Quip
  - Cross Cloud
release: "264"
---
# Sample Apex Trigger to Specify Documents or Templates

Use an Apex trigger to programmatically specify a document or template in a custom URL field. You must add a field if you selected the **Different templates for different records** option when you added the Quip Document component to a Lightning page.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr></tbody></table>

This example sets the QuipTemplateUrl custom field of the Account object to the template located at the URL https://mycompany.quip.com/E5FSAel9xIsB. The trigger fires before you insert an account.

```
// Sample Code for setting a Quip template URL programmatically using Apex
trigger AddQuipTemplate on Account(before insert)
{
    for(Account a : Trigger.New) {
        // Set the QuipTemplateUrl custom field to the Quip template document
        a.QuipTemplateUrl__c = 'https://mycompany.quip.com/E5FSAel9xIsB';
    }   

}
```