Question

Java Script not executing at run time

  • 1 February 2023
  • 7 replies
  • 117 views

Badge +1

Good day

Im New to Javacript, I have a custom Javascript function here that so does a very simple thing.

It takes the text from one nintex control (Multiline text) and adds it to another control (Also Multiline text)

the script works in the design editor how ever at run time the function does not execute. 

Can any one explain this behavior and maybe a fix i can apply in my script.

 

NWF$(document).ready(function() {
    NWF$('#' + txtAddComments).change(function() {
        var val = NWF$('#' + txtAddComments).val();
        NWF$('#' + txtAddCommentsTemp).val(val);
    });
});


7 replies

Userlevel 6
Badge +16

Hi @KBV 

You stated that the JavaScript code works during design but doesn’t work during run-time.

Are you using Nintex Mobile (as JavaScript doesn’t work in Nintex Mobile)?

Badge +1

Hi @Garrett 

No we are not using nintex mobile.

I have also deleted all the other nintex layouts to see if it has an effect which it doesn't. 

We are running Nintex on prem on online.

Userlevel 5
Badge +14

It’s incredibly strange that it would work in preview, but not in regular mode. Your code is correct and works in my tests. Can you provide any screenshots of the form, or load the form (New or Edit) with the Developer’s Console of Chrome / Edge open so that we can see if any errors are being thrown?

 

The more information the better!

Badge +1

Thank you for the response please see bellow

In editor mode the function runs as expected, it populates field 2 properly with no errors about the specific fields

Editor Mode

Editor Mode

Runtime

Run Time

 

 

 

 

Userlevel 5
Badge +14

Hmm. I can’t see anything off about what’s in those screenshots. Can you perhaps show me where the code is located in the form settings? Is it just in the Custom JavaScript textbox as shown in the example below?
 

 

Also do you have any additional JS running on this form or is it just the code for pushing one val across Controls? 

Badge +1

Hi @MegaJerk 

I have the code in the java script section exactly as you do.

no additional Javascript. Just the code for copying the values.

 

Userlevel 5
Badge +14

Okay then. Let’s do a simple test to make sure that we’re not crazy. Somewhere either before or after that code you have in there now, can you add the following code and then publish the form:

alert("test");

 

 

When you launch the form in both preview or as a new item, you should get a pop-up alert that resembles:

 

If you get that pop up in both places, then we know that JS *is* executing correctly but something about the other code is behaving in a way that is unexpected. Let me know the results. 

Reply