• Dave Wakeman
    May 13, 2016 at 9:50 am #1780

    I am working on a new coach view of my own that uses a couple of SPARK coach views, including the Button control.  I want to provide a configuration option on my coach view so that the consumer of my coach view can provide the label for the button using a formula that references other coach views on their coach.  My coach view has no knowledge of what is on the coach consuming it, so I put a configuration option in my coach view called “buttonLabel” (String) and I set the Label Formula button on the SPARK button coach view to the variable for my config option.

    That doesn’t seem to be working.  If I put a static string in quotes in the config option in the coach then it works, but when I put:


    in the config option I get an error in the browser console saying that “page.ui.get(..) is undefined”.  When I try ${buttonLableContent1}.getText() in the field then it throws a warning in the log saying the control can’t be found.  I tried ${../buttonLableContent1}.getText() but that didn’t seem to work either.

    How can I create a coach view that has a config option that is a formula, and when (and in what context) does the formula run?  Does it run in the consumer’s context or the context of my coach view?



    May 13, 2016 at 10:30 am #1781

    Hey Dave,

    You should bind your buttonLabel variable to the label of the button instead of the formula option. The variable should also exist on the coach level, and be passed into both the coach view with the button, and the coach view that sets the text for the button.

    The screenshot I’m attaching show 2 coach views. The first one has a text control that is bound to the same variable as the label for the button.


    Erick Quintanilla

    Dave Wakeman
    May 13, 2016 at 10:40 am #1784

    I did have the variable bound to the button label instead of the label formula at first, but that leads to another question.  Can the consumer of my coach view put javascript into my config option?  Will it still resolve something like ${mybuttonLabelContent}.getText()?  My original thought was that perhaps the consumer of my coach might want to manipulate/generate the label text dynamically.  In my coach view I could just put some formula in the Label Formula config option for the button and it would work.

    Am I able to provide that same feature as a “pass thru” config option from my coach view to the button?  The button may not be the best example of where it makes sense to use a formula, but lots of SPARK controls have formulas so I am sure I will want to do it at some point.


    Rackley Boren
    May 20, 2016 at 1:41 pm #1825

    Hi Dave,

    Yes, you should be able to pass the JavaScript through to the control. At the end of the day, the formula config options are text based and what ever you bind to “Text Expression” whether that is a hard coded value or bound to a string variable it will be evaluated through the framework.

    I set up a small example for myself to try this out to see what you might be running into, and I found the likely issue you were running into is improper control addressing. When you are passing the ${[controlId]}.getText() to the config option for your control in the coach view, you have to keep in mind that it will then be calling the code from that spot in the address tree. In this case from inside the coach view instead of the addressing being evaluated from the top down, you are starting bottom up. Since there is a coach view containing this control, that means you have a subview in between the control and the coach page.

    If I am going to call a control that is outside the coach view that knows nothing about it, I have to adjust my addressing to get to it. Most likely for your case you need ${../controlId}.getText() will do the trick since I am assuming you just have the one subview in the tree. Take a look at the Addressing article in our knowledge base for more information.

    In this set up there is no need for additional private variables on the parent view or coach page level, unless you are trying to pass in something that was set up on the server side prior to the coach loading.

    I am going to set up a KB article around this once I get validation on my thoughts around it.


    Rackley Boren


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Start typing and press Enter to search