How can I set a NULL value with window.handleItemChange?

Hi,

I am pretty sure this one is easy to solve, but I weren´t able to find a solution yet.

I have a Form with a regular standard button. When I click the button, Field values from a previous Item generation shall be mirrored into the current Form. Mirrowing regular values works fine, but I struggle to write NULL values into my form fields.

Here´s the sample of the code I use at the moment:

var previousValue = previousItem.getProperty("document_id");
if (typeof(previousValue ) !== "undefined" && previousValue !== null)
{
    window.handleItemChange("document_id", previousValue); // updates field to new value -> works
}
else
{
   window.handleItemChange("document_id", null); // <- update field to NULL -> doesn´t work
}

I tried this variant, but the database value will be an empty string and not a real NULL:

var previousValue = previousItem.getProperty("document_id",""); // <- database value will not be NULL!
window.handleItemChange("name", previousValue);

 

Thanks for any input!

Parents
  • I didn´t assue that this little issue would become so interesting.
    There is nothing wrong with window.handleItemChange.

    What I have seen yesterday seems to be some kind of regular text field behaviour, at least in my Innovator 11SP11.
    Once a text field contains a value, it can never be reset to zero. It can only be reset to an empty string.

    Steps to reproduce:
    1. Open an Item that contains a Form with regular fields
    2. Add a value into one of the string fields (e.g. name) and save the item
    3. Now delete the value from the text field and save again -> empty string instead of NULL will be set!

    This is no problem for my current use case, just was suprised about this behaviour.

  • Ah! I was testing with an item field yesterday. I can confirm that in my 11.0 SP15 environment, using handleItemChange on a text field did not set the value back to null in the database. I checked our records, and it seems like this is filed to be changed but is not yet scheduled for a specific release.

Reply Children