Troubles connecting text field populated by JavaScript to list column

  • 5 November 2018
  • 5 replies
  • 7 views

Badge +7

I have a textbox that is populated by a Javascript function.  I want to connect that textbox to a column in my list and keep coming up blank. I've tinkered with the datatype in my list column (right now it's a number, but have tried currency and string). I've added a calculated value field whose formula is just the value of the textbox (so I could then connect the calculated value to the list column). I've tried to get something to work using a formatting rule. No dice on any of these. It seems I'm missing something obvious. Why would the list column care if the field is populated by JavaScript? 

My textbox properties:

220510_pastedImage_1.png

Snippet of Javascript that populates txtTotalCost: 

NWF$('#'+jsTotalCost).val(totalCost);

5 replies

Userlevel 5
Badge +14

your code should work for single line text.

have you checked totalCost variable is correctly populated beforehand? can you you see the value in a form after code is executed?

don't you have multiple controls connected to the same list field?

Userlevel 2
Badge +11

Glue .focusout() after the val(). At least that works for me in all my JS.

Badge +7

The problem is - I had the textbox enabled property set to False. This still allows JavaScript to populate the textbox but apparently disables the SharePoint field from the SharePoint list itself. I think this is absurd. So I enabled the textbox, moved it to the far bottom corner of the form and covered it with a multi line text box. The I put a calculated field in its place so the user can see the payroll deduct amount but can't edit it. 

Userlevel 2
Badge +11

If you intend to access a control on a Nintex Form using JS, then never use the control properties Enabled and Visible. Especially hiding the control by setting Visible to No no longer renders the control on the form and as such it can't be used in JS. In these cases I always use a formatting rule:

  • Disabled controls need to be temporarily enabled in JS, value set and disabled again.
  • Hided controls should also be temporarily shown, value changed and hidden again
Badge +7

For anyone's reference, in my JavaScript I am now 1) populating the text box and 2) disabling it: 

NWF$('#'+jsTotalCost).val(totalCost);
NWF$('#'+jsTotalCost).prop('disabled',true);

Reply