CA Service Management

Expand all | Collapse all

How to get selections from a Selection Option component in a form?

  • 1.  How to get selections from a Selection Option component in a form?

    Posted Sep 19, 2017 10:05 AM

    Hi! We need to get the selected options from a selection option component used in a form through the script. We tried with ca_fdGetSelectedOptionValues and ca_fdGetTextFieldValue but we got "null" and "undefined" every time we use it.

     

    The code in the script is:

    {
    empaquetaSolicitud : function() {
    var resultado = '';
    resultado = 'Ubicaciones Origen: ' + ca_fdGetSelectedOptionValues(ca_fd.formId,'cmbubiorigen') + '\n\nUbicaciones Destino: ' + ca_fdGetSelectedOptionValues(ca_fd.formId,'cmbubidest');

    ca_fdSetTextFieldValue(ca_fd.formId,'ca_sdm_attr_description',resultado);
    return true;
    },
    }

     

    Regards

    Sebastian



  • 2.  Re: How to get selections from a Selection Option component in a form?

    Broadcom Employee
    Posted Sep 20, 2017 02:18 AM

    Good Morning Sebastian.

     

    Although I am not a 'java script expert', I found the below example that can possibly, help you further.

     

         getMatrixDesc: function() {
     
            var selected = ca_fdGetSelections(ca_fd.formId, 'ca_sdm_attr_z_error')[0].data;
           
            if (selected.matrixdesc == '' && selected.kbid  == '' && selected.desctemplate == '') {
              ca_fdSetTextFieldValue(ca_fd.formId, 'lbl_procedimento', '')
              ca_fdSetTextFieldValue(ca_fd.formId, 'ca_sdm_attr_description', '');

     

            }
            else {
                  var _lblHtml = [];
                  _lblHtml[0] = '<div id="procedimento">';
                  _lblHtml[1] = selected.matrixdesc;
                  _lblHtml[2] = (selected.kbid != '') ? '<br><br><b>***:</b><a style="color: #0979A5;" href="javascript:ca_fd.js.getKbdoc(' + selected.kbid + ')"> ' + selected.title + '</a><br><div id="kbdoc"><br></div></div>' : '</div>' ;
                  ca_fdSetTextFieldValue(ca_fd.formId, 'lbl_procedimento', _lblHtml.join(''));
                  ca_fdSetTextFieldValue(ca_fd.formId, 'ca_sdm_attr_description', selected.desctemplate);
            }
                
         },

     

    Thanks and kind regards, Louis.



  • 3.  Re: How to get selections from a Selection Option component in a form?

    Posted Sep 20, 2017 03:40 PM

    Hi Louis, thank you very much for your help! Unfortunately that code didn't work.



  • 4.  Re: How to get selections from a Selection Option component in a form?

    Posted Sep 20, 2017 10:16 AM

    Not sure if I translated this properly, but the following should work if I'm understanding this correctly (can obviously change that final result to however you wanted that string formatted):

     

    {
    packagesApplication: function () {
        var locations = ca_fdGetSelections (ca_fd.formId,'cmbubiorigen');
        var result1 = "";
        for (var i = 0; i < locations.length; i++) {
            var result1 = locations[i].label;
        }
        var destination = ca_fdGetSelections (ca_fd.formId,'cmbubidest');
        var result2 = "";
        for (var i = 0; i < destination.length; i++) {
            var result2 = destination[i].label;
        }
        var result = result1 + "\n\nLocations Destination:" + result2;
        ca_fdSetTextFieldValue(ca_fd.formId,'ca_sdm_attr_description',result);
    },
    }


  • 5.  Re: How to get selections from a Selection Option component in a form?

    Posted Sep 20, 2017 11:15 AM

    Actually the following may work w/ single selects, not requiring the loop, not far off from what you had originally:

     

    {
    packagesApplication : function () {
        var result = ca_fdGetSelectedOptionValues(ca_fd.formId,'cmbubiorigen')+"\ n\ nLocations Destination:"+ca_fdGetSelectedOptionValues(ca_fd.formId,'cmbubidest');
        ca_fdSetTextFieldValue (ca_fd.formId,'ca_sdm_attr_description',result);
    },
    }
    (That +"\ n\ nLocations Destination:" string will appear all as one, if you wanted the line breaks change to "\n\n"+"Locations Destination:")


  • 6.  Re: How to get selections from a Selection Option component in a form?

    Posted Sep 20, 2017 03:45 PM

    Hi Shomer, i tried your code but i get the results in blank for example:

    "

     

    Locations Destination:                                 "

     



  • 7.  Re: How to get selections from a Selection Option component in a form?

    Posted Sep 22, 2017 11:52 AM

    Can you try calling ca_fdGetSelectedOptionValues from the browser console (shift+ctrl+i in Chrome/Firefox) similar to the following:

     



  • 8.  Re: How to get selections from a Selection Option component in a form?

    Posted Sep 22, 2017 02:34 PM

    Hi Jason, I tried but I got nothing. The variable is called through the on submit javascript code.



  • 9.  Re: How to get selections from a Selection Option component in a form?

    Posted Sep 22, 2017 03:23 PM

    Can you confirm how the select field is populated, how the option(s) are selected and when you are calling ca_fdGetSelectedOptionValues?



  • 10.  Re: How to get selections from a Selection Option component in a form?

    Posted Sep 28, 2017 02:36 PM

    Yes, I fill them like this:

     

    And they are used from the form like this:

     

     

    the user can select 1 or multiple options and I need to get the selected options through the form script.



  • 11.  Re: How to get selections from a Selection Option component in a form?

    Posted Oct 30, 2017 04:40 PM

    Jason_Wolfe - Do you have any further insight for sperna on this one?



  • 12.  Re: How to get selections from a Selection Option component in a form?

    Posted Nov 01, 2017 11:17 AM

    Hi Jon, thanks for the follow up! I opened a case and we are still working on it without luck



  • 13.  Re: How to get selections from a Selection Option component in a form?

    Posted Nov 03, 2017 10:06 AM

    Thanks Sebastian - can you post the case number here for us?

    What we will do is mark this one answered for now, and then once we get the solution on the case, we can then post the solution here as well.

    Regards,

    Jon



  • 14.  Re: How to get selections from a Selection Option component in a form?
    Best Answer

    Posted Nov 07, 2017 09:11 AM

    yes:

    CA Support Case 00864782



  • 15.  Re: How to get selections from a Selection Option component in a form?

    Posted Nov 30, 2017 03:50 PM

    Finally it was a weird problem with the objects i was using. i deleted the form and the objetcts and everything went ok

     

    Thanks all for your help!