--- title: Create a JavaScript search result template slug: '1585' canonical_url: https://docs.coveo.com/en/1585/ collection: build-a-search-ui source_format: adoc --- # Create a JavaScript search result template {% include md-includes/version-tags/tag-product-version.liquid changeType='new' product='c4sf' version='2.26' month='7' day='' year='2016' link='1124/#july-2016-maintenance-release-v226' %} Members with the [required privileges](https://docs.coveo.com/en/3151/) can easily create new search result templates using the Interface Editor by duplicating an existing one. > **Leading practice** > > Leave default search result templates intact and rather modify copies of them. > This way, you can always come back to the default templates to review how they were made. To create a search result template . In the Coveo Administration Console, on the [**Search Pages**](https://platform.cloud.coveo.com/admin/#/orgid/search/search-pages/) ([platform-ca](https://platform-ca.cloud.coveo.com/admin/#/orgid/search/search-pages/) | [platform-eu](https://platform-eu.cloud.coveo.com/admin/#/orgid/search/search-pages/) | [platform-au](https://platform-au.cloud.coveo.com/admin/#/orgid/search/search-pages/)) page, click the desired page, and then click **Edit interface** in the Action bar. Alternatively, see [Access the Coveo for Salesforce Interface Editor](https://docs.coveo.com/en/3081/) for Salesforce search interfaces. . In the Interface Editor, click icon:settings-cog[alt=settings-cog,width=16], and then click **Result templates**. . In the **Result templates** panel, click **Add**. . When adding a result template to a [hosted search page](https://docs.coveo.com/en/2866/), in the **Result templates** panel: .. Under **Select a connector**, select the checkboxes corresponding to the [connectors](https://docs.coveo.com/en/2734/) for which you want to create a result template, and then click **Next**. Click **Any** to apply this template to all search results regardless of their type. .. Under **Select object type**, select the checkboxes corresponding to the object types for which you want to create a result template, and then click **Next**. .. Under **Select file type**, select the checkboxes corresponding to the [item](https://docs.coveo.com/en/210/) types for which you want to create a result template, and then click **Next**. .. Under **Select a template layout**, select a search result layout by clicking the numbers or the **<* and *>** keys, and then click **Apply**. A preview is displayed for each layout. > **Note** > > You can later customize this layout (see [Modify a JavaScript search result template grid](https://docs.coveo.com/en/1929/) and [Organize components within a search result template grid](https://docs.coveo.com/en/1745/)). . When adding a result template to a Salesforce search page: .. [[SelectDocumentType]]Under **Select a document type**: ... Under **Select or enter a field to apply the condition on**, choose the [field](https://docs.coveo.com/en/200/) that should be used to apply your template condition on. ... Under **Select or enter field values on which to filter on**, select the values your field should have for the result template to be applied. Once selected, the value should move to the **Select values** field. .. Under **Select a template layout**, select a search result layout by clicking the numbers or the **<* and *>** keys, and then click **Apply**. A preview is displayed for each layout. > **Note** > > You can later customize this layout (see [Modify a JavaScript search result template grid](https://docs.coveo.com/en/1929/) and [Organize components within a search result template grid](https://docs.coveo.com/en/1745/)). . In the **Result templates** panel, your newly created template now appears as **My** [**selected template layout**] **template**. When the corresponding panel isn't already open, click the template name. . In the panel that appears, in the **Template Option** tab: .. In the **Id** box, replace the default name with the desired name for your new template. .. When in a Salesforce search page, in the **Condition** boxes, verify that the **Field to apply the condition on** and **Field must match one of those values** fit your use case. .. When in a hosted search page, ensure that the values **Field: 'your field' must match one of those values** fit your use case. .. Under **Fields** or **Fields to request on every query**, start typing a field name in the dropdown menu to filter fields by name, and then click the desired fields. Selected fields appear in the **Selected fields** below the dropdown menu. Click **X** to delete them. > **Note** > > The field name must comply with the `@fieldname` format. . [[EditTemplateGrid]]On the **Layout** tab, you can modify the template grid (see [Modify a JavaScript search result template grid](https://docs.coveo.com/en/1929/) and [Organize components within a search result template grid](https://docs.coveo.com/en/1745/)). . On the **Code** tab, you can review the template grid code. You could also copy the code and paste it in the same place in another search page. For example, you modify and test your JavaScript search result template in a dedicated search page to avoid accidentally making unwanted changes in your production page. Therefore, once satisfied with your modifications, you copy and paste the modified code into your production search page. > **Note** > > The search result template grid code doesn't include the condition under which the code should apply, that is, which search results should be formatted this way. > To copy the condition as well, you must access the entire page code, and then look for the `