Developer forum

Forum » CMS - Standard features » Error when using ItemRelation field on Page ItemType

Error when using ItemRelation field on Page ItemType

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Guys,

I have this solution running 8.9.2.15 (latest version).

I have set a field of type ItemRelation on the PageItemtype for storing some relations with other pages.

Thisng look very good for pages where I add this property. For some reason, for older pages that were not saved after adding this property, I get a nasty error when trying to load or check GetLoop("Item.Page.Related_Pages.Value"). No matter if the tag is commented or inside a verification. I cannot check if the tag returns a null or empty value because no matter what I try, I get the yellow error.

I have attached the error and you can find it online as well: https://development-dynamicweb.biolegend.com/en-us/products/all-groups-immunology-5321-human-immunology-1597

If I save the page, the error is gone.

Looks like a bug to me.

Thank you,

Adrian

error_BL.png

Replies

 
Nicolai Pedersen
Reply

Hi Adrian

That is bug TFS#38527 fixed in 9.3.2.0. There are no fix available for 8 solutions.

BR Nicolai

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Is there a work around? Maybe save all pages once using the API?

 
Nicolai Pedersen
Reply

How many pages do you have using this?

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

A few hundred, maybe up to 1,500 or so. Too many to manually click Save on..... Oh, and times 3 environments.....

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

We just wrote this code to update all pages using the API. Do you see any potential problems with running this code once?

@{
  var ids = new List<int>();
  const string sql = "Select PageID FROM Page";
  using (var connection = Dynamicweb.Database.CreateConnection())
  {
    using (var reader = Dynamicweb.Database.CreateDataReader(sql, connection))
    {
      while (reader.Read())
      {
        ids.Add(Convert.ToInt32(reader[0]));
      }
    }
  }
  foreach (var id in ids)
  {
    var page = Dynamicweb.Content.Page.GetPageById(id);
    page.Save(true);
  }
}
 
Nicolai Pedersen
Reply

Hm... No, not in particular.... Would not test it in production anyhow!

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Haha, no we won't. We have separate dev and test environments so I think we can safely try it out....

 

You must be logged in to post in the forum