Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • carsten 4 posts 24 karma points
    Jun 11, 2015 @ 11:24
    carsten
    0

    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.

    var content = ApplicationContext.Services.ContentService.CreateContent(pollName + ":" + DateTime.Now.ToString("dd-MM-yyyy"), post.Id , "Poll");
                    content.SetValue("name", pollName);
                    content.SetValue("radioorcheckbox", choiceOption);
                    ApplicationContext.Services.ContentService.SaveAndPublishWithStatus(content);
    

    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?

  • Jamie Pollock 174 posts 853 karma points c-trib
    Jun 11, 2015 @ 11:33
    Jamie Pollock
    0

    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

  • carsten 4 posts 24 karma points
    Jun 11, 2015 @ 12:01
    carsten
    0

    Thanks for your reply, It still crash even with your code.

  • Jamie Pollock 174 posts 853 karma points c-trib
    Jun 11, 2015 @ 12:15
    Jamie Pollock
    0

    Ack, that's a shame. I've create a quick usercontrol to replicate the code. Could you answer a few questions?

    1. What kind of data type is it radioorcheckbox?
    2. What version of Umbraco 7 are you running on?
    3. What type of .net object is choiceOption?

    Thanks,
    Jamie

  • carsten 4 posts 24 karma points
    Jun 11, 2015 @ 12:18
    carsten
    0

    Thanks for your reply, let me answer your questions:

    1. What kind of data type is it radioorcheckbox? radioorcheckbox is a true/false

    2. What version of Umbraco 7 are you running on? I'm running Umbraco 7.2.5

    3. 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.

  • Jamie Pollock 174 posts 853 karma points c-trib
    Jun 11, 2015 @ 12:33
    Jamie Pollock
    0

    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?

  • carsten 4 posts 24 karma points
    Jun 11, 2015 @ 14:28
    carsten
    0

    I will test it once my umbraco "wants" to work with me again

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies