Defining And Attaching Prevalue Sources
Prevalue sources are a way to pre-define and/or retrieve a list of items from a certain source. They can be added in any field types that include some kind of list like Dropdown and Multiple/Single Choice lists.
Setting up a Prevalue Source
Prevalue sources can be managed in the Prevalue sources folder available in the Forms section.
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F1470284034-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FHN4dErU7ghf8hOdcQpSs%252Fuploads%252Fgit-blob-bb90fa4e7d308edc77ff9cebf4f17c752b1d9304%252Fprevaluesourcetree.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=23b3f3b3&sv=1)
To set a prevalue source:
Navigate to the Forms section.
Right-click the Prevalue sources folder and select Create.
A new page opens in the right-side of the editor where you'll need to setup and configure your prevalue source.
Enter a Name.
Select the type of prevalue source from the Type drop-down. For more information on the different default types, see the Overview of the Prevalue Source Types article.
Choose type
Configuring the Prevalue Source
Depending on the Type you choose, you'll need to provide some additional settings:
In this walk-through, we will select Get values from textfile from the Type drop-down.
Now, provide a file containing the list to use as prevalues. For example: A
.txt
file containing the following values:\Select Pick File and choose the text file you created.
Once the text file is uploaded, click Save to save the prevalue source.
If the file is successfully uploaded and validated, you will see an overview of the values in a tabular format.
If you would like to have different values presented to your users from the value stored, you can provide two values per line, separated with a vertical bar (|), e.g.:
In this case the user would pick from a list showing the captions, but the single integer values would be stored with the record.
This can be useful if the recorded entries are used in any subsequent workflows or business processes, where particular values, that aren't appropriate for the user to select from, are required.
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F1470284034-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FHN4dErU7ghf8hOdcQpSs%252Fuploads%252Fgit-blob-7e0a79b21b1db8e0dc2dcd6a3544d7fbb7038747%252FPrevalues-with-caption.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=ac08bf99&sv=1)
Defining Cache Options for the Prevalue Source
Sometimes retrieving the list of options for a prevalue source can be an expensive operation. If the source depends on data from external systems, it could be that the list changes regularly or rarely.
Given the variation here, we allow you to select an appropriate level of caching for the list of options.
You can choose between:
No Caching
- no caching will be applied and the list of options will be retrieved from source on every request. You will likely only want to choose this option if the information changes frequently and it's important that the latest is presented to website visitors.Cache For Specified Time
- the list will be cached for the period of time provided.Cache With No Expiry
- the list will be cached on first request and not retrieved again until either the prevalue source is edited or the website is restarted. This ismost appropriate to use for information held within the prevalue source data itself (such as when uploading a text file).
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F1470284034-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FHN4dErU7ghf8hOdcQpSs%252Fuploads%252Fgit-blob-d030dd94fd4e924aaa757a201c68805f01bace0d%252Fprevalue-cache-options.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=83af5be8&sv=1)
Attaching a Prevalue Source to a Field
Once a prevalue source has been created, it can be used while building Forms in the Forms designer.
Example: Let's add a Multiple Choice field type in our Form.
If there is at least one prevalue source defined in the project, the Prevalues source will contain a dropdown from where you can choose the predefined value.
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F1470284034-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FHN4dErU7ghf8hOdcQpSs%252Fuploads%252Fgit-blob-c1293a4a9ae90db8f5bac30d36afab3f481ab84a%252FFieldPrevalueSource.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=c6d0aa4&sv=1)
Once you have selected the prevalue source, the values are rendered in the Forms designer from the attached source.
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F1470284034-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FHN4dErU7ghf8hOdcQpSs%252Fuploads%252Fgit-blob-ba1e9aeac2f579911102e0afcd71f4e339bf5e83%252Ffieldpreview.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=79aa4d0b&sv=1)
Last updated