Updating URL query parameters on interaction with action element

Hi,
I am trying to add a query parameter to a URL and refresh the fetched data on checkbox selection. The way I am trying to approach this is to add an onChange interaction to the checkbox and the event would trigger a Refresh data action. But, I don’t get how to properly set up a dynamic value for the action.

  1. Is it the right approach in general?
  2. Is there any documentation for the Refresh data action?
  3. How to make complex queries resulting from interactions with various elements of UI (in other words, filters)?
  4. What is “queryInvalidation” field for? What does it do?

Regards,
Maciej

I see that I can set up multiple filters for the query parameters and assign dynamic values to them. However, in case of the query parameter that can have true/false value I would like the filter to be either true or removed from the query. I don’t want to assign false value,.

Hi @maciek_ziolkowski , sorry I missed this one earlier!

Yes, you should be able to run a Refresh Data step in interactions:

Are you using SQL? If so, and you want to potentially remove that condition from the query, the best thing to do is to formulate this as SQL, like:

select * from mytable
where case when {{ $state.checkbox.checked }} then myfield else true

Hi @yang ,
thanks for the tip. Unfortunately, I stumble on a bug when fetching data with a random SQL query with dynamic values.

image

and this is my query

where category_name is a page URL path parameter

image

when I replace the dynamic value with a string the query works fine…

Also,
even though I’ve set the min role for the query to Anonymous, when I set the preview role to this role the query returns an error and I get such notification in Plasmic Studio:

Oh that’s interesting, can you share a few things

Screenshot of the page data tab, including the current preview of The path parameter and the minimum role required

What you see when you click into the pill inside of the SQL editor, what is the preview value it shows there for that path parameter

The screenshot of the minimum roll on the query itself

And a link to the plasmic projects and a specific page that this is happening on

Here you go:

  1. Screenshot of the page data tab

  2. What you see when you click into the pill inside of the SQL editor:

  3. The screenshot of the minimum role on the query:

  4. Here’s the link to the project and a specific page:
    Plasmic

Sorry for the delay here, the issue is that there was a missing space between your dynamic value and the and after it. We’re adjusting the UI to make this easier to spot.

1 Like

Hi @yang , thanks for spotting the issue. But now, for some reason, when I assign the Refresh Data action to onChange event on the checkbox (with the correct query that does return results), nothing happens… The list of elements fetched remains unchanged.

Hi @maciek_ziolkowski , the query does seem to be refreshing correctly. I just don’t think that the query is being used anywhere else on the page, so you don’t see anything change. For instance, the main list is driven by a different query, the fatchCompanies query.

I think you just need to make fatchCompanies incorporate the checkbox value, you don’t need a second query.

(You also don’t need to have Refresh query onChange at all, you can remove that. As soon as the checkbox value changes, since the query is already referencing checkbox → checked, it will update automatically)

1 Like