logo
logo

Script properties

In Sitecore Content Hub™, all types of scripts have access to 2 main objects: MClient and Context. Both MClient and Context objects provide users with a collection of useful properties.

MClient properties

MClient properties are available for all types of scripts. They allow users to manipulate data in Content Hub (e.g. 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:

PropertyType
CommandsStylelabs.M.Sdk.Clients.ICommandsClient
CulturesStylelabs.M.Sdk.Clients.ICultureClient
DataSourceFactoryStylelabs.M.Sdk.Factories.IDataSourceFactory
DataSourcesStylelabs.M.Sdk.Clients.IDataSourcesClient
EntitiesStylelabs.M.Sdk.Clients.IEntitiesClient
EntityDefinitionsStylelabs.M.Sdk.Clients.IEntityDefinitionsClient
EntityFactoryStylelabs.M.Sdk.Factories.IEntityFactory
JobsStylelabs.M.Sdk.Clients.IJobsclient
LoggerStylelabs.M.Sdk.Contracts.Logging.ILogger
NotificationsStylelabs.M.Sdk.Clients.INotificationsClient
PackageStylelabs.M.Sdk.Clients.IPackageClient
PoliciesStylelabs.M.Sdk.Clients.IPoliciesClient
QueryingStylelabs.M.Sdk.Clients.IQueryingClient
ScriptsStylelabs.M.Sdk.Clients.IScriptsClient
SettingsStylelabs.M.Sdk.Clients.ISettingsClient
UsersStylelabs.M.Sdk.Clients.IUsersClient

For more information about clients or factories, please refer to the SDK API reference.

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.

For a descriptive list of script types, please refer to the script types section.

User sign-in scripts

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

PropertyTypeDescription
AuthenticationSourceM.Base.Scripting.Users.AuthenticationSourceThis property contains the source of registration of the user, which can be internal (Content Hub) or external (an external provider).
Possible values:
  • Internal
  • External
EntityM.Sdk.Contracts.Base.IEntityThis property contains the entity object representing the signed-in user.
ExternalInfoExternalUserInfoThis 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.

For more information about the context properties, please refer to the API reference guide.

User pre-registration scripts

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

PropertyTypeDescription
AuthenticationSourceM.Base.Scripting.Users.AuthenticationSourceThis property contains the source of registration of the user, which can be internal (Content Hub) or external (an external provider).
Possible values:
  • Internal
  • External
UsernamestringThis property contains the username of the created user.
EmailstringThis property contains the email of the created user.
CultureSystem.Globalization.CultureInfoThis property contains the culture information of the created user.

For more information about the context properties, please refer to the API reference guide.

User post-registration scripts

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

PropertyTypeDescription
AuthenticationSourceM.Base.Scripting.Users.AuthenticationSourceThis property contains the source of registration of the user, which can be internal (Content Hub) or external (an external provider).
Possible values:
  • Internal
  • External
EntityM.Sdk.Contracts.Base.IEntityThis property contains the entity object representing the signed-in user.
ExternalInfoExternalUserInfoThis 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.

For more information about the context properties, please refer to the API reference guide.

Metadata processing script

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

PropertyTypeDescription
FileM.Sdk.Contracts.Processing.IFileThis property contains the File entity that is being processed.
IFile properties:
  • Filename: string
  • Extension: string
EntityStylelabs.M.Sdk.Contracts.Base.IEntityThis property contains the entity object representing the asset associated with the File entity being processed.
MetadataPropertiesIReadOnlyDictionary<string, JToken>This property contains the available metadata. The metadata properties depend on the processed file.

For more information about the context properties, please refer to the API reference guide.

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).

    Note

    In this case, ExecutionSource is equal to WebApi.

  • External Action: When the script is called by an external action from a page component.

    Note

    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.

      Note

      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.

      Note

      In this case, ExecutionSource is equal to Trigger and ExecutionType is equal to InProcess.

The following table contains the context properties for each use case.

For more information about the context properties, please refer to the API reference guide.

Can we improve this article ? Provide feedback