Thanks for your reply, let me answer your questions:
What kind of data type is it radioorcheckbox?
radioorcheckbox is a true/false
What version of Umbraco 7 are you running on?
I'm running Umbraco 7.2.5
What type of .net object is choiceOption?
choiceOption is the value of the selected radiobutton(out of 2 radiobuttons), and it will always be either true or false.
Hmmm, I've set up the following code just to test out the original code.
var pollName = "New Poll";
var postNodeId = 1058; // replace with your id
var choiceOption = true;
var post = ApplicationContext.Current.Services.ContentService.GetById(postNodeId);
var content = ApplicationContext.Current.Services.ContentService.CreateContent(pollName + ":" + DateTime.Now.ToString("dd-MM-yyyy"), post.Id, "Poll");
content.SetValue("name", pollName);
content.SetValue("radioorcheckbox", choiceOption);
ApplicationContext.Current.Services.ContentService.SaveAndPublishWithStatus(content);
Only big change is the code calls ApplicationContent.Current.Services rather than ApplicationContent.Services.
On top of this I have a document type with 2 properties; name and radioorcheckbox. The code works fine for me and I haven't allowed the poll type below the post node. They simply appear under there.
The only thing I could think of at this point is whether the poll node exists. Either that or perhaps a database connection issue?
Umbraco seems to "crash" after SaveAndPublishWithStatus
Hello and thanks for reading this,
When i run the code below it seems like umbraco crash in some way.
After I run the code, and enter umbraco backend, then the menu on the left is gone except the help and user image on the top.
I cant delete anything in umbraco backend and I can't create any child for a content, (100% sure that i have allowed childs for that current content)
It takes about 30 min before the menu comes back, and everything works.
but it only happens when i run the code above. Can someone say whats wrong?
Hey carsten,
Have you tried using
ApplicationContext.Services.ContentService.CreateContentWithIdentity
instead?This will create and save the entity first ensuring it had a node within the system first.
Thanks,
Jamie
Thanks for your reply, It still crash even with your code.
Ack, that's a shame. I've create a quick usercontrol to replicate the code. Could you answer a few questions?
Thanks,
Jamie
Thanks for your reply, let me answer your questions:
What kind of data type is it radioorcheckbox? radioorcheckbox is a true/false
What version of Umbraco 7 are you running on? I'm running Umbraco 7.2.5
What type of .net object is choiceOption? choiceOption is the value of the selected radiobutton(out of 2 radiobuttons), and it will always be either true or false.
Hmmm, I've set up the following code just to test out the original code.
Only big change is the code calls
ApplicationContent.Current.Services
rather thanApplicationContent.Services
.On top of this I have a document type with 2 properties;
name
andradioorcheckbox
. The code works fine for me and I haven't allowed the poll type below the post node. They simply appear under there.The only thing I could think of at this point is whether the poll node exists. Either that or perhaps a database connection issue?
I will test it once my umbraco "wants" to work with me again
is working on a reply...