> For the complete documentation index, see [llms.txt](https://learn.capstorm.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.capstorm.com/copystorm-restore/reference/configuration-files/how-to-use-a-text-field-as-a-reference-field.md).

# How To Use a Text Field As a Reference Field

While it is best practice to store Salesforce Reference Ids in Reference Fields, there are a handful of situations where a Reference Id may be stored in a Text field.

By default, CopyStorm/Restore will use Reference Field metadata to determine whether or not a field contains a Reference Id, and which table(s) the Id may reference. In cases where Reference Ids are stored in Text fields CopyStorm/Restore can be configured to treat the field as a Reference Field, which will cause CopyStorm/Restore to:

* Take the reference information into account when determining the table restore order.
* Use CopyStorm/Restore’s Old Id to New Id mapping to ensure referential integrity when uploading field values for the Text field.

To configure CopyStorm/Restore to treat a Text field as a Reference field:

1. Create a file `[CopyStormRestore]/config/CopyForceMetadata.xml`
2. Use the following template to populate the file:

```
<CopyForceMetaData>
<!--
Treat the field Contact.TextField__c as a reference field which:
- Contains references to either the Account or Contact table.
- Uses a relationship name of MyCustomRelationship.
-->
	<FieldRule table="Contact" field="TextField__c" relatedToTable="Account,Contact" relationshipName="MyCustomRelationship"/>
</CopyForceMetaData>
```
