Update Date Field automatically
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Tom,
Yes, of course! Please, check out the following article - https://spform.com/javascript-framework ... eld-values
It shows you how to detect change in any of the fields, how to get the current value and how to set a new value to a field. All you need to do, is write the code to detect change in a field Start Date and to update the Due Date properly.
For example:
Yes, of course! Please, check out the following article - https://spform.com/javascript-framework ... eld-values
It shows you how to detect change in any of the fields, how to get the current value and how to set a new value to a field. All you need to do, is write the code to detect change in a field Start Date and to update the Due Date properly.
For example:
Code: Select all
fd.field('StartDate').change(function(){
var startDate = fd.field('StartDate').control('getDate');
var dueDate = new Date();
var weekInMilliseconds = 7 * 24 * 60 * 60 * 1000;
dueDate.setTime(startDate.getTime() + weekInMilliseconds);
fd.field('DueDate').value(dueDate);
});
Cheers
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Tom,
Yes, I was just testing it out for you, it's in my first reply now. Check it out, but don't forget to replace StartDate and DueDate with correct InternalNames of the fields, I do not know them, but you can check them in the designer, when you select a field. Also, I am adding a week, but you can add any amount of days instead.
Yes, I was just testing it out for you, it's in my first reply now. Check it out, but don't forget to replace StartDate and DueDate with correct InternalNames of the fields, I do not know them, but you can check them in the designer, when you select a field. Also, I am adding a week, but you can add any amount of days instead.
Cheers
Sorry for the late delay,
the script doesn't work.
Here is my script
fd.field('Anfangsdatum').change(function(){
var startDate = fd.field('Anfangsdatum').control('getDate');
var dueDate = new Date();
var weekInMilliseconds = 7 * 24 * 60 * 60 * 1000;
dueDate.setTime(startDate.getTime() + weekInMilliseconds);
fd.field('Fälligkeitsdatum').value(dueDate);
});
Best wishes
Tom
the script doesn't work.
Here is my script
fd.field('Anfangsdatum').change(function(){
var startDate = fd.field('Anfangsdatum').control('getDate');
var dueDate = new Date();
var weekInMilliseconds = 7 * 24 * 60 * 60 * 1000;
dueDate.setTime(startDate.getTime() + weekInMilliseconds);
fd.field('Fälligkeitsdatum').value(dueDate);
});
Best wishes
Tom
Hi Tom,
The example was for the DateTime field with a default template.
A code for the field with a Kendo template (your choice, as I understand) will be slightly different:
The example was for the DateTime field with a default template.
A code for the field with a Kendo template (your choice, as I understand) will be slightly different:
Code: Select all
fd.field('Anfangsdatum').change(function(){
var startDate = fd.field('Anfangsdatum').value();
var dueDate = new Date();
var weekInMilliseconds = 7 * 24 * 60 * 60 * 1000;
dueDate.setTime(startDate.getTime() + weekInMilliseconds);
fd.field('Fälligkeitsdatum').value(dueDate);
});
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Cassidy,
Use the following code for default Date field:
And the following code for Kendo Date field:
I hope this will help you, as these are the only two options for date fields available in Forms Designer by default. If you have any questions - let us know!
Use the following code for default Date field:
Code: Select all
fd.field('StartDate').change(function(){
var startDate = fd.field('StartDate').control('getDate');
var dueDate = new Date();
var weekInMilliseconds = 7 * 24 * 60 * 60 * 1000;
dueDate.setTime(startDate.getTime() + weekInMilliseconds);
fd.field('DueDate').value(dueDate);
});
Code: Select all
fd.field('StartDate').change(function(){
var startDate = fd.field('StartDate').value();
var dueDate = new Date();
var weekInMilliseconds = 7 * 24 * 60 * 60 * 1000;
dueDate.setTime(startDate.getTime() + weekInMilliseconds);
fd.field('DueDate').value(dueDate);
});
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 21 guests