i have some form data that i have to save together with the timestamp.
so i can only use the REST API.
But i have tried several methods out there but doesnt seem to work .
below is the samplecode where i am trying to retrive the timestamp results in to
"my_timestamp" variable where i will inturn save into the dictionary to be used by the REST
any ideas
/// get current timestamp EPOCH TIME
var timestamp_search = new SearchManager({
"id": "timestamp_search",
"status_buckets": 0,
"latest_time": "$latest$",
"search": "| stats count as timestamp | eval timestamp = now()",
"earliest_time": "$earliest$",
"cancelOnUnload": true,
"app": utils.getCurrentApp(),
"auto_cancel": 90,
"preview": true,
"runWhenTimeIsUndefined": false
}, {tokens: true,tokenNamespace: "submitted"});
//WHERE I GET THE TIME STAMP FROM THE SEACH MANAGER
var my_timestamp = ??
//FORM INPUTS
var record = {
"CustID": form_id,
"CustName": form_name,
"CustStreet": form_street,
"CustCity": form_city,
"CustState": form_state,
"CustZip": form_zip,
"time_stamp" : my_timestamp
};
// Use the request method to send a REST POST request
// to the storage/collections/data/{collection}/ endpoint
service.request(
"storage/collections/data/mycollection/",
"POST",
null,
null,
JSON.stringify(record),
{"Content-Type": "application/json"},
null);
});
... View more