Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Arjan H. 226 posts 463 karma points c-trib
    Oct 10, 2014 @ 22:09
    Arjan H.
    1

    Get custom properties from new member when using MemberService.Saved event

    I want to send a notification email when a new member has been created in Umbraco 6.2.2. I'm using the MemberService.Saved event to accomplish this. To determine if the MemberService.Saved event has been fired by a new entity I'm using the following extension method:

    http://our.umbraco.org/documentation/Reference/Events-v6/determining-new-entity

    foreach (var member in e.SavedEntities)
    {
      var dirty = var dirty = (IRememberBeingDirty)member;
    
      if (dirty.WasPropertyDirty("Id"))
      {
        // send notification email
      }
    }
    

    However, I'm having trouble accessing the member's custom properties. I've tried member.GetValue("customPropertyName"), and member.Properties["customPropertyName"].Value, and I've even tried accessing the custom properties through the obsolete API:

    var m = umbraco.cms.businesslogic.member.Member.GetMemberFromLoginName(member.Username);
    m.getProperty("customPropertyName").Value;
    

    But for some reason every custom property returns a null value. Does anyone have any idea why? When using this code on saving an existing member the custom properties do return the proper values.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 13, 2014 @ 11:29
    Dave Woestenborghs
    0

    What type of property are you trying to retreive. Is it a textbox or something else ?

    Also do you see the values for the member in the backoffice.

    Dave

  • Arjan H. 226 posts 463 karma points c-trib
    Oct 13, 2014 @ 11:33
    Arjan H.
    0

    The properties I'm trying to retrieve are all Textstring or True/false. And yes, I can see the values in the backoffice. Again, the properties aren't available in the MemberService.Saved event when the event is triggered by saving a new member, the properties are available when the event is triggered by saving/updating an existing member.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 13, 2014 @ 11:46
    Dave Woestenborghs
    0

    By the way.

    Since your are using 6.2.2 you can also check if a member is new by using : var isNew = entity.IsNewEntity();

    Dave

     

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 13, 2014 @ 11:48
    Dave Woestenborghs
    0

    What result do you get when you member.GetProperty("customProperty").Value ?

    Dave

  • Arjan H. 226 posts 463 karma points c-trib
    Oct 13, 2014 @ 12:19
    Arjan H.
    0

    Null values.

  • Nikola Romcevic 26 posts 139 karma points
    Oct 27, 2014 @ 17:30
    Nikola Romcevic
    0

    Hi Arjan!

    Have you found a solution?

    Cheers, Nikola

  • Arjan H. 226 posts 463 karma points c-trib
    Oct 27, 2014 @ 17:32
    Arjan H.
    0

    @Nikola: Unfortunately not. Instead I've created a task that runs every hour to process new members. This works in our situation, but I realize this won't be an acceptable solution for all situations.

  • Nikola Romcevic 26 posts 139 karma points
    Oct 27, 2014 @ 18:01
    Nikola Romcevic
    0

    Yeah, that won't work for my situtation :) But thanks anyway.

  • Charles Afford 1163 posts 1709 karma points
    Oct 27, 2014 @ 21:09
    Charles Afford
    0

    Arjan what are your property alias values. They need to be different to the name as Umbraco seems to do a case insensitive match. I have had this problem before. Hope that helps. Charlie.

    Also on the member object you create. In the watch window you should be able to see the properties on that object? Are they also null?

    Charlie :)

  • Arjan H. 226 posts 463 karma points c-trib
    Oct 27, 2014 @ 21:11
    Arjan H.
    0

    I'm using uWebshop and I'm trying to access the properties uWebshop adds to the member type like: customerFirstName, customerLastName, etc. And yes, when I set a watch on the object during debugging the properties are also null.

  • Leon Lindeberg 12 posts 103 karma points
    Sep 06, 2017 @ 11:32
    Leon Lindeberg
    0

    Got stuck here too.. Did you find a solution?

  • Arjan H. 226 posts 463 karma points c-trib
    Sep 08, 2017 @ 21:17
    Arjan H.
    0

    Nope, I never found a solution. Like I said in one of my previous replies I worked around it by implementing a scheduled task that did some post-processing on new members.

    By the way, which version of Umbraco are you using? Are you still on 6.2.x or is this also an issue on 7.x?

  • Sahar 10 posts 79 karma points
    Dec 12, 2017 @ 06:07
    Sahar
    0

    I am also stuck here. I created a custom member type in back office and a few properties there.

    Now I can access the type in the code but all the properties are coming with null values.

            var searcher = Examine.ExamineManager.Instance.SearchProviderCollection["InternalMemberSearcher"];
            IEnumerable<SearchResult> pagedResults;
    
            var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.And);
    
            IBooleanOperation query = null;
    
            //Build the Examine query
            query = searchCriteria.Field("Type", "Agent");
    
            //Get the search result
    
            var results = searcher.Search(query.Compile());
    
             if (results.Count > 0 )
             {
                 foreach (var result in results )
                 {
                            AgentViewCMSModel item = new AgentViewCMSModel();
    
                            var node = Members.GetById(Convert.ToInt32(result.Fields["id"]));
    
                           item.Country = node.GetPropertyValue(item.COUNTRY_PROPERTY_NAME).ToString();
    
                }
          }
    

    The problem in above code snippet is, it gets the correct member type records using custom "Type" property's value but gets all the custom properties with "null" values.

    Note: I have two custom member Types 'Member' and 'Agents' with different custom properties according to business requirement. is that a problem?

    any lead will be highly appreciated.

    Thanks

  • Sahar 10 posts 79 karma points
    Dec 12, 2017 @ 07:01
    Sahar
    0

    ok, it works now. the same code works without any change (I just clean built the solution).

    still trying to figure out what happened :)

    thanks anyway..

  • Sumesh KP 35 posts 108 karma points c-trib
    Jun 13, 2018 @ 14:34
    Sumesh KP
    0

    Anybody got the solution for this?

Please Sign in or register to post replies

Write your reply to:

Draft