Skip to content

Changing custom properties values

Dynamic Content can be used to automatically change custom subscriber values when the email is sent, using SetSubscriberProperty method.

Method signature:

SetSubscriberProperty(name, value)

Method always returns empty string and can be put anywhere in the email. For example:

${SetSubscriberProperty('some_number', 123)}

It is also possible to set subscriber properties conditionally, using standard logical syntax:

<if condition='HasSubscriberProperty('is_client')'>
    ${SetSubscriberProperty('is_client_and_got_email', true)}
</if>

value parameter will accept any object, but it is important to set appropriate value, depending on custom property type. See examples below for different types of custom properties.

Boolean properties:

${SetSubscriberProperty('some_boolean', true)}
${SetSubscriberProperty('some_boolean', false)}

Text properties:

${SetSubscriberProperty('some_text', 'foobar')}

Number properties:

${SetSubscriberProperty('some_number', 123)}

Money properties:

${SetSubscriberProperty('some_money', 12.99)}

NOTE: Dot character (.) must be used as a decimal symbol.

Date and DateTime properties:

${SetSubscriberProperty('some_date', '2013-12-02')}
${SetSubscriberProperty('some_datetime', '2013-12-02 10:15:00')}
${SetSubscriberProperty('some_date', new System.DateTime(2013, 12, 2).Date)}
${SetSubscriberProperty('some_datetime', new System.DateTime(2013, 12, 2, 10, 15, 0))}

NOTE: For convenience, it is possible to provide date/datetime as a string, but it is required to use sortable (ISO) format: YYYY-MM-DD hh:mm:ss.

All dates are treated as dates in business unit’s timezone.

SingleSelect properties:

${SetSubscriberProperty('some_singleselect', 'value1')}
${SetSubscriberProperty('some_singleselect', 'value2')}

NOTE: Value set to custom single select property must be one of predefined values.

Of course, it is possible to use expressions and other Dynamic Content methods as arguments, provided proper value type (e.g. using casting) is inserted:

${SetSubscriberProperty('some_number', (int)GetSubscriberProperty('some_other_number') + 123)}

If for some reason, it is impossible to set subscriber property value (e.g. value is invalid or property name is unrecognized), the method will not do anything. Email will be sent as usual, without errors.

On this page
To top