My Java knowledge is mostly cut and paste, so hoping for some help.
I want to extract the four parts of a user-entered date field and use them to create 4 distinct values in the same object.
The user enters a complex date that has Start Date, Start Time, End Date, End Time.
In my object, I have fields for each of those four values.
I want to set those fields to the extracted values, but I'm not sure how to parse and extract the different parts of a complex date field. And actually not sure how to set those variables, either. Here's a stab at it, copied and chopped up from another code snippet on complex dates. Any help?
// Update your view number to match your project $(document).on('knack-record-create.view_259', function(event, view, record) {var startd, startt, endd, endt data = new Object(); // I think this creates the 4 variables I need.
// Updated my view number, and field numbers field, but now I need to pull each of the 4 parts of the date field out, and not sure how.
var startd = ("#view_259-field_299"), //Parse code goes here, right?
startt = ("#view_259-field_299-time"), //Parse code goes here, right?
endd = ("#view_259-field_299"), //Parse code goes here, right?
endt = ("#view_259-field_299"), //Parse code goes here, right?Knack.showSpinner();
// This was originally a call that added the complex date to the database. But I need it to add the new simplified dates to the database.
// You will need to update with your own <Application ID> and <API Key>
// Also update with the correct scene and view numbers.
$.ajax({
url: “https://api.knackhq.com/v1/scenes/scene_<204>/views/view_<395>/records/” + record.id ,
type: “PUT”,
headers: {“X-Knack-Application-Id”: “<Application ID>”, “X-Knack-REST-API-Key”:"<API Key>"},
data: data,
success: function(response) {
console.log(“Record Updated with this data:”);
console.dir(data);
},
error: function(response) {
alert(‘Update Failed!’);
console.log( response.error );
},
complete: function () {
Knack.hideSpinner();
}
});
});