CA Service Management

  • 1.  Help on Conditional Select Field Options

    Posted 09-17-2018 02:47 PM

    Hi guys!

     

    Is it possible to condition the ca_reportQuery based on the selection of ca_fdGetSelectedOptionValues to display another select field?

     

    I need to display all municipalities of the Brazilian states based on the pre-selection of this state.

     

    I created the report for each state and its municipalities, however I'm not sure how to condition this report and use it in a new ca_fdGetSelectedOptionValues.

     

    Has anyone ever had to do this?   

     

    I use the javascript below to show and hide some fields, however I'm not sure how to condition the use for new selects ca_fdGetSelectedOptionValues.

     

    {
         showLabel: function () {
              var estado = ca_fdGetSelectedOptionValues(ca_fd.formId, 'ca_sdm_attr_z_str_estado');

              if (estado == 'Distrito Federal') {
                   ca_fdHideField(ca_fd.formId, 'predio_descentralizadas');
                   ca_fdHideField(ca_fd.formId, 'sala_descent');
                   ca_fdShowField(ca_fd.formId, 'predio');
                   ca_fdShowField(ca_fd.formId, 'sala');
              }
         }
    }

     

    Many thanks!



  • 2.  Re: Help on Conditional Select Field Options

    Posted 09-17-2018 05:23 PM

    Hi Diego,

     

    You can pass variables into select components powered by data object, is that what you're trying to do?

     

    1. onChange of the first select field, refresh the second select field so that it pass in the updated variables

    ca_fdFetchSelectData(ca_fd.formId, 'select1');

     

    2. Pass the value of the first select into the second select using the Report/Plug-in Variables attribute.

    Example: $({'value':ca_fdGetSelectedOptionValues(ca_fd.formId, 'select1')[0]})



  • 3.  Re: Help on Conditional Select Field Options

    Posted 09-18-2018 08:57 AM

    Hi gbruneau!


    I was thinking of something using the ca_reportQuery option, which will condition the display of this report based on the selected option in the first ca_fdGetSelectedOptionValues.

     

    I have unfortunately never used ca_reportQuery and really do not quite understand how it should be used.

     

    Many thanks again!!



  • 4.  Re: Help on Conditional Select Field Options

    Posted 09-18-2018 09:00 AM

    Hi Diego,

     

    You can conditionally hide/display fields based on returned data from ca_reportQuery. What do you mean by conditionally display report? If you can help me understand the use case I might be able to provide an example.



  • 5.  Re: Help on Conditional Select Field Options

    Posted 09-18-2018 09:34 AM

    Hi gbruneau!

     

    Sorry if i was not clear enough!


    I know the script below does not make much sense, but I was thinking of something like that to display the fields and their associated reports.

     

    See if you can understand a little what I'm trying to do:

     

    {
         showStatePlugin: function () {
              var state = ca_fdGetSelectedOptionValues(ca_fd.formId, 'ca_sdm_attr_z_str_state');
              if (state == 'state1') {
                   ca_fdShowField(ca_fd.formId, 'city1');
                   ca_reportQuery('city1', reportInput, function (rows) {
                        myFunc(rows, formId, additionalArg)
                   }, null);
              }
              if (state == 'state2') {
                   ca_fdShowField(ca_fd.formId, 'city2');
                   ca_reportQuery('city2', reportInput, function (rows) {
                        myFunc(rows, formId, additionalArg)
                   }, null);
              }
         }
    }


  • 6.  Re: Help on Conditional Select Field Options

    Posted 09-18-2018 09:46 AM

    Just want to clarify, ca_reportQuery will run a data object (sql query) or java plugin and return a list of results. You can parse these results and put them in a table, text area, or conditionally show/hide fields. In your case what data did you want to conditionally display?



  • 7.  Re: Help on Conditional Select Field Options

    Posted 09-18-2018 10:06 AM


    Based on the state selection, which is also a plugin, I need to display the cities associated with it.

     

    For example, if the customer selects the Ohio option I need to invoke my Ohio cities reports and display the options for this report in a select field.

     

    I'm not sure how to call this report and display this data correctly.

     

    I created 27 new objects of each, one for each Brazilian state/cities, as shown below:

     

     

    Each report date shows the cities of a specific state, I figured that using the ca_reportQuery option I could invoke all 27 plugins from each city and display them conditionally according to the state's choice.

     

    This state option for example is already used to show and hide some custom fields in some forms as well.

     

    showLabel: function () {
         var state= ca_fdGetSelectedOptionValues(ca_fd.formId, 'ca_sdm_attr_z_str_state');

         if (state == 'Distrito Federal') {
              ca_fdHideField(ca_fd.formId, 'predio_descentralizadas');
              ca_fdHideField(ca_fd.formId, 'sala_descent');
              ca_fdShowField(ca_fd.formId, 'predio');
              ca_fdShowField(ca_fd.formId, 'sala');
         }
         if (state != 'Distrito Federal') {
              ca_fdHideField(ca_fd.formId, 'predio');
              ca_fdHideField(ca_fd.formId, 'sala');
              ca_fdShowField(ca_fd.formId, 'predio_descentralizadas');
              ca_fdShowField(ca_fd.formId, 'sala_descent');

         }
    }

     

    I would just like to use these options to condition the display of new fields and invoke the ca_reportQuery of each of these fields.



  • 8.  Re: Help on Conditional Select Field Options

    Posted 09-18-2018 10:22 AM

    I see what you're trying to do you. Instead of having 27+ hidden fields you might be able to use a single City select field which accepts input from the state field. In this case you wouldn't need to use the reportObject functions but simply use the report/plugin variable attribute to pass the value to a single data object.

     

    Can you share a few of your data object queries so I can see if this method is a possibility?



  • 9.  Re: Help on Conditional Select Field Options

    Posted 09-18-2018 11:33 AM


    Yes, I can gbruneau!

     

    But it's not necessarily a query from database.

     

    The data object I created is a csv file that will show me all cities:

     



  • 10.  Re: Help on Conditional Select Field Options

    Posted 09-18-2018 11:44 AM

    I forgot about the CSV option, in that case you can't use the variables.. It looks like you'll have to have one select field for each data object and a bunch of else if statements to hide/show the proper field. reportQuery won't help you here as it won't allow you to programatically fill a select field, there's an an active idea for a similar functionality here