Script properties

In Sitecore Content Hub, all types of scripts have access to two main objects: MClient and Context. Both MClient and Context objects provide users with a collection of useful properties. See the API Reference for additional information.

MClient properties

MClient properties are available for all types of scripts. They allow users to manipulate data in Content Hub (for example, data sources, entities, entity definitions, policies, scripts, users) and other functionalities like querying and logging through different clients.

The following table summarizes the available MClient properties:

Property

Type

Commands

Stylelabs.M.Sdk.Clients.ICommandsClient

Cultures

Stylelabs.M.Sdk.Clients.ICultureClient

DataSourceFactory

Stylelabs.M.Sdk.Factories.IDataSourceFactory

DataSources

Stylelabs.M.Sdk.Clients.IDataSourcesClient

Entities

Stylelabs.M.Sdk.Clients.IEntitiesClient

EntityDefinitions

Stylelabs.M.Sdk.Clients.IEntityDefinitionsClient

EntityFactory

Stylelabs.M.Sdk.Factories.IEntityFactory

Jobs

Stylelabs.M.Sdk.Clients.IJobsclient

Logger

Stylelabs.M.Sdk.Contracts.Logging.ILogger

Notifications

Stylelabs.M.Sdk.Clients.INotificationsClient

Package

Stylelabs.M.Sdk.Clients.IPackageClient

Policies

Stylelabs.M.Sdk.Clients.IPoliciesClient

Querying

Stylelabs.M.Sdk.Clients.IQueryingClient

Scripts

Stylelabs.M.Sdk.Clients.IScriptsClient

Settings

Stylelabs.M.Sdk.Clients.ISettingsClient

TypedEntityFactory

Stylelabs.M.Sdk.Factories.ITypedEntityFactory

Users

Stylelabs.M.Sdk.Clients.IUsersClient

Context properties

Context properties are the different context variables that are accessible by scripts. Each script type has specific context properties. The following section defines the context properties for each script type.

User sign-in scripts

The following table contains the context properties available for User sign-in scripts.

Property

Type

Description

AuthenticationSource

M.Base.Scripting.Users.AuthenticationSource

This property contains the source of registration of the user, which can be internal (Content Hub) or external (an external provider). Possible values:

  • Internal

  • External

User

M.Sdk.Contracts.Base.IEntity

This property contains the entity object representing the signed-in user.

ExternalUserInfo

ExternalUserInfo

This property contains the information about the user that the external provider supplies. ExternalUserInfo properties:

  • Provider

  • Username

  • Email

  • Culture

  • Claims

Warning

ExternalUserInfo is only used when the AuthenticationSource is External.

User pre-registration scripts

The following table contains the context properties available for User registration scripts.

Property

Type

Description

AuthenticationSource

M.Base.Scripting.Users.AuthenticationSource

This property contains the source of registration of the user, which can be internal (Content Hub) or external (an external provider). Possible values:

  • Internal

  • External

Username

string

This property contains the username of the created user.

Email

string

This property contains the email of the created user.

Culture

System.Globalization.CultureInfo

This property contains the culture information of the created user.

User post-registration scripts

The following table contains the context properties available for User registration scripts.

Property

Type

Description

AuthenticationSource

M.Base.Scripting.Users.AuthenticationSource

This property contains the source of registration of the user, which can be internal (Content Hub) or external (an external provider). Possible values:

  • Internal

  • External

User

M.Sdk.Contracts.Base.IEntity

This property contains the entity object representing the signed-in user.

ExternalInfo

ExternalUserInfo

This property contains the information about the user that the external provider supplies. ExternalUserInfo properties:

  • Provider

  • Username

  • Email

  • Culture

  • Claims

Warning

ExternalInfo is only used when the AuthenticationSource is External.

Metadata processing script

The following table contains the context properties available for Metadata processing scripts.

Property

Type

Description

File

M.Sdk.Contracts.Processing.IFile

This property contains the File entity that is being processed. IFile properties:

  • Filename: string

  • Extension: string

Asset

Stylelabs.M.Sdk.Contracts.Base.IEntity

This property contains the entity object representing the asset associated with the File entity being processed.

MetadataProperties

IReadOnlyDictionary <string, JToken>

This property contains the available metadata. The metadata properties depend on the processed file.

Action scripts

For Action scripts, the context properties depend on the execution source of the script. The execution source is the method by which the script is called. The context properties differ according to the following use cases:

  • Web Api - When the script is called by a Web Api (REST). In this case, ExecutionSource is equal to WebApi.

  • External Action - When the script is called by an external action from a page component. In this case, ExecutionSource is equal to ExternalAction or MassEdit. It is set to MassEdit when the Action script is called from the mass-edit menu.

  • Triggers - The context properties for triggers depend on their execution type: In Process or In Background (Out of process).

    • In Background - When the script is called by a trigger in background. In this case, ExecutionSource is equal to Trigger and ExecutionType is equal to OutOfProcess.

    • In Process - When the script is called by a trigger in process. In this case, ExecutionSource is equal to Trigger and ExecutionType is equal to InProcess.

For each use case, click the tab to see a table that contains the relevant context properties.

Do you have some feedback for us?

If you have suggestions for improving this article,