Automation Process - Using Macros to Exclude Actions Being Taken on Particular Contacts

Stephen Dickerson asked on March 20, 2014 13:13


I'm trying to create a macro condition to exclude certain contacts. I figure there are a couple of ways to do this.

I have two sites running on one instance; therefore I have site specific contacts and global contacts. Of course, some of these contacts are also users. I want to exclude global contacts from having an action applied to them if they belong to a particular organization that is not a "partner organization." This can be defined in the organization a contact belongs to (organization is a partner = true), so this may be the easiest way to accomplish this.

The other way I can think to accomplish this would be: the contact could have a user account that belongs to a particular role (Partner role).

I'm new to writing macros, so I'm having a hard time figuring out how to identify a contact's organization and determine whether it's a partner using macros in the automation process. Thank you for your help!

Recent Answers

Josef Dvorak answered on March 27, 2014 09:45 (last edited on March 24, 2018 12:15)


I was not sure what you mean by organization, we do not have such object in Kentico. If it is some custom object, you will need to create a Custom Macro Method to read it.

If you represent the organization using the Account object, you can read and filter them using its status in Macro. Here are some examples:

This macro will return true, if at least one of Contact Accounts is in status with codename "Partner":

{% OnlineMarketingContext.CurrentContact.Accounts.Filter("AccountStatus == \"Partner\"").Count > 0 |(user)zbynekh|(hash)cde4bb15b460955594dbcc19622f420e0530b666185034134f1f7b27edff02fd%}

This macro will return true, if at least one of Contact Accounts has custom Boolean field "AccountIsPartner" set to true:

{% OnlineMarketingContext.CurrentContact.Accounts.Filter("AccountIsPartner").Count > 0 |(user)zbynekh|(hash)6666614d6ad091c462db165b7c58fa9d9e1425d07e7075fcce6ea0475fa86fbb%}

And you can test that Contact is not global like this:

{% OnlineMarketingContext.CurrentContact.SiteID != null |(user)zbynekh|(hash)b78ea40673799d08003368b8ceb55cd40fd6b2cdd4ef4dca5f719bc0daa5bdfd%}

When put together, this macro will pass only if the Contact is not global, or at least one of its contacts has a custom field "AccountIsPartner" set to true:

{% OnlineMarketingContext.CurrentContact.SiteID != null || OnlineMarketingContext.CurrentContact.Accounts.Filter("AccountIsPartner").Count > 0|(user)zbynekh|(hash)6390976cdfcbf727f52fa7c8d7b12e3994a1e555803edc368820f0ef9ab1b22a%}

As you can see, these Macros work with OnlineMarketingContext.CurrentContact, so that you can test them on a Document first. When you pick one to be used in Marketing Automation Process, substitute OnlineMarketingContext.CurrentContact for just Contact.

Let me know if I can help you any further.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.