Note that there are some explanatory texts on larger screens.

plurals
  1. POObject error with trying to return documents (Umbraco Document API)
    primarykey
    data
    text
    <p>I'm working on a recursive method that displays all documents I have permissions to see. The first pass works great, but when it calls itself recursively passing a document array of the current document's children it throws an error:</p> <blockquote> <p>Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p> <p>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.</p> </blockquote> <p>Here's the code:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { lblTest.Text = "Data&lt;br /&gt;&lt;br /&gt;"; Document[] releaseDocs = Document.GetRootDocuments(); displayDocs(releaseDocs); } public void displayDocs(Document[] releaseDocs) { string docPermissions = null; User currentUser = User.GetCurrent(); foreach (var doc in releaseDocs) { docPermissions = currentUser.GetPermissions(doc.Path); if ((docPermissions.Contains("F")) &amp;&amp; (docPermissions.Contains("U"))) { lblTest.Text += "D/T: " + doc.CreateDateTime + "&lt;br /&gt;\r\n"; lblTest.Text += "Level: " + doc.Level + "&lt;br /&gt;\r\n"; lblTest.Text += "Text: " + doc.Text + "&lt;br /&gt;\r\n"; lblTest.Text += "&lt;hr /&gt;\r\n"; if (doc.HasChildren) { Document[] childDocs = Document.GetChildrenForTree(doc.Id); displayDocs(childDocs); //error occurs here } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload