Copied to clipboard

Flag this post as spam?

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


  • Søren Reinke 158 posts 206 karma points c-trib
    Jan 18, 2010 @ 15:40
    Søren Reinke
    0

    Get Node by ID fails

    Hi there

    I have a strange problem, i have created a Document Type called 'Frontpage Banners'.

    I made a node of this type and published it, i can see the node in the umbraco.config xml file under data\ and in the cmsContentXml table.

    But when i try to retrieve it from c# using:

    XPathNodeIterator it = umbraco.library.GetXmlNodeById("4236");

    4236 is the NodeId seen in umbraco backend and database.

    I am being told there is no published node with that ID, even though Umbraco backend tells me it is published.

     

    Retreiving by xpath is no success either :-(

    I have tried to delete umbraco.config, restart IIS, delete the node, make a new one (of course used the new ID)

    Absolut no success :-(

    Does anyone have any clue what the problem is ?

    The funny thing is if i try to get any other node the same way it works.

  • Søren Reinke 158 posts 206 karma points c-trib
    Jan 19, 2010 @ 14:29
    Søren Reinke
    0

    In the umbraco.config file i have the following xml (just a snippet)

     

      <node id="4236" version="b0529b7c-298c-426d-b2cc-17b34dab7b7b" parentID="-1" level="1" writerID="5" creatorID="5" nodeType="4234" template="0" sortOrder="6" createDate="2010-01-18T14:21:19" updateDate="2010-01-19T14:20:44" nodeName="Banners Frontpage" urlName="banners-frontpage" writerName="Søren Reinke" creatorName="Søren Reinke" nodeTypeAlias="BannersFrontpageFolder" path="-1,4236">
        <node id="4243" version="63a9f5b3-dc4e-4cb6-ada4-9bb16aae97b0" parentID="4236" level="2" writerID="5" creatorID="1" nodeType="4237" template="0" sortOrder="0" createDate="2010-01-18T15:38:53" updateDate="2010-01-19T14:20:45" nodeName="NameRemoved" urlName="NameRemoved" writerName="Søren Reinke" creatorName="Webadmin" nodeTypeAlias="BannersFrontpage" path="-1,4236,4243">
          <data alias="Date">1986-05-29T00:00:00</data>
          <data alias="Image" />
          <data alias="PredefinedType">57</data>
          <data alias="Text"><![CDATA[REMOVED]></data>
        </node>

     

    If i in c# do this:
     var nodes = umbraco.library.GetXmlNodeById("4236");

    The InnerXml of the Current property is:

    <error>No published item exist with id 4236</error>

     

    How can that be, when the nodes are published ?

     

    Is there a bug in Umbraco ?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 19, 2010 @ 14:36
    Dirk De Grave
    0

    Hi,

    what happens if you use:

    umbraco.presentation.nodeFactory.Node node = new umbraco.presentation.nodeFactory.Node(4236);

    and for example query for the date property?

    var date = node.getProperty("Date");

     

    Cheers,

    /Dirk

  • Søren Reinke 158 posts 206 karma points c-trib
    Jan 19, 2010 @ 15:11
    Søren Reinke
    0

    Hi Dirk

    Thanks for your answer.

    Your first code line only returns a completly empty node, everything is 0, null, "" and data like that.

    Any other nodeID works perfectly.

     

    But the funny thing is a line like:

    Document newDoc = Document.MakeNew(bannerName, typeToCreate, createdBy, 4236);

    Works perfectly, so Umbraco knows the node exists.

     

    I have a bad feeling the database might be broken somehow.

    Does there exist a tool, that can validate/repair the datastructure in the database ?

  • Dennis Milandt 190 posts 517 karma points
    Jan 19, 2010 @ 15:24
    Dennis Milandt
    0

    Is this a problem for all nodes you try to access, or just a problem with this particular one?

    You said you tried to delete and create it again, and still it didn't work.

    Does it work for other types of nodes?

    Is this a project with umbraco PRO+Support subscribtion? - in that case, you can try to let the Core team take a look at the database.

    /Dennis

  • Søren Reinke 158 posts 206 karma points c-trib
    Jan 20, 2010 @ 10:49
    Søren Reinke
    0

    Strange have been debugging around for like forever, for some weird reason it is now working again :-(

    I have no clue why, but at least i can continue.

    Thanks a lot for your input.

  • Dominic Dore 18 posts 38 karma points
    Jul 12, 2011 @ 23:11
    Dominic Dore
    0

    Hello,

    I am having the exact same issue (see: our.umbraco.org/forum/developers/api-questions/22168-Listing-Media-from-a-folder-through-net-usercontrols), except mine is when I am trying to access the Node of a media folder. Did you ever happen to figure out what the problem was? I am in desparate need of some help here, I have been debugging and researching this for hours. Thanks a lot!

    Cheers!

    - Dom

  • Ross Stewart 3 posts 23 karma points
    Jun 23, 2014 @ 17:41
    Ross Stewart
    0

    Hey guys!

    I'm having a similar issue, hope someone can shed some light on this as I'm going slightly mad!

    I created a Document Type called 'Circuit', with property ID 1077. I then created a node from it and published it. I'm connecting to a MS SQL Server database.

    In my MVC 4 Web API app, in my Home Controller, I have this:

    public ActionResult Index()

            {

    umbraco.library.GetXmlNodeById("1077");

    umbraco.NodeFactory.Node myNode = new umbraco.NodeFactory.Node(1077);

    return View(myNode);

    }

    When I run it, I get - 

    System.NullReferenceException: Object reference not set to an instance of an object.

    umbraco.library.GetXmlNodeById(String id) +77

    Any ideas? I've tried other node Ids and it's giving me the same issue.

    Thanks

    Ross

  • Merna 1 post 71 karma points
    Sep 24, 2018 @ 10:11
    Merna
    0

    I have the same issue. Any ideas.

Please Sign in or register to post replies

Write your reply to:

Draft