Sitecore tips and tricks and community news !

Post Top Ad

Post Top Ad

WFFM Action add contact to contacts list, extend conditions

All of us know WFFM very well and made there a lot of things. We would like today focus on particular action - "Add Contact To Contact List"

In general, this action is used to adding some contact data gathered from form and push this information as a contact to some list in List Manager. More details information is available in documentation here.

This action has very useful things - conditions:

It provides ability to create conditions based on fields you have in your form to add contact to the list. Developer see list of checkboxes what is userfriendly. 

List of checkboxes works as an 'OR' condition, so first true statement return true for whole list.

What in case when we want to have 'AND' condition and check if all selected checkboxes give true? Is it possible?

Sure, it is ! :)

I had already custom action which has been inherited from default action "Add Contact To Contact List". If you don't have this situation it's good to make it in this same way.

When we decompile this action we see:

Highlighted area on red show us part of code responsible for checking our conditions. To change it we have to take a look how it's working currently and how we can change it. Hence, during digging we see:

Selected area shows exactly, when some condition return true, the whole method return true as well. Right now, we have to think how to change it to AND condition ? I propose to create an array of results per each condition, then check if all of them return true. Since we will have that information we can decide if whole method should return true or false.

Later we have to only use our method implementation in our custom action. That's all ! It's working perfectly :)

Make conditions in that way and give content editors more possibilities :)

No comments:

Post a Comment