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
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
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.
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
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
Hi Ronen
What if you try to get prevalues with this code:
Try to use "GetDataTypeDefinitionByName("My Datatype Name")" method for getting dataType definition, then use this id for getting prevalues.
Thanks
Alex
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
Did you solve the issue with saving the checkbox list value? Can you share?
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
is working on a reply...