Is it possible to clear value of lookup column?

  • 16 September 2017
  • 9 replies
  • 16 views

Badge +3

I would like to reset or clear a lookup column that could have one or more values selected with causing a form save.

thank you


9 replies

Userlevel 5
Badge +14

lookup column that could have one or more values selected

can you clarify that a bit more?

is it 'checkbox multi selection', 'list multi selection' or 'multi select'?

with causing a form save

as well for this - do you mean you hit a button, it clears lookup control and save form?

Badge +3

Thank you Marian!

So I have a site lookup column that I want to have cleared or set back to "Please select a value..." if a checkbox is checked on (or a button clicked). This is the code I am using:

NWF$(document).ready(function(){

   NWF$('#'+cidContractor).change(function() {

      if(NWF$('#'+ cidContractor).prop("checked")) {
         NWF$('#'+ cidTraining).val("");
      }
   })
});

cidContractor is the checkbox and cidTraining is the lookup. It looks like the lookup value is just a string but it doesn't remove the value if I set the value to an empty string or "Please select a value...". So maybe it should be [0] position?

I think the second part of the question was a syntax error and that has been fixed.

Userlevel 5
Badge +14

what form version are you on? solution is different for different versions.

as well, above you mentioned you have lookup multiselect capable. but from the screenshot it doesn't seem to be so.

can you for sure post its configuration.

Badge +3

Thank you. Nintex Forms Version: 2.10.2.0. It's not multi-select, just a drop down lookup.

Userlevel 5
Badge +14

ok, then following should reset lookup value

NWF$('#'+cidTraining).val("");
NWF$('#'+cidTraining).siblings('select.nf-client-control').val('**SelectValue**');
‍‍

‌ clear value‌ forms 2.9 and newer‌

Badge +3

Amazing!! Thank you - again.

Is this thing: siblings('select.nf-client-control') documented somewhere? Like Nintex or JQuery?

Userlevel 5
Badge +14

no it isn't.

and note it's valid just for current forms version(s). prior v2.9 the same was being achieved completely different way (that's why I asked for your forms version). and no one knows when nintex decides to change it again.

Badge +6

The jQuery.siblings() method is documented under docs.jquery.com Traversing section, I suppose. The DOM object(s) selector 'select.nf-client-control' (any element of node name 'select' that has 'nf-client-control' among its CSS classes) is based on the HTML markup generated by Nintex Forms and something that Nintex should document and keep consistent as much as possible.

Badge +3

Thank you, that is very helpful!

Reply