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
Hello,
Could someone tell me how I should save a value to a Multi Node Tree Picker. I've tried saving a page Id however this is not reflected in the backoffice. Does it need to be saved in a particular format.
Examples welcome.
Many thanks
Paul
Hi Paul,
I haven't done this but at a guess, maybe you need to pass in an IPublishedContent?
Otherwise, it'd be good to see your code so far and we can go from there.
Hi Ben,
Thanks for the reply, would that be a List
Thanks
Hey Paul I ran into a similar problem.
See this thread and the helper method by Dan:
https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/85761-setting-the-value-of-multinodetreepicker2-programatically#comment-273131
Hi Matt,
Thanks for the link, I've tried to no avail to use that code.
I have managed to get it working, see code below:-
if (memberExists) { IMember currentUser = ms.GetByUsername(userName); if (currentUser != null) { var findPage = cs.GetById(pageId); var loadUdi = Udi.Create(Constants.UdiEntityType.Document, findPage.Key); List<string> splitPages = new List<string>(); if (currentUser.GetValue("favouritePages") != null) { splitPages = currentUser.GetValue("favouritePages").ToString().Split(',').ToList(); bool checkIfExists = splitPages.Any(page => page == loadUdi.ToString()); if (!checkIfExists) { splitPages.Add(loadUdi.ToString()); currentUser.SetValue("favouritePages", string.Join(",", splitPages)); } } else { splitPages.Add(loadUdi.ToString()); currentUser.SetValue("favouritePages", string.Join(",", splitPages)); } ms.Save(currentUser); } }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to save a value to a MNTP programmatically
Hello,
Could someone tell me how I should save a value to a Multi Node Tree Picker. I've tried saving a page Id however this is not reflected in the backoffice. Does it need to be saved in a particular format.
Examples welcome.
Many thanks
Paul
Hi Paul,
I haven't done this but at a guess, maybe you need to pass in an IPublishedContent?
Otherwise, it'd be good to see your code so far and we can go from there.
Hi Ben,
Thanks for the reply, would that be a List
Thanks
Paul
Hey Paul I ran into a similar problem.
See this thread and the helper method by Dan:
https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/85761-setting-the-value-of-multinodetreepicker2-programatically#comment-273131
Hi Matt,
Thanks for the link, I've tried to no avail to use that code.
I have managed to get it working, see code below:-
is working on a reply...