Current Time in Nintex Forms (real Time)


Badge +8

Hi,

I needed to extract the current time in Nintex Forms. I am aware of the CurrentTime nintex function, but the problem is that the currentTime is never updated and if the form is kept open for a few minutes the time is not updated. I believe Nintex loads the variables when the form is first loaded. I need to get the exact time (don't want to use the client time and would need to rely more on the server time).

Any guesses how I can achieve this.? I have tried a number of ways like calling a processupdate() function to refresh my calculated field to give the current time, but the time never refreshes and it always stays the same (i.e. the time when the form first loaded)

has anyone else faced this and how did they overcome? Any suggestions welcome.

Regards,

Shrini

Marian HatalaCaroline Jung


19 replies

Userlevel 5
Badge +14

what about to use OOTB sharepoint field 'Created'?

or you can create your own datetime  list field and set it's default value to current date. if you do not supply it's value from forms it will be populated with date&time when item is created.

Badge +8

Hi Marian,

Date is not an issue, its the "time" that's an issue. When the form is first opened the time is set and after that the time is never updated. So if the user closes the form (using a button click) and if I read the "time" at that moment the time would be past(may be couple of minutes behind depending on how much time the form is kept open). I need the exact time the user had clicked the button.

Regards,

Shrini

Userlevel 5
Badge +14

do you mean to update datetime field with each item's edit/update?

then there in OOTB sharepoint list field 'Modified'

Badge +8

No ... not the update datetime field.. Cant use the SP OOB LastModified or Created Date

Scenario

User opens my form .. reviews stuff, puts in comments and Submits the form. (Submit is triggered through a button click).

I need to add the datetime stamp on the user comment fields and save it. 

For adding the dateTime stamp I am using Nintex inbuilt function CurrentDate and CurrentTime. This issue with using CurrentTime is that it is not realtime and if the user has taken few minutes to review before hitting submit the Time that I add to the comments is few minutes earlier. Is there any way to get the "Server" currentTime on the nintex Form ? (realtime)

Regards,

Shrini

Userlevel 5
Badge +14

are those comment fields/controls single line or multiline texts?

Badge +8

Multiline texts.. I have used AppendOnly Multi-line (if thats what you are referring to) before but this needs to be plain text field

Userlevel 5
Badge +14

append changes is available for both plain and rich text

216910_pastedImage_1.png

... at least on SP2013 on-prem. I'm not sure what platform are you on.

Badge +8

Hi,

I am already using appendChanges for some other text boxes. The problem with AppendOnly is it uses versioning behind the scenes to save data and its difficult to extract the entire text out of the appendonly field. 

Try adding the appendonly text box to your default view and see the contents. It doesnt show up. 

Badge +8

Hey Marian,

Would you know the syntax of calling NIntex built-in functions like CurrentDate or CurrentTime etc from JS function (using NWF$) ?

Regards,

Shrini

Userlevel 5
Badge +14

that's how it's designed.

having a view with a column that have some 20 or so lines for each item is as well not very comfortable to look through.

User opens my form .. reviews stuff, puts in comments and Submits the form. (Submit is triggered through a button click).

I need to add the datetime stamp on the user comment fields and save it. 

could you describe how this is exactly done in practice?

how do you append CurrentDate/Time reference variables to the comments?

I wonder how do you eg. proceed if form was not submitted due to not being valid? meaning you timestamp comments before first submit attempt, then form is corrected and submitted once again. how do you check and/or prevent timestamp is not added several times? resp. that previous timestamp should be replaced?

or how do you ensure user added a comment or check whether it added anything or not to decide whether timestamp should be added or not?

how do you identify whether user added comment at beginning of the field or somewhere in the middle or at the end? how do you identify position where to add timestamp?

Userlevel 5
Badge +14

these two are not any functions you could call from js code. they are just references (placeholders) which are evaluated and replaced at server side at the moment when form/page is generated. that's the reason why they are not reevaluated at runtime.

Badge +8

Hmm just wanted to validate if these functions are only evaluated once when the form loads (which I thought would be the case) but wanted to double check

BTW I am sure I have seen on one of this forum we can call Nintex functions using NWF$ from JS and hence was curious to check this myself!

Badge +8

Can deep dive on this .. but i have it all covered though .. the only issue is getting the value of time (realtime) at server side rather than depending on client side or doing another update after the form has been updated.

With regards to the validation - There are not much validation and most of the validation is being done via JS, so after the validation is done and everything is clear before posting the form back to the server, this server timestamp and comments copy happens at the end.

I am already using the appendonly comments for capturing these values, but I copy from this appendonly comments and keep them in a hidden field (with the datetime stamp and it would be few minutes old the user has taken some time before approving) if it is required for any reporting purposes.

Userlevel 5
Badge +14
the only issue is getting the value of time (realtime) at server side rather than depending on client side

whatever you perform/run in form (on your own) is being performed/ran on client side.

so whatever complicated js script or logic you write it still runs on client side. even if you made some postback/ajax call to the server just before the submit to get server's current time, there still would be some time gap between the time you get returned from server and 'real' submit (ie. when everything is sent/processed/written to the sharepoint)

if you really needed server value you would need to rely on sharepoint's fields/calculations as mentioned above, or a custom workflow.

 most of the validation is being done via JS

if you already have bunch of js code within the form then you can get current time from javascript's Date object. but of course that's client's time.

JavaScript Date Reference 

btw, does that really matter whether you get a timestamp when form was opened or when form was submitted?

user can open form in EDIT mode at 12:00 and submit at 12:05 (so with current solution you would get submit time 12:00 and user needed some 5min to take the action) or whether user opens the form at 11:00 in VIEW mode, checks everything, then at 12:00 switches to EDIT and submits within the same minute? you would get the same submit times 12:00 in both cases, but you can not measure how much time the user spent working on it out of that.

Userlevel 5
Badge +14

that's true, but just for runtime functions, published (or not) client APIs and plenty of other forms' internal functions.

but not everything what's needed for overall environment functionality can be found there.

Badge +8

Cheers ..

Could you provide me the syntax of calling any one of the Nintex functions through NWF$?

Badge +8

true .. hence I require the server side time rather than the client side time.

I was only curious if there was any built-in function or any clever way in Nintex to find the current time (which does get updated every minute - if not every second).

Userlevel 5
Badge +14

I guess we have already discussed all the possibilities...

Userlevel 5
Badge +14

see eg. https://community.nintex.com/message/72006-re-read-in-text-from-list-item-and-place-it-in-form-text-box?commentID=72006#… 

Reply