1. External

Examples

The following examples are designed to help you understand and implement external page components:

For all examples, types are imported from the SDK:

import {
    FieldFilterRequestResource,
    FilterOperator,
    RequestedFilterType,
} from "@sitecore/sc-contenthub-webclient-sdk";

The following table provides code examples for filtering:

  • Filter: Code example
  • Filter on one or more entity IDs:
new FieldFilterRequestResource({
    filterType: RequestedFilterType.IdFilter,
    fieldName: "Id",
    operator: FilterOperator.AnyOf,
    values: [1, 2, 3],
    hidden: true,
    multiSelect: false,
    visible: true,
})
  • Get all entities from the specified definition:
new FieldFilterRequestResource({
    fieldName: "definitionName",
    operator: FilterOperator.AnyOf,
    filterType: RequestedFilterType.InFilter,
    values: ["M.Asset"],
    hidden: true,
    multiSelect: false,
    visible: true,
}
  • Filter on a string property: NoteAlso available: operator: FilterOperator.DoesNotEqual
new FieldFilterRequestResource({
    filterType: RequestedFilterType.FieldFilter,
    operator: FilterOperator.Equals,
    fieldName: "Status",
    values: ["Active"],
})
  • Filter on a Boolean property: NoteAlso available: operator: FilterOperator.DoesNotEqual (for example, to get all entities where the boolean is false or null (not set)).
new FieldFilterRequestResource({
    definitionName: "M.AssetMedia",
    filterType: RequestedFilterType.FieldFilter,
    fieldName: "IsOrderingCategory",
    operator: FilterOperator.Equals,
    values: [true],
    visible: true,
})
  • Filter on entities where the specified relation is not filled in (that is, it is missing).: NoteYou can also filter on entities where the relation is filled in using FilterOperator.Exists. Other fieldName options include "ancestors..somerelationname.ancestor_ids", "taxonomy_items.98.children", and "taxonomy_items.98.".
new FieldFilterRequestResource({
    filterType: RequestedFilterType.FieldFilter,
    fieldName: "relations.SomeRelationName.parents",
    operator: FilterOperator.Missing,
    values: [null],
    hidden: true,
    multiSelect: false,
    visible: true,
}
  • Filter on entities that have a relation with any entity 1, 2, 3 (FilterOperator.AnyOf)Filter on entities that have a relation with all entities 1, 2, 3 (FilterOperator.AllOf):
new FieldFilterRequestResource({
    fieldName: "relations.SomeRelationName.parents",
    operator: FilterOperator.AnyOf,
    filterType: RequestedFilterType.InFilter,
    values: [1, 2, 3],
    hidden: true,
    multiSelect: false,
    role: null, // needs to be defined for self relations! "Parent" or "Child"
    visible: true,
})
Note

To help you implement external page components, code samples are also available.

If you have suggestions for improving this article, let us know!