Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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
get the member
var mem = ApplicationContext.Current.Services.MemberService.GetByUsername(email);
get the property type id of the checklist
var id = mem.Properties.First(x => x.Alias == "selectedCategories").PropertyType.Id
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
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.
Thank Alex that worked for me
now I'm having trouble to update the checkbox list
I don't get any exception but when I open the backoffice non of the checkbox list is checked
Did you solve the issue with saving the checkbox list value? Can you share?
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
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted