Copied to clipboard

Flag this post as spam?

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


  • Andreas Emtinger 23 posts 185 karma points
    Dec 21, 2016 @ 12:14
    Andreas Emtinger
    0

    Add custom field to custom Member Type

    Hi!

    So I created a new Member Type "Member Contact" with custom properties.

    We created a SearchIndex for our new Member Type and added some members to it. Everything works fine.

    But now, our customer want too change order when displaying "Member Contact" on our site.

    • So I added a new numeric field to our member type.
    • It worked
    • But when I try to update a member with information in this field I get an error ( se below)
    • Why? I tried add another text field, didnt work.

    Member have an internal SortOrder, but I cant find how to reorder in backoffice.

    Stacktrace:

    at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Umbraco.Core.Persistence.Repositories.MemberRepository.PersistUpdatedItem(IMember entity) at Umbraco.Core.Cache.DefaultRepositoryCachePolicy2.CreateOrUpdate(TEntity entity, Action1 persistMethod) at Umbraco.Core.Persistence.Repositories.RepositoryBase2.PersistUpdatedItem(IEntity entity) at Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit(Action1 transactionCompleting) at Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit() at Umbraco.Core.Services.MemberService.Save(IMember entity, Boolean raiseEvents) at Umbraco.Web.Editors.MemberController.PostSave(MemberSave contentItem) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.

  • Andreas Emtinger 23 posts 185 karma points
    Dec 21, 2016 @ 22:22
    Andreas Emtinger
    101

    I found a fix with SQL

    I added a row to cmsPropertyData in SQL for each member with my new [propertytypeid].

    INSERT INTO [dbo].[cmsPropertyData]
               ([contentNodeId]
               ,[versionId]
               ,[propertytypeid]
               ,[dataInt]
               ,[dataDecimal]
               ,[dataDate]
               ,[dataNvarchar]
               ,[dataNtext])
    SELECT TOP 1000 [contentNodeId],[versionId], 193, 1, null, null, null, null
        FROM [dbo].[cmsMember]
            INNER JOIN [dbo].[cmsPropertyData]
            ON [dbo].[cmsMember].[nodeId]=[dbo].[cmsPropertyData].[contentNodeId]
        GROUP BY [contentNodeId], [versionId]
    
    • 193: My new propertytypeid.
    • 1: A default value for my numeric field

    So clearly a bug!

Please Sign in or register to post replies

Write your reply to:

Draft