I am trying to Update a single line text field with the value from a date picker field. At the moment I am getting the return value as day month year time etc - I only want the date format yyyy-mm-dd returned and not the time and time zone
fd.field('Title').disabled = true;
fd.field('Sales_x0020_Date').disabled = true;
fd.field('Sales_x0020_Date').value;
var today = new Date();
var minusDate = today.setDate(today.getDate()-1);
fd.field('Sales_x0020_Date').value = new Date(minusDate);
var date = new Date().toISOString().split('T')[0]
var formattedDate = date.replace(/-/g, "/")
fd.field('Date1').value = new Date(formattedDate);
function combine () {
if (fd.field('BranchNo').value != null && fd.field('Date1').value != null) {
fd.field('Title').value = fd.field('BranchNo').value + '-' + fd.field('Date1');
}
else {
//Clear PositionWeek field value if one of the dropdowns is cleared
fd.field('Title').value = '';
}
}
//Call function on form load
combine ();
//Call function on field change
fd.field('BranchNo').$on('change', combine);
fd.field('Date1').$on('change', combine);
});
The form is bringing the Date1 value up as [Object Object]
I am getting the Title field data from a field called BranchNo (Number field), then I take the date value that is in my Sales Date (Date) and copying it to the Date1 and Date2 column. Then I try to convert the Date1 field to ISOString and copy it to the Title field - Title field needs to = BranchNo-Date1 and is not working at the moment. Am I missing something in my code???
The code I've shared is for converting the date to a string in the desired format. You msut use it for the text field like so:
var date = new Date().toISOString().split('T')[0]
var formattedDate = date.replace(/-/g, "/")
d.field('Title').value = fd.field('BranchNo').value + '-' + formattedDate;