Setting a Value to Null

Posts   
 
   
 
Anonymous
User
Posts: 0
Joined: 11-Nov-2006
# Posted on: 20-Nov-2007 23:15:13   

Hi Guys,

I am using the following to set a value to null


                        variation.Fields[(int)TicketVariationFieldIndex.Hours].IsChanged = true;
                        variation.Hours = null;

can someone tell me why i setting the IsChangeg flag to true is neccessary and why this doesn't happen autoamtically when i assign the null value

Cheers,

Pete

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Nov-2007 08:40:21   

You may need to set is Changed to true, if variation.Hours had the value of null before setting it to null.

Because if the value of the field doesn't change, IsChanged remains false, and no value will be set in the database when the entity gets saved.

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 21-Nov-2007 20:04:53   

Hi,

It might also have to do something with entity.SetNewFieldValue();

I thought that if you use SetNewFieldValue() to do this it will be flagged as changed.

Cheers, Gab