dynamicPage params not being passed to nextPage

In writing a custom app, I ran into what I believe to be a bug in the Hubitat.

I use the params argument of href, and dynamicPage to pass-around the parameters provided by the caller. This work in every aspect of my code, except on.

def appDiscovery(params) {
    def networkId = params?.netId
    if (!networkId) return mainPage()
    
    def child = getChildDevice(networkId)
    if (!child)
        return mainPage()
    
    def apps = child.getInstalledApps()

    log.debug "Sending: ${params}"
    return dynamicPage(name:"appDiscovery", title:"Discover Apps", nextPage:"installApps", params: params) {
        section() {
            paragraph ""
        }
        section("${child.label} Applications") {
            input "${networkId}_selectedApps", "enum", title: "Select Roku Apps to publish and child devices", required: flase, multiple: true, options: apps, submitOnChange: true
        }
    }
}

def installApps(params) {
    // For some reason, params always arrive as null in this function
    // def networkId = params?.netId
    // if (!networkId) return mainPage()
    log.debug "Received: ${params}"
    def nids = apps.collect { key, value -> key}.findAll { child.getChildDevice(it) != null }

    def selected = settings["selectedApps"]
    selected.each { networkID ->
        
    }
    
    return dynamicPage(name:"installApps", title:"Updating child devices", nextPage:"mainPage") {
        section() {
            paragraph "Nothing to do"
        }
    }
}

In appDiscovery(params) I receive the params and can log them. On submit, the params are retained, and no matter how many times I submit on the input method, params is retained. But, when installApps(params) is called, 100% of the time, the new variable is null. In my logs, I can see this to be the case:
image

The installApps() dynamic page is the 3rd deep in a chain of receiving and passing the params via this same technique.

Is this a bug, or am I not doing this right?

It would seem to be affect passing of params only on the 4th page or deeper. @mike.maxwell or @bravenel, is there a limit to how deep application dynamic pages can go that would explain why all 4th page and lower only receive null for params?

Even when explicitly set in the href or dynamicPage as a constant map, the values are not received by the target page, if the target page is a 4th layer deep page.

We will look into this.

Thanks. I'm sure it is something I am doing, but I am not seeing what I could possibly be doing that would be be cause, nor why it only happens on the 4th page deep. I have two dynamic pages with this problem, and bother are at the 4th level of depth.

What do you mean by "is called". Params are passed by an href.

If you are talking about returning to a page from inside, the params are gone. You have to put them in state for this situation.

I think I see the problem. I had seen code where params was defined as an argument to the dynamicPage function. As such, I was trying to use that, to pass the params to the next page. Apparently, that is not really an option, and the system just ignores the argument. I just looked up dynamic page on the ST docs to learn it was not available. Looks like I will have to persist state to pass arguments to the next page, since this does not appear to actually be a feature.

This is part of the problem with have to reverse engineer the documentation as I go. What I can surmise about the system is only as good as the examples I can find.

The documentation is a wiki. Please contribute...

2 Likes

Happy to. I have asked for access in the past. It says I need a login to make changes. Thanks!

I see we can create accounts now. Thanks! I will work on adding to the documentation what I learn.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.