1

I have a member type which has a custom property - lets name it books - of data type checkbox - so multiple choice is possible.

Now I'm trying to update this member programatically with new values for books. In the customxml it comes as cdata, I'm passing a value as

umbraco.cms.businesslogic.member.Member member =  umbraco.cms.businesslogic.member.Member.GetMemberFromEmail(email);
member.SetProperty("memberBooks", booksValue);
member.Save();

where 'booksValue' is a string of values seperated with comma - because it's how it appears in the contentXml.

It doesn't work.

The question is - how do I update the member property/ xml with new multiple values?

nickornotto
  • 1,946
  • 4
  • 36
  • 68

2 Answers2

3

I have resolved this issue.

Both

member.getProperty(“memberBooks”).Value = booksValue;

and

member.SetProperty("memberBooks", booksValue);

work

I was just passing wrong values.

In the contentXml they display as values but actually I need to update the property with the ids so if the data type is checkbox list and the values are like:

1 - book

2 - booko

3 - booki

then in the contentXml it displays as a list "book,booko,booki" but to update it programatically I had to pass: "1,2,3" to the property.

So it should be:

member.SetProperty("memberBooks", "1,2,3");

instead of:

member.SetProperty("memberBooks", "book,booko,booki");

I hope it helps others with the same problem.

nickornotto
  • 1,946
  • 4
  • 36
  • 68
  • I am glad that you have found solution – Ankur Ghelani Jun 27 '13 at 10:09
  • This is helpful, but you still need to get the IDs. I created extension methods to help with this at https://gist.github.com/alindgren/bc670f2e0d938d1b788d38a70720e102 – Alex Jul 27 '16 at 21:45
0

here is what you need to do:

umbraco.cms.businesslogic.member.Member member = umbraco.cms.businesslogic.member.Member.GetMemberFromEmail(email);
member.getProperty(“memberBooks”).Value = booksValue;
member.Save();

I hope this should work. I haven't tried it since long-time but this is how I used it.

Ankur Ghelani
  • 659
  • 4
  • 16