Bug in Dynamic pages with parameters and submitOnChange

(www.rboyapps.com - Make your home your butler!) #1

@Jim @jody.albritton @slagle

Another one:

According to the docs, for using dynamic pages with parameters

page-params-by-href.groovy shows how to pass parameters to dynamic pages using the href element.

So here’s the bug. When passing a parameter to a page, example:

def hrefParams = [
        user: i as String
href(name: "unlockActions", params: hrefParams, title: "Click here to define actions", page: "unlockActionsPage", description: "", required: false)

Now on the unlockActions page (dynamic):

def unlockActionsPage(params) {
	def user = params.user ?: ""

        log.debug "user:$user"

    dynamicPage(name:"unlockActionsPage", title: "unlock actions" + (user ? " for user $user" : ""), uninstall: false, install: false) {
            section {
                    input "individualDoorActions${user}", "bool", title: "unlock actions for each door", required: true,  submitOnChange: true

When doing a submitOnChange: true and the page refreshes the param passed to the page is lost and the user shows up as null. That should not be the case, it should retain any parameters passed to it.

Rule machine - as per the app developer, this app is no longer available for new installs, distribution, or support
(Jody) #2

Do you have a support ticket open about this? I am tracking several tickets about submitOnChange with the cloud team. If you have a ticket number, send it over to me in a PM and I will add it to the list.

(www.rboyapps.com - Make your home your butler!) #3

Hmm no. Actually I was going to ask this question to @Jim but maybe you or anyone can answer it.
When I come across bugs like this one or the one I tagged to Jim about the named attribute not working on input dynamic variables, who’s the right person to tag and the owner? Should I report to support or someone on teh forum. If so, who?

(Mike Maxwell) #4

I noticed this about two months ago, and thought it was a “feature”…

(www.rboyapps.com - Make your home your butler!) #5

Response from support: :smile:

We’re going to pass this along to somebody from our dev platform team for you. Thanks for pointing it out!

(www.rboyapps.com - Make your home your butler!) #6

Ticket #183603

(Jody) #7

I have added this to the internal tracking system @RBoy.

(Sean Kendall Schneyer) #8

Ugh, this just bit me as I was trying to improve my setup for my Ecobee SmartApp and couldn’t get the params to do what I expected. Jumped over here to the forums and see that I’m not the only one having this issue.

I’m going to work around it using a state.XXX parameter but that just clutters up the data stored permanently when I really only need it temporarily.

(Jared Fisher) #9

I’ve also run into this problem, but just used a workaround until SmartThings decides it’s worth addressing themselves.

I’ve placed the logic inside a helper function, so make things more readable, you can implement as makes sense for your code.

def persistPrefParams(params) {
    if (params?.pref)
        state.pref = params.pref

In your original page’s href input:

href(name: "urlSettingName"
     title: "Configure Setting",
     description: "Click to edit setting...",
     page: "pageConfigASetting",
     params: [ pref: [value1: "${val1}"]]

Your target page’s method will look like:

def pageConfigASetting(params) {
    dynamicPage(name: "pageConfigASetting",
                title: "Config This Setting",
                install: false,
                uninstall: false) {
        section {
            ["pushed","held"].each { event ->
                href(name: "pageConfigASetting${getVal1()}${event}",
                     title: event,
                     page: "pageConfigEvent",
                     params: [ pref: [value1: "${getVal1)}", value2: event]])

Then as you can see, I used a helper method to grab a specific val from the state:

def getVal1() {

def getVal2() {

Just don’t start trying to use the helper methods outside of the dynamic page, as they are only meant for the last created dynamicPage. You might end up wondering why you’re event handler is only processing a setting based on the value you last updated in your pref’s.

Edit: Apologies for the edits, had to figure out the code markup.