CA Service Management

 View Only
  • 1.  Values from dynamic Dropdown - how?

    Posted Feb 18, 2015 12:27 PM

    Hi,

    I need a dynamic dropdown (that works) but how can I get the value selected by the customer in the dynamic Dropdown?

    This is my code in an detail_in.htmpl:

     

    // this function creates the arrays with id and name and works (the where is here a sample)

    function z_create_geb()    {

                    //alert("in _create_geb");   

                    <PDM_LIST ESC_STYLE=JS2 prefix=list_g factory=z_geb_sap where="delete_flag=0">

                                   ret_g_name[ret_g_name.length] = decodeURIComponent('$list_g.z_g_name');

                                   ret_g_id[ret_g_id.length]                 = decodeURIComponent('$list_g.id');

                    </PDM_LIST>

                    arr_g_anz = ret_g_id.length;                          

    }

     

    // this code creates the dynamic Dropdown and works also

     

    <PDM_MACRO name=dtlStartRow>

    detailRowHdr("Geb",1,0);

    if (ret_g_id.length > 1) {   

                    <PDM_MACRO name=dtlStartRow>

                    docWriteln('<tr><td align="left">');

                    docWriteln('<select' + detailNextID(true) + '>');

                    for (i = 0; i < ret_g_id.length; i++) {

                                   docWrite('<option value="' + ret_g_id[i] + '" ');

                                   docWriteln('>' + ret_g_name[i] +'</option>');

                    }             

                    docWriteln('</select></td>');

    }

     

    How can I use the selected value ('ret_g_id' or 'ret_g_name')  and store it in the DB??

    Regards



  • 2.  Re: Values from dynamic Dropdown - how?

    Posted Feb 18, 2015 03:04 PM

    Hi.

    First of all you would need an attribute in your cr object where you can store values in. In your case it seems, that you want to store an id. So lets say, your cr object has an attribute named "z_geb_sap_id". All you would have to do is, that the name of your "select" dropdown is equal to "SET.z_geb_sap_id" and you select html element is inside the dtlForm and dtlEnd macro. This would store the selected ret_g_id[] in the z_geb_sap_id attribute of the cr object. Sure, it will not store the ret_g_name[] value. But that's the nature of these things.

     

    What I'm asking myself is, what you would like to achieve? To me it looks like that you want to have a dropdown field, which offers a subset of available records of another table (z_geb_sap), and this should be stored in an attribute of the cr/in object. Correct? Compared to a standard Dropdown, the only difference seems to be the use of a subset of this table, specified by a whereclause, correct?

    If so, I would have a simpler approach for your challange, something like:

     

    <PDM_MACRO name=dtlDropdown hdr="Geb" attr=z_geb_sap_id factory=z_geb_sap whereclause="delete_flag=0" list_display="z_g_name" rel_attr_name="id">

     

    If you would create the z_geb_sap_id attribute as an SREL to the z_geb_sap factory, it would get even simpler, because you could ommit the "factiry", "list_display" and "rel_attr_name" parameters in above pdm_macro line.

     

    Let me know your thoughts, and kind regards.

    ..............Michael



  • 3.  Re: Values from dynamic Dropdown - how?

    Posted Feb 19, 2015 04:27 AM

    Goor Morning Michael,

    short answer, I am not in office.

    I need the result of the dropdown for a second dropdown with a whereclause like "where ($args.z_geb_sap.z_g_name = z_g2_name).

    Means create a subset of the second table with an attribute of the second (z_g2_name) and the result of the first dropdown.

    The z_g2_name is a string object of second table, because I want save the z_g_name (string).

    Your thoughts sound good.

    The way wouldt be: 1. dropdown -> onChange -> function(store the result in DB)

                                 2. dropdown with whereclause from 1. -> function(store result)

                                 3. dropdown with whereclause from 2. ....

                                  4. ....

                                  5.   and so on  ??

    Have I understood your thougths ?

    I will try it on monday and send report



  • 4.  Re: Values from dynamic Dropdown - how?

    Posted Feb 20, 2015 04:36 AM

    Michael is correct: you need fields in the schema to store the information.

     

    I once wrote a wiki on another site on one possibility to implement dependent dropdowns: http://www.servicedeskusers.com/Dependent_dropdowns

     

    It is for an older SDM release, but it should give you some ideas on how to establish the requirements.



  • 5.  Re: Values from dynamic Dropdown - how?

    Posted Feb 20, 2015 04:43 AM

    Hi,

    take a look at Dependent dropdowns article on SDU. It may help you..

     

    Jakub



  • 6.  Re: Values from dynamic Dropdown - how?

    Posted Apr 25, 2016 04:28 PM

    Sorry, unable to access to dependent dropdowns, i think this doc is not available anymore. Does anyone else have it documented?

     

    Regards,

    JOHN



  • 7.  Re: Values from dynamic Dropdown - how?

    Posted Feb 26, 2015 04:10 AM

    Hi,

    thanks to all. I works fine.

     

    Yesterday I made all changes. I used therecommended  link.

    The sample uses the table 'rootcause' and it is no problem the change all for another table.

    Only a change in the schema of the use table is neccessary (insert an atttribut for depented values).

    The data for my table will imported via script, that was updated.

    If your date update via GUI you need a little spel to create the data.

    Thank you all for your help.

    Regards



  • 8.  Re: Values from dynamic Dropdown - how?
    Best Answer

    Posted Mar 31, 2015 10:06 AM

    Hi all,

    after 4 weeks a short additional. All clients are satisfied.

     

    I found an little error in java script:

    change the line: if (tempArr2[1] != prevlevel2) {

    in if ((tempArr2[1] != prevlevel2) || (tempArr2[1] == prevlevel2) && (len2 == -1)) {

    The table entries      A0.B0.C0     [0,0,0]

                                  A1.B0.C1     [1,-1,1]

    break down the java script.

    Because i wrote if ((tempArr2[1] != prevlevel2) || (tempArr2[1] == prevlevel2) && (len2 == -1)) {

     

    After the PDM_LIST I inserted a Sort: all....sort(); because the data were sometimes unsorted and this was the solution without schema update.

    Thanks to all