November Happy Hour will be moved to Thursday December 5th.

Value gets reset on every odd update

Vote:
 

We have a scheduled task that reads data from a database and creates/updates pages in EPiServer. The weird part of this that if a property on a page has had a value, for instance a phonenumber and this value is deleted from the database. 

The first time after this when the task executes the value of the page gets emptied as expected. But the second time the task executes the value gets reset to the previous value even though the value from the database still is empty/null.

And then it continues with this set/reset of the value on each execution of the task...

On update I create a writableClone of the page and sets all the properties like this:

personPage.PageName = person.Fullname;
personPage.Title = person.Worktitle;
personPage.Email = person.Email;
personPage.FullName = person.Fullname;
personPage.Mobile = person.MobilePhone;
personPage.Phone = person.WorkPhone;

When debugging I can see that the WorkPhone of the EF object person is null and the personPage just before the saveAction.Publish has null on the Phone but when I reload the updated page the Phone contains the previous value.

Have tried setting all values to null before seting the value, like so:

personPage.Phone = null;
personPage.Phone = person.WorkPhone;

But that doesnt work either and why would it since Workphone is null. The only thing thats keepeing the previous value to reappear between executions is to set the value to a string with a space, like this:

personPage.Phone = null;
personPage.Phone = person.WorkPhone ?? " ";

Why this strange behaviour?

#86682
May 28, 2014 11:41
Vote:
 

How do you save it?

#86684
May 28, 2014 12:41
Vote:
 
var serviceLocationHelper = ServiceLocator.Current.GetInstance<ServiceLocationHelper>();
 
var contentRepository = serviceLocationHelper.ContentRepository();
contentRepository.Save(personPage, SaveAction.Publish, AccessLevel.NoAccess);


#86686
May 28, 2014 13:49
Vote:
 

Ok. then it should not be a cache-problem since that repository updates the cache also.

Are the sites load balanced?

#86689
May 28, 2014 13:55
Vote:
 

Nope, regular single server setup. Able to recreate the error on my developing machine as well.

#86691
May 28, 2014 14:13
Vote:
 

Ok. Then it is very strange. I guess that phone is a string and that should be able to be null.

If you can recreate it in development, activate debug-logging and see if you can see anything in the logs.

#86694
May 28, 2014 14:30
Vote:
 

How property is defined on the page type? Can you paste code? Is it just ordinary property or some override?

#86891
Jun 04, 2014 8:01
Vote:
 

The properties are regular virtual properties

[Editable(true)]
        [Display(
            Name = "FullName",
            Description = "",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual String FullName { get; set; }

        [Editable(true)]
        [Display(
            Name = "Email",
            Description = "",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual String Email { get; set; }

        [Editable(true)]
        [Display(
            Name = "Phone",
            Description = "",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual String Phone { get; set; }

        [Editable(true)]
        [Display(
            Name = "Mobile",
            Description = "",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual String Mobile { get; set; }

        [Editable(true)]
        [Display(
            Name = "Title",
            Description = "",
            GroupName = SystemTabNames.Content,
            Order = 1)]
        public virtual String Title { get; set; }
#86892
Jun 04, 2014 8:15
Vote:
 

Had to change the way I updated the value since empty strings caused this behaviour as well

personPage.Phone = null;
            personPage.Phone = string.IsNullOrEmpty(person.WorkPhone) ? " " : person.WorkPhone;
#86893
Jun 04, 2014 8:18
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.