Embedding questions with optional parameters

Hi, I have a question with 3 required parameters and 2 non-required parameters.
I want to embed it programmatically without showing the user any of these parameters so in the embedding config I set all parameters to “locked” (as “editable” would show the user an input box, and “disable” doesn’t let me pass values programmatically).
However when I embed this question and don’t set some of the non-required parameters I get an error “You must specify a value for :some_non_required_parameter in the JWT.”.
It seems to me that it’s a bug for the embedding settings to override the question’s parameter settings? I don’t understand why a non-required parameter becomes required when embedding?
Otherwise can someone explain how I can achieve what I describe?

Many thanks
Mauricio

Hi @mausch

Without seeing the queries or having a step-by-step using sample data, it’s difficult to help or know where the problem is.

But given that questions about Embedding and Field Filter comes up on a regular basis, I think the user experience and/or error messages could be better and more helpful.

Thanks for the quick reply @flamber .
I don’t really see how the specific queries or sample data are relevant here? My question is about the behaviour of parameters when embedding.
Since you say this is a common question could you point me to some existing thread about it? Maybe I can add to that discussion. FWIW none of these parameters are “field filters”, they are just numbers.

Cheers

I've been through this pain myself. I'm using C#, so little bit different:

If you really don't want to set the values in the same way (probably tricky with numbers), you could look at having 2 versions of the dashboard and just select depending upon whether or not there's a value in the parameter.

1 Like

Hi Andrew , I’m using C# as well, but I don’t think that matters.
I found this relevant comment from a developer saying that “locked” means the parameter becomes required.
I don’t understand how you can embed questions with non-required parameters then?
If non-required means you can only use “editable” embedded parameters this seems like a crippling limitation in embedding? Can anyone confirm this is the case?

Just create a 2nd copy of the dashboard/question without the parameter. Programtically select depending upon whether or not you want to set a parameter value.
It’s a pain, but not the end of the world.

Yeah I guess there’s no other way around this for now.
Still I left a comment on https://github.com/metabase/metabase/issues/7306 , I recommend everyone having this issue to comment and upvote so the Metabase team reopens and addresses this issue.

For what it’s worth, we also took the “two dashboards” approach and created a special dashboard for embedded that has just the parameters we need. In the end it made more sense for our application to maintain a different dashboard for the embedded version anyway.