Query Parameters in a Modal/Dialog

I have checked some other posts about this and it seems they are all outdated.
I’m passing a couple of query params in a modal that loads a page. On that page if I use mustache to read that query param, it works.

{{$Param.my_great_param}}

Now when I try to access the same via javascript, they simply does not exist.

How can I access that param inside my javascript? I’m using it to load information that is related to the action/objects/etc.

Things that I have tried so far:

  • skuid.page.params → for some reason only return the modal inner page params
  • creating an ui only model that I could associate the field with the param → doesn’t work because there is no way to inform the model to use that param for the first row and conditionals on the model itself doesn’t support that
  • using raw javascript to read the query parameters → just to find out that just like the skuid.page.params it does not have that param that is available through mustache

Any help appreciated. Right now I’m thinking in doing something really ugly and hacky.

Update:
Just tried the hacky way and it doesn’t work because the mustache parameter is only translated after the page is loaded.

Update 2:
To solve it I had to use a 2nd hacky way to get to the information.

Ui-Only Model
→ 1 field per parameter
→ model action
→ when model is required
→ update model
→ add field
→ associate the field with formula
→ on the formula use the mustache parameter.

When the page is loaded the model will then have the parameters values. For you to access the values via javascript:

Load model
→ get rows
→ use first row
→ get the value of the parameter you need.

Are you using V1 or V2?

I’m not exactly sure how you’re working around in your solution, but it sounds somewhat similar to what I’ve been doing. In V1 I’ve been creating a UI model that creates a row by default and just set up formula fields that each get the params with {{$Param.ParamName}}

The reason I’m using this method in the first place is to capture the inner parameters passed to a page include instead of the outer parameters at the top of the window. {{$Param.ParamName}} seems to get inner parameters, whereas using a page parameter condition on the model gets the outermost / top / base URL parameters.

There’s a strange bug I’ve discovered that you might run into with this method, which is if you have any models querying on page load that use field from another model and reference your UI parameter model’s fields, it can error. To prevent this I’ve generally been querying models not on page load but slightly after using an action sequence that runs on page render.

Hello csilva,

What are you doing in javascript that requires the page parameters? It can be a bit difficult since they can conflict between and parent and a child, but the method of using a ui-only model with fields & defaults reflecting the params is one I’ve used, similar to what Mark outlines.

If it needs to be in JS, you do have access to the parameters in V2, but it may take an extra step. The method skuid.page.getParameters() will give you the parameters directly on the current page, but if you pass in the page’s id it’ll give a bit more info. This may change, but skuid.page.getParameters(skuid.page.pageComponentId) will currently return additional parameters on the page, including the actual page parameter if it’s being used in a page include.

Using V2. As of right now, the only way I have to pass the parameters is by creating an UI only model and performing actions to pass the information by. Now I’m on the fight to correctly load the SO model with the information given. My last ended in a forever loop.

When it comes to this challenge, context is everything. For example,

skuid.model.map()

current page

page.model.map()

the loaded page

Also there are some examples showing the page name as a parameter for map, but that is incorrect.

With the UI model I managed to get the parameter, load the page based on that parameter, get the models from that page based on everything passed.

It does feel like you are jumping into hoops just to get information out of the system.