Error when saving page

Vote:
 

Hi,

I'm getting error when trying to save a page.

I create a new page programmatically and save it. I then populate its children through copying some other pages in my solution. Depending on of the copied children I want to update a property in my page. All of this is happening in the same function and I've not navigated to my new page yet, and I still only have a PageReference to my new page which is returned from when I saved it.What I want to do is this:

foreach (PageData page in children)
            {
                if (page.PageTypeID == kindergardenPageTypeId)
                {
                    PageData newClonedPage = GetPage(newPage).CreateWritableClone();
                    newClonedPage.Property["myProperty"].Value = page.PageLink;
                    DataFactory.Instance.Save(newClonedPage, SaveAction.Save, AccessLevel.Create);
                }
            }

It compiles fine but in runtime I get this error message ont the DataFactory.Instance.Save function:

The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_tblWorkProperty_tblPageType". The conflict occurred in database "dbPBL", table "dbo.tblPageType", column 'pkID'

A thing that I noticed is that the pagereference to my new page look like the page id  combined with a working page id, ex. {500_888}. Is there some delay interval from when you create your page until you can alter it? Anyone seen this error before?

- Kjetil Simensen

#25032
Oct 09, 2008 18:02
Vote:
 

I can see that there is a small error in my copy-paste from my code to this post.

I am saving the page for publish so the Save code should look like this:

DataFactory.Instance.Save(newClonedPage, SaveAction.Publish, AccessLevel.Create);

Not sure if it makes any different though...

#25039
Oct 10, 2008 9:00
Vote:
 

Solved!

 the propertytype was wrong.  Embarassed

#25041
Oct 10, 2008 10:39
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.