Tuesday, December 30, 2014

How to create SDL Tridion Contextual Expressions

Contextual Expressions are intended to be created from external systems like CMA. In this blog post I am showing a basic method to create Contextual Expressions (Expressions Target Groups) without the need of CMA.

Expressions Target Groups should must contain certain Application Data in the following format

TargetGroupExtensionData targetGroupExtensionData = new TargetGroupExtensionData
    ContextExpression = contextExpression,
    SyncLabel = version

The Context Expression and the SyncLabel properties are mandatory. They should be included while saving the Target Group Application Data

ApplicationDataAdapter appDataAdapter = new ApplicationDataAdapter(TargetGroupExtensionData.ApplicationId, targetGroupExtensionData);
_coreServiceClient.SaveApplicationData(existingTargetGroup.Id, new[] { appDataAdapter.ApplicationData });

The source code is available in my Git Repository.

No comments:

Post a Comment