Default WFFM field value loaded from Contact facet

Is it possible to set WFFM field value directly from Contact facet stored in xDB, like first name, last name, address, phone?

I have data stored in Mongo and it's loaded to Tracker.Current when displaying the form. I tried to use Rules for selected field with following conditions, but without success.

use the default value from user profile Personal/FirstName field

Use the default value from Personal/FirstName visitor tag

  • Got the same question in 8.1.. (with mvc forms, but that should not be relevant) :

  • In reply to Gert Gullentops:

    You have to create new custom rule for this:

    1) In Master db under /sitecore/system/Settings/Rules/Definitions/Elements/Web Forms for Marketers Actions insert new Action item, eg: "Read Value From Contact Facet"
    In "Text" field: Use the default value from [Name,,,specific] contact facet
    In "Type" field use class from your assembly: Your.Assembly.Rules.ReadValueFromContact,Your.Assembly

    2) Implement the ReadValueFromContact class. The simplest version may look like this:

    public class ReadValueFromContact<T> : ReadValue<T> where T : ConditionalRuleContext
        {
            protected override object GetValue()
            {
                return GetContactData(this.Name);
            }
    
            private object GetContactData(string facetXpath)
            {
                if (!AuthenticationManager.GetActiveUser().IsAuthenticated)
                {
                    Log.Warn("[ReadValueFromContact]User is not authenticated.", (object)this);
                    return null;
                }
                if (Tracker.Current == null || Tracker.Current.Contact == null)
                {
                    Log.Warn("[ReadValueFromContact]Tracker is empty .", (object)this);
                    return null;
                }
    
                var contact = Tracker.Current.Contact;
                string index = facetXpath.Split('/')[0];
    
                IFacet facet = contact.Facets[index];
                var name = facetXpath.Remove(0, index.Length + 1);
                var prop = facet.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
                return prop == null ? null : prop.GetValue(facet);
            }
        }

    Mind that this will work for simple facets like "Personal/FirstName", or "Personal/Gender" etc, it will not work for more complex ones like eg "Addresses/Entries/StreetLine1", but's it's just a matter of implementing more complex GetContactData method. You already have all required data.
    I used reflection to get contact facets by property names, but maybe there easier way to get them.

    3) Finally you can now use new Rule in WFFM Form Designer, select the field, then "Rules", "New Condition" and for example something like:

    where the current user is a member of the extranet\Registered User role

    Use the default value from Personal/FirstName contact facet
  • In reply to Tomasz Juranek:

    So it's not out-of-the-box..  which is a shame because a customer expects this from an integrated "experience" platform.. Where is the feature wish list?

    Thanks for the code head start.

  • Might be a few months late to your question, but I've got some source code on GitHub (github.com/.../WFFM.PopulateFieldAction) that provides a full module with rules and pickers to populate fields from the xProfile. A series of posts explaining can be see at www.paragon-inc.com/.../using_xprofile_data_to_populate_a_wffm_part_1.