Create extra textstring in repeatable texstring programmatically
Hi there.
I am trying to create an extra texstring in the new datatype repeatable texstring. Is that at all possible??
I have a property with the alias "test", wich a repeatable textstring. In this example i want to save emails programmatically to the array of textstrings.
I am going for 1 textstring per email. So that you can access the emails from umbraco admin.
I have the following code at the moment
var contentService = ApplicationContext.Services.ContentService;
IPublishedContent root = Umbraco.TypedContentAtRoot().First();
var newsletter = root.Descendant("boletinInformativo");
//Test is the alias for repeatable textstring
var mailsInNewsletter = newsletter.GetPropertyValue<string[]>("test");
var getNewsletter = contentService.GetById(newsletter.Id);
// This is where i am quite lost i have email as a parameter in the actionresult that i want to assign
getNewsletter.SetValue("test", mailsInNewsletter + ??? );
contentService.SaveAndPublishWithStatus(getNewsletter);
return Json("yes", JsonRequestBehavior.AllowGet);
I hope you have an idea of what i am trying to achieve.
Found the solution -- for repeatable strings (and I would imagine any type of list), you need to segment the different line items by (ironically enough) a new line. Code is as follows:
if (content.HasProperty(propertyName))
content.SetValue(propertyName, "item1" + Environment.NewLine + "item2");
Create extra textstring in repeatable texstring programmatically
Hi there.
I am trying to create an extra texstring in the new datatype repeatable texstring. Is that at all possible??
I have a property with the alias "test", wich a repeatable textstring. In this example i want to save emails programmatically to the array of textstrings.
I am going for 1 textstring per email. So that you can access the emails from umbraco admin.
I have the following code at the moment
I hope you have an idea of what i am trying to achieve.
Thank you!
Mathias, were you ever able to solve this issue? We are running into the exact same issues and cannot find a solution either.
Found the solution -- for repeatable strings (and I would imagine any type of list), you need to segment the different line items by (ironically enough) a new line. Code is as follows:
is working on a reply...