I am trying to edit a record using session variables. There are TWO conditions passed into this form: RegDash and RegDate. Both of these values must be used to edit the correct record.
I used the following Forum post as a guide:
However, The filter DOES NOT WORK, it gets the wrong item???
I rewrote the code to use wixDataquery instead of a filter:
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
import {local, session} from ‘wix-storage’;
import wixWindow from ‘wix-window’;
$w.onReady( function () {
let formType = session.getItem(“Edit#Sel”);
let regDash = session.getItem(“CarId”);
let regDate = session.getItem(“eDate”);
// EDIT THE RECORD PASSED BY SESSION
if (formType === “Edit”){
console.log("regDash ",regDash)
console.log("redDate ",regDate)
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
import {local, session} from ‘wix-storage’;
import wixWindow from ‘wix-window’;
$w.onReady( function () {
let formType = session.getItem(“Edit#Sel”);
let regDash = session.getItem(“CarId”);
let regDate = session.getItem(“eDate”);
// EDIT THE RECORD PASSED BY SESSION
if (formType === “Edit”){
var filter = filter.eq(“dash_no” , regDash).eq(“entry_date” , regDate);
$w(“#dataset1”).setFilter(filter)
} else {
$w(“#button3”).label = “Submit”;
}
session.clear();
});
Is it possibly because the regDate is a DATE/TIME fields?
The page list-registry-histories LISTS all the history records. They are stored by Dash#, Date/Time. When database is ready, I am storing the date as retrieved in a session variable. Console log shows it correctly in LONG format. For example:
Thu Aug 02 2018
I am then converting to simple Date without the TIME(GMT) mumbo jumbo as you call it. Record is displaying as I wish. The display also contains a button click event that loads THIS page and using the session variables dash_no and entry_date. I have also console logged the session variable from the GET and it is same as what was sent. BUT, it displays the WRONG record. I am thinking that INTERNALLY the date is stored differently…as you suggested SO…
I created an additional text field in the repeater called origDate that is connect the same database entry_date. Then onRepeaterReady, I HIDE this text field. Also, console logged this extra field. It is getting preserved as the copy is what gets modified for actual display in the repeater.
Here is the RunTime log. It clearly shows the List program is setting session variable properly, and on the Update click the new page is also properly getting the right session variable valus.
Time removed from Date/Time Stamp: New Date Thu Aug 02 2018
wixcode-worker.js:17 CarId: 2716
wixcode-worker.js:17 eDate: Fri Aug 03 2018 00:00:00 GMT-0400 (Eastern Daylight Time)
console.js:35 Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
console.js:35 Loading the code for the Update Registry History page. To debug this code, open wqukw.js in Developer Tools.
console.js:35 CarId: 2716
console.js:35 eDate: Fri Aug 03 2018 00:00:00 GMT-0400 (Eastern Daylight Time)
yet, the displayed input form has the WRONG record and all three fields are unselected WHITE???
I am going to revert to the wixDataQuery method I tried earlier…just to see what happens…
FYI - When ONLY one entry for a given dash_no is present you don’t get the white screen, but the it shows the FIRST record on the form. If more than one entry but each with different date you get the White Input Form. Therefore, the FILTER is DEFINITELY NOT WORKING.