Manage the properties of a type

Each content type is included in a web service, together with a list of the most useful properties and field properties. For each content type, you can exclude fields that are included by default or include fields that are not included by default. You can also change the properties that are included for each field, such as sorting or filtering.

EXAMPLE: Exclude the Author field from the News content type and make the news Summary a read-only field.

Perform the following:

  1. Click Administration » Settings » Advanced » WebServices » Routes » Frontend » Services.
  2. Select you web service and click Types.
  3. Click Telerik.Sitefinity.News.Model.NewsItem » PropertyMappings » Author » Delete.
  4. Click Summary and select ReadOnly.
  5. Save your changes.

The Author field is no longer available through the web service and the news Summary is available only as a read-only field.

Create a property field

Each type can have properties assigned to it, such as Name, Author, Related media, Parent, etc. The following types of property mappings are available: Persistent, Calculated, Navigational, and Complex.
Perform the following:

  1. Click Administration » Settings » Advanced » WebServices » Routes 
  2. Expand <your-route> » <your-service> » <your-type> » Property mappings.
  3. Click Create new and select one of the following:
    • PersistentPropertyMapping
      Persistent properties fields are directly mapped to the database. They include Id, Title, DateCreated, LastModified, etc. These properties can be queried, filtered, and made read-only. You can control how these properties are serialized, using the Name property – you can change how the property name is returned from the service in the JSON.
      Configure the following fields:
      • Persistent name
        This is the name of the property in the actual CLR type. If you do not specified, the Name property is used.
      • Allow filter
        Specifies whether to allow or deny filtering on a property.
      • Allow sorting
        Specifies whether to allow or deny sorting on a property.

        NOTE: Filtering and sorting should be done on fields that have indexes on them in the database. Most of the fields do not have indexes and as a result the filtering and sorting on those fields might take longer to execute. Use caution when enabling these two settings. Or as an alternative, you could manually add indexes on the fields that you want to filter or sort.

      • Selected by default
        Calculated and persistent properties have the setting – SelectedByDefault. This is a setting that determines which properties will be returned implicitly when querying the service type. For example, Tags and Categories are notSelectedByDefault, because this properties cause DB queries and can generate an overhead, if they are selected by default for a large amount of items.
      • Is key
        If you set it to true, then this property will be used for a key in all of the calls to the parent type.
      • Description
        This is the description of the field that will be available in the metadata. Only a single ID per type is supported.
      • Name
        The name of the property. You cannot have two properties with the same name. The name property can be used for renaming the properties.

        NOTE: All of the dates that Sitefinity CMS serves are in UTC and in the ISO 8601 format. JavaScript is familiar with this date format and can easily convert the string value of the date format to a JS object using new Date("DateVAl")

    • CalculatedPropertyMapping
      Calculated properties are types of properties that are dynamically calculated on every request. They are not mapped to the database and are read-only. You can write your own properties. For more information see Custom calculated properties.
    • NavigationPropertyMapping
      Navigational properties are the types of properties that are used to query relations. For example, BlogPost and Blog. Each navigational property has a ResolverType setting. This is the implementation of how the data for the current item is queried. The API for custom navigational properties is not public.
      You can choose between the following types of navigational resolvers – Persistent and RelatedData.
      • Persistent navigational properties
        These are used for relations such as Blog and BlogPost or Image and Image library
        The resolver type is Telerik.Sitefinity.Web.Services.Contracts.PersistentNavigationResolver.
      • Related navigational properties
        These are used for Related data queries.
        The resolver type is Telerik.Sitefinity.Web.Services.Contracts.RelatedDataPropertyResolver

        NOTE: If your service has an auto-generated collection of types, when you add a related data or related media to a type, Sitefinity CMS automatically creates a property mapping for this field. If the collection is not auto-generated, you have to create it manually.

        IMPORTANT: If you want a related data or media field to be available in the service, the type of the related data or media must also be part of the service. For example, if you want a service to expose the related images of news items, the images type must also be exposed in the service.

        EXAMPLE: You can query the related images of a news item, using the following query string:
        /api/default/newsitems?$expand=RelatedImages
        In this case, RelatedImages is the exact name of the custom field that is set in the backend.
        Expand will return all the properties of the related items of the news type.

        For more information about querying navigational properties, see oData documentation » System Query Option $expand.

        NOTE: Navigational properties do not support filtering or sorting and are not optimized for performance.

    • ComplexPropertyMappings
      The ComplexPropertyMapping field type is used for properties that are not of simple types like integer, string GUID, etc. You can use it for properties that are composed of other properties. The return type must be marked with the DataContractAttribute. All of the child properties that are included must be marked with the DataMemberAttribute.
  4. Save your changes.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?