Copied to clipboard

Flag this post as spam?

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


  • lucuma 261 posts 563 karma points
    Mar 06, 2013 @ 15:36
    lucuma
    0

    Creating and Publishing Document via Code but not Searchable via Razor - 4.7.11

    I've got something rather simple in that a user is voting for something on the site and a part of this vote is capturing the user's email.  Creating the Document is straightforward:

    DocumentType dt = DocumentType.GetByAlias("VideoVote");
                User author = new User(0);
                Document doc = Document.MakeNew(whichvote, dt, author, Model.Id);
                doc.getProperty("voteChoice").Value = whichvote;
                doc.getProperty("youtubeCode").Value = youtube;
                doc.getProperty("email").Value = email;
                doc.getProperty("ip").Value = ip; // defined prior
                doc.Template = 4407; // need to change on prod
    
                doc.Save();
    
                doc.Publish(author);

    The document is created HOWEVER it is not searchable like this:

    return Model.Descendants().Where("email==\"" + email + "\"").Count() > 0;

    If I go into the backend and save and publish manually it will show up in that query above.. Can somone help track down what I need to do so that after creating the node I can search for it?

  • lucuma 261 posts 563 karma points
    Mar 07, 2013 @ 16:07
    lucuma
    0

    Too many long days..  I left off:

     umbraco.library.UpdateDocumentCache(doc.Id);
  • 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