cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Custom JavaScript variable declaration fails when the value have special characters

Hi there,

Environment: SharePoint on-premise 2013 and Nintex Forms 2013

I have a custom function in which I have a simple variable declaration:

var bulletinTitle = Title;

When user inputs the Title value as: 2015 Guest Experience Information" Pack

The page does not load as the JavaScript files to load because of the following error:

     SyntaxError: missing ; before statement

var bulletinTitle = 2015 Guest Experience Information" Pack;

I tried all the options such as:

  • var bulletinTitle = "Title";
  • var bulletinTitle = 'Title';  // The above example works here but fails when user have Single Qoute in the title '
  • var bulletinTitle = fn-Replace(Title, '"', '\"');

Does anyone came across this and how did you fix it ?

Thanks in advance.

0 Kudos
Reply
4 Replies
mlauer
Nintex Newbie

Re: Custom JavaScript variable declaration fails when the value have special characters

Hi Arvi

the following is working for me:

var bulletinTitle = "fn-Replace(title,x1,x2)";

Where x1 and x2 are single line text variables:

Default value for x1 is double quote.

Default value for x2 is backslash + double quote.

Kind regards

Manfred

0 Kudos
Reply
Not applicable

Re: Custom JavaScript variable declaration fails when the value have special characters

Hi Manfred,

Thank you for your response.

I was trying you option but there is no insert "Form variables" within the "Settings - Form" >> "Custom JavaScript".

Nintex issue.PNG

Thanks,

Arvi

0 Kudos
Reply
mlauer
Nintex Newbie

Re: Custom JavaScript variable declaration fails when the value have special characters

Hi Arvi

are You using a list form?

Kind regards

Manfred

0 Kudos
Reply
Not applicable

Re: Custom JavaScript variable declaration fails when the value have special characters

Hi Manfred,

Yes, I'm using list form.

I have a SharePoint list, which is customized using Nintex forms and within the Nintex form designer "Settings - Form" >> "Custom JavaScript" and I have a function in which there is a variable declaration:

     var bulletinTitle = Title;

As this JavaScript is on the form, it will be loaded on the page without calling the function and the script loads on the page replacing the actual value of the Title as:

     var bulletinTitle = 2015 Guest Experience Information" Pack;

Then the browser throws JavaScript error:

     SyntaxError: missing ; before statement

Hope this is clear

Thanks,

Arvi

0 Kudos
Reply