Copied to clipboard

Flag this post as spam?

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


  • Ronen Rimon 22 posts 124 karma points
    Oct 03, 2017 @ 13:26
    Ronen Rimon
    0

    getting prevalues of checklist

    Hello, I have checklist that I'm using as additional property in member type I'm trying to get the checklist prevalues and I always get empty list. my steps are

    1. get the member var mem = ApplicationContext.Current.Services.MemberService.GetByUsername(email);

    2. get the property type id of the checklist var id = mem.Properties.First(x => x.Alias == "selectedCategories").PropertyType.Id

    3. get the prevalues var prevalues = ApplicationContext.Current.Services.DataTypeService.GetPreValuesByDataTypeId(id)

    when I'm following this steps on content type and not member type it is working fine

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Oct 03, 2017 @ 22:55
    Alex Skrypnyk
    100

    Hi Ronen

    What if you try to get prevalues with this code:

    var dataType = ApplicationContext.Services.DataTypeService.GetDataTypeDefinitionByName("example");
    var preValues = ApplicationContext.Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dataType.Id);
    

    Try to use "GetDataTypeDefinitionByName("My Datatype Name")" method for getting dataType definition, then use this id for getting prevalues.

    Thanks

    Alex

  • Ronen Rimon 22 posts 124 karma points
    Oct 04, 2017 @ 05:12
    Ronen Rimon
    0

    Thank Alex that worked for me

    now I'm having trouble to update the checkbox list I'm using

    mem.SetValue("selectedCategories", string.Join(",",IdOfCheckBoxListItems)); ApplicationContext.Current.Services.MemberService.Save(mem);

    I don't get any exception but when I open the backoffice non of the checkbox list is checked

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Oct 18, 2017 @ 21:15
    Alex Skrypnyk
    0

    Did you solve the issue with saving the checkbox list value? Can you share?

  • Ronen Rimon 22 posts 124 karma points
    Oct 20, 2017 @ 05:35
    Ronen Rimon
    1

    Hi Alex It worked for me like that:

    var selectedCategories = ApplicationContext.Current.Services.DataTypeService.GetAllDataTypeDefinitions().First(x => x.Name == "Member - Selected Categories");

    var preValueId1 = ApplicationContext.Current.Services.DataTypeService.GetPreValuesCollectionByDataTypeId(selectedCategories.Id).PreValuesAsDictionary.Where(x => memberViewModel.SelectedCategories.Contains(x.Value.Value)).Select(y => y.Value.Id);

    member.SetValue("selectedCategories", string.Join(",", preValueId1));

    where "Member - Selected Categories" is the name of the checkbox list

Please Sign in or register to post replies

Write your reply to:

Draft