AnsweredAssumed Answered

How make sure "cleared" lookup value from form is not saved

Question asked by wimv on Oct 22, 2015
Latest reply on Oct 23, 2015 by wimv

Hi,

 

My SharePoint list has 2 columns:

End user name (lookup field)

End user name manual (text field)

 

It is required that one of them has a value (not both of them).

So either End user name should have a value, either End user name manual.

 

This is an extract from my form:

 

22-10-2015 17-35-46.png

 

Note: the CONT_IDS_CLEAN CORRECT_ANSWERS DISC_IDS_CLEAN content_ids curl_test.sh disc_ids_qready discussions queries questions_set.log test test_CID test_body are just labels (not coming from requirements on the list).

 

Default the End user name dropdown is enabled, the text field (bottom) disabled.

When I don't find the name in the list, I check the checkbox to enable the bottom textfield and disable + clear the top dropdown.

 

Before:

22-10-2015 17-40-54.png

After:

22-10-2015 17-41-10.png

This is done with the following javascript code:

 

var EnduserNameNotAvailable = NWF$('#' + varEnduserNameNotAvailable);      

 

EnduserNameNotAvailable.change(function()

 

{if (EnduserNameNotAvailable.prop('checked') == true)

{ NWF$('#' + varEnduserName).val("");

}

else

{ NWF$('#' + varEnduserNameManual).val("");

}

}

);

 

As you can see the change on the checkbox triggers the code to set the lookup value to "".

 

However, it seems that the lookup is only cleared "superficially". When I save the form the previously selected value "BP" is still saved in the list, even though the form didn't show it anymore.

 

In summary: when I select the default value of the dropdown manually ("Please select a value...") then no value is save on the column. When I use javascript code to select the default value then -unexpectedly- a previously selected value is saved.

 

How should I prevent that value from being saved? Or how can I do a "real" clear?

 

Thanks in advance for suggesting a solution.

 

Wim

Outcomes