Content retrieval

This section describes how to retrieve data from Xperience. You can work with the following system objects:

Retrieve form data

When retrieving forms data, use BizFormItemProvider and generated <FormCodeName>Item classes. BizFormItemProvider exposes two methods to facilitate form data retrieval:

  • GetItem<TType>–returns a record of the specified type and ID.
  • GetItems<TType> – returns all records of the specified type using the ObjectQuery API.

The following example demonstrates how to retrieve individual submissions from a ‘Contact Us’ form. The code uses a generated form data class (ContactUsItem) to work with individual submitted entries.

// Gets all form items of the given type
IEnumerable<ContactUsItem> items = BizFormItemProvider.GetItems<ContactUsItem>();

// Gets a single form item with the given type and ID
ContactUsItem item = BizFormItemProvider.GetItem<ContactUsItem>(1);

// Programatically assigns and saves a value for the form record's 'CustomField' input
object customFieldValue = "CustomValue";
item.SetValue(nameof(item.Fields.CustomField), customFieldValue);

Retrieve general object data

To retrieve general objects managed by the system, use the corresponding <Class>Info classes (e.g., UserInfo) and the I<Class>InfoProvider interface to retrieve the data. The query generated by the Get method of the interface can be parameterized using ObjectQuery syntax, see ObjectQuery API and Database table API for more information.

The following example shows how to get user objects.

// An instance of  IUserInfoProvider (e.g., obtained via dependency injection)
private readonly IUserInfoProvider userInfoProvider;

// An instance of the object query
var query = userInfoProvider.Get();

// Gets all users and materializes the result
IEnumerable<User> users = query.GetEnumerableTypedResult();