Why doesn't the setFilter for a dataset work?

I have tried this various ways and finally I moved the code from the onReady function to being executed by a button. As soon as the setFilter is called all of the user input fields on the form get set to read-only and still the data on the form doesn’t change. The information looks as follows:

When the following code runs:

export function button2_click(event) {
   console.log("button2_click called");
   let eventId=session.getItem("CurEventID");
   console.log("button2_click, eventId="+eventId);
   $w("#EventsDataset").setFilter(wixData.filter()
       .eq("eventId", "eventId") 
   )
   .then( () => {
       console.log("dataaset setFilter was successful");
   })
   .catch( (err) => {
       console.log("setFilter error encountered, err="+err);
   });

I get the following results in the developers console log:

button2_click called Event Detals Line 91
button2_click, eventId=e5dcbd3c-d40d-41fa-864b-92ea44894650 Event Detals Line 93

An error occurred in one of currentIndexChanged callbacks Error: Variant “Error” not covered in pattern. This could mean you did not include all variants in your Union’s matchWith function. For example, if you had this Union: const Operation = union({ Add: (a, b) => ({ a, b }), Subtract: (a, b) => ({ a, b }), }) But wrote this matchWith: op.matchWith({ Add: ({ a, b }) => a + b // Subtract not implemented! }) It would throw this error because we need to check against ‘Subtract’. Check your matchWith function’s argument, it’s possibly missing the ‘Error’ method in the object you’ve passed.

dataaset setFilter was successful

Since I am not calling currentIndexChanged or matchWith I assume it must be something with the setFilter or the wixData.filter entries but I am calling them exactly the same as shown in the Wix Code API page for setFilter. Can anyone see a difference in what I am doing?

Hello, artpuryear !

  1. The string .eq (“eventId”, “eventId”) is doubtful, maybe you can try it
  .eq ("eventId", eventId) 
  1. “.then (() => …” is the exit point when something is found in the database or nothing is found. It is useful here to check the search results with console output. “.catch ((err) => …” is an emergency exit point when there is no access to the database or there are problems with the Internet.

Good luck!

Yes, I have done the .eq statement both ways (“.eq(“eventId”,eventId)” and ".eq(“eventId”,“eventId”) and both ways give me an error. Can you tell me why it is calling currentIndexChanged and matchWidth? What do I need to do to satisfy what it is looking for?

Probably, the cause of the error is outside the limits of the given fragment, the data type in the database may be incorrectly applied. Sorry, I don’t have enough experience too.

Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor.