I have a field A with a start date and time (04/12/17 15:20) and field B with end date and time (04/12/17 16:20) I also hace Field C which is a date/time field with "options like repeat and end-time to use with a calendar" enabled. I would like to automatically populate Field C using the information from field A and Field B to display in a calendar.
Who can help?
Arved
I needed to do this in an app for a client - it can be done in JavaScript (sorry about the lack of indentation):
// Listen for a record being edited on view_1070... Add Event
$(document).on('knack-form-submit.view_1070.view_1071', function(event, view, record) {
// Set up PUT request to update the record at the end
var url = 'https://api.knack.com/v1/pages/scene_640/views/view_1073/records/' + record.id;
var headers = {
'X-Knack-Application-ID': appID,
'X-Knack-REST-API-Key': 'knack',
'content-type': 'application/json'
};
// Set date range for Calendars to the calculated value...
// field 969 is the field with the end date
// field 967 is the start date and 968 is the end date
if (record.field_968.length > 0) {
var data = {field_969: {
date: record.field_967, // start date
to: {
date: record.field_968 // end date
}
}
};
} else {
var data = {field_968: record.field_967, field_969: {
date: record.field_967, // start date
to: {
date: record.field_967 // end date
}
}
};
}
console.log (data);
Knack.showSpinner();
// Make the AJAX call
$.ajax({
url: url,
type: 'PUT',
headers: headers,
data: JSON.stringify(data),
}).done(function(responseData)
{
Knack.hideSpinner();
});
});
And I'm interested in more or less the same, getting the start and end dates out from a date field with the "repeat and end-time" enabled. Something like mydate.start and mydate.end
/Jens