Skip to main content

Hi,

I've been working on this off and on for weeks and spent a lot of time searching for an answer that would work but so far, I've had no luck!  Hopefully, someone out there can steer me in the right direction.  This is my scenario - I have a form and a workflow.  When a new form is submitted, a workflow is triggered.  When a form is edited (date fields only), a different workflow kicks off.  Now, I know there's a workflow feature that can check previous values vs. new values but I've read that this feature isn't 100% reliable (perhaps this isn't correct?).  Anyways, my goal was to use JavaScript to compare old values vs. new.  This is what a portion of my form looks like:

Form and Formula

I've been mostly focusing on the Departure Date first (when I get this right, I'll add change events to the others, as well).  So, to explain - the user opens a form that they have already created because they want to edit the dates.  In this example, the departure date (JavaScript ID = "varEndDateID") is updated and this triggers a change event.  This is what my JS code looks like:

  NWF$("#" + varEndDateID).change(function(){

    var oldDeparture = 'End Date'; //End Date is the item property value
    NWF$("#" + varNewEndDate).trigger('focusout');
    var endDateTime = NWF$("#" + varNewEndDate).val();
    console.log('new end date is: ' + endDateTime);
  });

The new date is supposed to get stored to the variable endDateTime.  But, it always stores the previous date (the one that appears in the calculated field (JavaScript ID = "varNewEndDate") is what appears on the form when it first loads.  I tried making it a global variable but that didn't help.  I've used .trigger('blur'), .trigger('change'), and .trigger('focusout') in an effort to refresh the value in the calculated field but that didn't work, either.  My goal is to take this value and compare it to the original (which I was retrieving by assigning the "End Date" item property to a variable).

What am I missing here?  Please help and thanks in advance!

Hi,

In your calculated field formula, you must use the EndDate value from the control list, not from the item properties list.

Do you understand what i'm talking about ?

Regards.


Hi,

My calculated field is using the named control for the EndDate but it's still producing the old date when that date is extracted from the form using JavaScript:

 

Is there anyway I can get the data to be refreshed before extracting it via JavaScript?

Please let me know.  Thanks!


And if you execute NWF$("#" + varNewEndDate).val() (with IE10 or IE11) in JavaScript console after modified the DepartureDate, it's the same result ?

Maybe it's a trigger/focus problem.

Regards.


Yes, I get the same result when I execute NWF$("#" + varNewEndDate).val() in IE11.  It keeps showing me the previous value rather than the current one.  


This works for me on Nintex for Office 365 : 

Regards.


Pulling the date directly like that works for me, too, but it only returns the date.  I need the time, as well.  This is why I've been trying to get the date/time in such a roundabout way.  Incidentally, I'm using SharePoint 2013/Nintex 2013 On Premise.  I'm not sure if that makes any difference, but just in case it does, that is the version I'm using!


I don't know if it's the same for OnPremise, but this works in Online. I had to change the declaration of my Date field in the SharePoint list and in Nintex Form to display the time.

Regards.


I created a calculated field containing the date/time using item properties and one calculated field using the named control date/time value.  When those dates were then logged into the console using jQuery, they were still showing previous dates rather than current. 


1. if you only want to know date changed, you do not need to complicate things with hunting for previous value at all.

if your custom change handler is fired you can be sure a change happened.

anyway, you can get new value as follows

NWF$('#'+dtctrl).change(function(evt){
    console.log('new value=' + evt.target.value);
})

2. are you aware of that change handler assigned to date control by a javascript variable is fired only for date input box?

for hours and minutes inputs you will have to attach separate handlers, if you are interested in their changes.


I'll give that a try, thank you!  

And no, I'm not aware of how to use change handlers for the hours and minutes.  This is my first time using the time controls.  So far, this is how I've been handling the time (in order to set defaults - this is separate from the code I'm using to detect changes):

var firstTime = NWF$("#" + varStartDateID)
var hour1ddl = firstTime.parent().find("selectlid*='DateHours']");
var min1ddl = firstTime.parent().find("selectlid*='DateMinutes']");  


Hi ‌,

This is an interesting use case. We have been working on a few new features I would be interested to get your feedback on. Would you mind having a call so we can discuss your requirements in more detail and show some upcoming features? My email is euan.gamble@nintex.com.

 

Cheers,

Euan


Have you tried to use the conditional start feature on prem? I have personally had pretty good success with it. Here is an example of a conditional start if you need one.

conditional start


Reply