Skip to main content

I have a Travel Form, where the user enters the Departure Date in a Date picker field. I want to be able to set andother field (Flight Departure Date) to the previously entered Departure Date. In InfoPath this is easy, but in Nintex it appears I need to write some JavaScript (and I am not a java script coder).


Can anyone help....PLEASE!!!

have a look here https://community.nintex.com/message/35016?commentID=35016#comment-34952 


Lots of information but a bit light on actual step by step instruction...but thanks for this suggestions


This is why I like InfoPath over Nintex....to set a default date field based on the value of another date field...quick and easy! In Nintex you need to write all the JavaScript....

Surely someone must have a simple solution???


Can anyone help me out. I have copied this script but my form simply hangs. I am not a java expert, so I am flying blind. All I want is to have date field default to the another date field....it's can't be that difficult! Please someone help me out


was it on published form or in preview? try it wiht published form.

check developer console for any errors (press F12 in a browser and switch to console window)

have you correctly configured javascript variables to source and target date controls?

post your configuration and script if you customized it anyhow.


OK, so I created a form with two date/time fields: [Startdate] and [Enddate]. What I am trying to achieve is after the users enters a start date, this is then updated into the Enddate field.

This is the script I placed in Form Settings - Custom JavaScript:

NWF.FormFiller.Events.RegisterAfterReady(function () {            NWF$("#"+StartDateVar).change( function () {   //sets the date box                     NWF$("#"+EndDateVar).val(NWF$("#"+StartDateVar).val());                       });   NWF$("#"+StartDateVar).parent().find("selectrid*='DateHours']").change(function () {   //sets the hour box             NWF$("#"+EndDateVar).parent().find("selectFid*='DateHours']").val(NWF$("#"+StartDateVar).parent().find("select(id*='DateHours']").val());                      }) NWF$("#"+StartDateVar).parent().find("select id*='DateMinutes']").change (function () {   //sets the minutes box                NWF$("#"+EndDateVar).parent().find("select id*='DateMinutes']").val(NWF$("#"+StartDateVar).parent().find("selecteid*='DateMinutes']").val());                        })  
})

In the StartDate field I put in the Client ID JavaScript variable (in the EndDate field I put the variable EndDateVar)

193430_pastedImage_1.png

I publish the form and then click on New Item (to add a new form). Nintex simply seems to hand with the circle dots just turning with "Please wait" and the form never opens.


that seems to be correct at first sight.

I just hope you have correctly formatted javascript code and not how it looks like here to be everything on single line.

try to check developer console for an errors - before you click new item press F12 and switch to console tab.

then click new item and watch the console for any errors.


I got someone to check the code and he found a few issues with way SharePoint treats Java:

NWF.FormFiller.Events.RegisterAfterReady(function() {

      NWF$("#" + StartDateVar).change(function() { /*sets the date box*/

        NWF$("#" + EndDateVar).val(NWF$("#" + StartDateVar).val());

      });

     

      NWF$("#" + StartDateVar).parent().find("selecttid*='DateHours']").change(function() { /*sets the hour box*/

        NWF$("#" + EndDateVar).parent().find("select+id*='DateHours']").val(NWF$("#" + StartDateVar).parent().find("selectSid*='DateHours']").val());

      });

      NWF$("#" + StartDateVar).parent().find("selectNid*='DateMinutes']").change(function() { /*sets the minutes box */

        NWF$("#" + EndDateVar).parent().find("selectÂid*='DateMinutes']").val(NWF$("#" + StartDateVar).parent().find("select"id*='DateMinutes']").val());

      });

});

Updated and it now works


‌, could you clarify what problems have you found in my code?


I got an developer to look at it and he told me there where some ";' missing and that in Java SharePoint/Nintex that the // comments were causing an issue so he change // to /*.....*/

Apart from that.....it worked

Thanks


so I would say it was just an issue of lost formating (line feeds) as you copy&pasted the code.

double slashes are valid comment delimiters in javascript.


emha, I've noticed Nintex Form custom JavaScript doesn't like "//" for comments. I've had to wrap all comments into comment blocks (/* comment */). I assume this is due to Nintex Forms removing the formatting from the script.


Reply