Setting Cascading Fields Fails

cdaringe
edited February 11, 2022 in Analytics #1
<p>Hi all,</p>
<p> </p>
<p>I am new to actuate.  I have inherited a codebase and am still wrestling on coming up to speed w/ the JSAPI.</p>
<p> </p>
<p>The problem is that when I set my form/report parameters, the cascading fields do not get set, and instead just use the default.</p>
<p> </p>
<p>I am running 3.1.x.</p>
<p> </p>
<p>Our initialization of a parameter set for a report looks roughly as follows:</p>
<pre class="_prettyXprint _lang-js">
var values = { someField: someValue, someCascadingParam: someCascadingValue }
var param = new actuate.Parameter("actuateparams")
param.downloadParameters(function (paramDefs) {
// some other init code ..., hidden!
viewer.setParameters(values)
param.renderContent(paramDefs, function () {
// parameter form updated!
// however, my cascading value is not set properly in the form.
// in fact, i dont think the value have even been downloaded yet,
// as I see a SOAP request in the network tab requesting value sets.
// also, the parent field is properly set :)
})
})
</pre>
<p>I don't have a good means to share a runnable example, but if there is a way to do so, I'd be happy to try if someone would provide some guidance.</p>
<p> </p>
<p>Thanks for your time!</p>
<p> </p>
<p>Chris</p>

Comments

  • <p>With cascading parameters and JSAPI, the solution is to call <strong>overwriteParameterDefProperties() </strong>after setting the values of the parameters. </p>
    <p> </p>
    <p>The process is:</p>
    <ol><li>Get the parameter definitions</li>
    <li>Set the parameter values</li>
    <li>overwriteParameterDefProperties</li>
    <li>Download the parameter definitions again and renderContent</li>
    </ol><pre class="_prettyXprint">
                function afterInit() {
                                        params = new actuate.Parameter("ReportParamDiv");
                                        params.setReportName("my.rptdesign");
                                        params.downloadParameters(getParamDefs);
                }

                function getParamDefs(paramDefArray) {
                            parameterDefs = paramDefArray;
                            setParams(); //sets the values of the parameters, values are provided somehow, e.g. passed in the url
                            params.overwriteParameterDefProperties( parameterDefs );
                            params.downloadParameters( renderContent );
                }

                function renderContent( paramDefs ) {
                            params.renderContent( paramDefs );
                }</pre>
    Warning No formatter is installed for the format ipb
  • cdaringe
    edited April 3, 2017 #3
    <p>Thanks Clement, I'm trying this now.</p>
    <p> </p>
    <p>I'm assuming `setParams` in your script is really `<span style="color:rgb(0,0,136);">viewInstance.setParameters`?  Just want to clarify.  Thanks</span></p>
  • <p>Thanks Clement!  I think that will meet my needs.</p>