CA Service Management

  • 1.  Dynamically change "whereclaues" of a dtlDropdown

    Posted Apr 19, 2017 03:23 AM

    Hi everyone

     

    I need something on my change detaill screen, which dynamically changes the "whereclause" of another dtlDropdown item.

     

    by default I have the macro below for z_TestDropdown attribute

     

    <PDM_MACRO name=dtlDropdown hdr="Test Dropdown" attr=z_TestDropdown make_required=yes lookup=no whereclause="z_Code is not null">

     

    I have also another dropdown attribute

     

    <PDM_MACRO name=dtlDropdown hdr="Main Dropdown" attr=z_MainDropdown make_required=yes default="X" evt="onChange=\\\"test_change(this);\\\"">

     

    I'm trying to change the whereclaues of "z_TestDropdown" if the value of "z_MainDropdown"changes but I couldn't achieve it. Is that possible?

     

    Regards

    Utku



  • 2.  Re: Dynamically change "whereclaues" of a dtlDropdown
    Best Answer

    Posted Apr 19, 2017 04:17 AM

    Hi Utku!

    This is not possible because where_clause search performed by pre-processor (HTMPL) and can't be affected via JavaScript, as the way can preload all possible values and then switch dropdown options depending on them:

    function statusReloadRC(value) {
         ahdframe.document.getElementsByName('SET.z_TestDropdown')[0].options.length = 0;
         ahdframe.document.getElementsByName('SET.z_TestDropdown')[0].options[0] = new Option("<Empty>", "", true, false);    
         var i=1;
         if (value == "HOLD") {
              <PDM_LIST PREFIX=list WHERE="description like 'HOLD' AND delete_flag = 0" FACTORY=rc>
                   ahdframe.document.getElementsByName('SET.z_TestDropdown')[0].options[i] = new Option("$list.sym", "$list.id", false, false);
                   i++;
              </PDM_LIST>
         } else if ( (value == "CNCL") || (value == "CLnotRE") ) {
              <PDM_LIST PREFIX=list WHERE="description like 'CNCL' AND delete_flag = 0" FACTORY=rc>
                   ahdframe.document.getElementsByName('SET.z_TestDropdown')[0].options[i] = new Option("$list.sym", "$list.id", false, false);
                   i++;
              </PDM_LIST>
         } else if (value == "RE") {
              <PDM_LIST PREFIX=list WHERE="description like 'RE' AND delete_flag = 0" FACTORY=rc>
                   ahdframe.document.getElementsByName('SET.z_TestDropdown')[0].options[i] = new Option("$list.sym", "$list.id", false, false);
                   i++;
              </PDM_LIST>
         }
    }

     

    Where statusReloadRc(value) should be attached to onchange event.

     

    Regards,

    cdtj



  • 3.  RE: Re: Dynamically change "whereclaues" of a dtlDropdown

    Posted Jun 18, 2019 01:31 PM
    hi cdtj,

    nice solution! 
    one question - if I use it with SREL field type the "value" contains id (foreign key to the SREL table).
    How can I get e.g. the "sym" instead of "id"?


    ------------------------------
    Radek Mihalik
    CZ
    ------------------------------