Skip to main content
added 1 character in body
Source Link
John John
  • 1
  • 49
  • 258
  • 603

I am working on a sharepoint 2013 on-premises team site. now i want to set a column which is of type date/time to be equal to today date,so i added a script inside the Edit form, then i tried to set the date value using SPUtiltiy, as follow:-

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd = '0'+dd
} 

if(mm<10) {
    mm = '0'+mm
} 

today = dd + '/' + mm + '/' + yyyy;
alert(today);
SPUtility.GetSPFieldByInternalName('OrderDateCustomerApproved_').SetValue(today);

but i got this error:-

Unable to set date, invalid arguments (requires year, month, and day as integers).

throw "Unable to set date, invalid arguments (requires year, month, and day as integers).";

so i tried to do so using pure JavaScript appraoch as follow:-

$('select[id^="OrderDateCustomerApproved_"]').val(today);

where this did not raise any error, but the fielfield was not populated with today date!!

so can anyone adivce on this please?

enter image description here

I am working on a sharepoint 2013 on-premises team site. now i want to set a column which is of type date/time to be equal to today date,so i added a script inside the Edit form, then i tried to set the date value using SPUtiltiy, as follow:-

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd = '0'+dd
} 

if(mm<10) {
    mm = '0'+mm
} 

today = dd + '/' + mm + '/' + yyyy;
alert(today);
SPUtility.GetSPFieldByInternalName('OrderDateCustomerApproved_').SetValue(today);

but i got this error:-

Unable to set date, invalid arguments (requires year, month, and day as integers).

throw "Unable to set date, invalid arguments (requires year, month, and day as integers).";

so i tried to do so using pure JavaScript appraoch as follow:-

$('select[id^="OrderDateCustomerApproved_"]').val(today);

where this did not raise any error, but the fiel was not populated with today date!!

so can anyone adivce on this please?

enter image description here

I am working on a sharepoint 2013 on-premises team site. now i want to set a column which is of type date/time to be equal to today date,so i added a script inside the Edit form, then i tried to set the date value using SPUtiltiy, as follow:-

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd = '0'+dd
} 

if(mm<10) {
    mm = '0'+mm
} 

today = dd + '/' + mm + '/' + yyyy;
alert(today);
SPUtility.GetSPFieldByInternalName('OrderDateCustomerApproved_').SetValue(today);

but i got this error:-

Unable to set date, invalid arguments (requires year, month, and day as integers).

throw "Unable to set date, invalid arguments (requires year, month, and day as integers).";

so i tried to do so using pure JavaScript appraoch as follow:-

$('select[id^="OrderDateCustomerApproved_"]').val(today);

where this did not raise any error, but the field was not populated with today date!!

so can anyone adivce on this please?

enter image description here

Source Link
John John
  • 1
  • 49
  • 258
  • 603

Unable to change my Date filed using javascript inside my Edit form

I am working on a sharepoint 2013 on-premises team site. now i want to set a column which is of type date/time to be equal to today date,so i added a script inside the Edit form, then i tried to set the date value using SPUtiltiy, as follow:-

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd = '0'+dd
} 

if(mm<10) {
    mm = '0'+mm
} 

today = dd + '/' + mm + '/' + yyyy;
alert(today);
SPUtility.GetSPFieldByInternalName('OrderDateCustomerApproved_').SetValue(today);

but i got this error:-

Unable to set date, invalid arguments (requires year, month, and day as integers).

throw "Unable to set date, invalid arguments (requires year, month, and day as integers).";

so i tried to do so using pure JavaScript appraoch as follow:-

$('select[id^="OrderDateCustomerApproved_"]').val(today);

where this did not raise any error, but the fiel was not populated with today date!!

so can anyone adivce on this please?

enter image description here