Custom values

Current version: 9.3

Custom values allow activity types to share data among themselves. The custom data is specific to the current enrollment and is only stored in the automation database. It is not intended as permanent storage. Store important information in another location or service (such as using the xConnect client).

Custom values are string key value pairs. Activities can both read and write custom values. Any other activity in the plan can then read and update these values.

A common use for custom values is to avoid repeating computations from one activity to another. For example, you may have an activity which searches the current interaction for a specific outcome. If the outcome is present, the activity can store relevant data about the outcome in custom values so other activities don’t need to search for the outcome, and can instead simply access the custom value directly.

Setting custom values

Use the context.SetCustomValue(string,string) method inside the Invoke method.

RequestResponse
public ActivityResult Invoke(IContactProcessingContext context)
{
        var outcome = context.Interaction.Events.FirstOrDefault(x => x.DefinitionId == MyOutcomeDefinitionId) as Outcome;

        if(outcome != null)
        {
                context.SetCustomValue("cost", outcome.MonetaryValue.ToString());
                return new SuccessMove("triggered");
        }

        return new SuccessMove("not-triggered");
}

Getting custom values

Use the context.GetCustomValue(string,string) method inside the Invoke method.

RequestResponse
public double ValueLimit { get; set; }

public ActivityResult Invoke(IContactProcessingContext context)
{
        var monetaryValue = decimal.Parse(context.GetCustomValue("cost"));

        if(monetaryValue >= ValueLimit)
        {
                return new SuccessMove("over");
        }

        return new SuccessMove("under");
}

Custom value lifetime

Sitecore stores custom values with the enrollment in the Automation database. When you remove the enrollment, the activity returns SuccessExitPlan, and the system destroys the custom values data.

Do you have some feedback for us?

If you have suggestions for improving this article,