CA Service Management

 View Only

  • 1.  Hide/display the text field in detail form

    Posted Feb 10, 2017 05:59 AM

    Hi Community,

     

    I would like to display/hide a text box in  "request_status_change.htmpl"  depends on the status value of a request ticket.

    looking for some inputs/reference If some one achieved same functionality.

     

    Thank you,

     

    Regards,

    Venkat



  • 2.  Re: Hide/display the text field in detail form

    Posted Feb 10, 2017 06:29 AM

    Hi Venkat,

     

    I think this should be easily be done with a <PDM_IF> wrapped around the field in question on the form.

     

    Kind Regards,

    Brian



  • 3.  RE: Re: Hide/display the text field in detail form

    Posted May 28, 2025 02:23 AM

    Hi Team,

    How can we implement this by using the PDM _IF?

    Could you please provide the commands.

    Our Requirement is : We need to hide the custom resolution summary field to be enabled only when user select the status as "Resolved". How can you do it please provide me the steps to do, Thank You!




  • 4.  Re: Hide/display the text field in detail form

    Posted Feb 10, 2017 06:37 AM

    you're correct but, analyst has to extra click 'save' to see the text filed to be available in detail form. looking for more robust solution same as 'self-service Include' and 'Self-service symbol" in detail_pcat.htmpl. Where the self-service symbol is hide/unhide depends on the value of self-service include' value.



  • 5.  Re: Hide/display the text field in detail form

    Posted Feb 10, 2017 07:27 AM

    Then I think you will need to script it using ajax code and/or put some on change event on the status field

    my 2 cents

    /J



  • 6.  Re: Hide/display the text field in detail form

    Posted Feb 10, 2017 08:26 AM

    Hi jmayer,  any reference or example on constructing ajax call.



  • 7.  Re: Hide/display the text field in detail form

    Posted Feb 10, 2017 09:13 AM

    Have a look to Turker answer

    I think it make it simple in your case.

    if not we can then look to the ajax. you will see many example of those in sdm source code

    /J



  • 8.  Re: Hide/display the text field in detail form

    Posted Feb 10, 2017 08:40 AM

    Hi Venkat,

     

    I share my coder for this case how hide/show element by status field change. We used for show/hide affected_resource field.

     

    First you can define a id for element for which you hide/show elements like,

     

    <PMD_MACRO name=dtlLookup hdr="Affected Resource" attr="affected_resource">
    var affected_resource_id = _dtl.currID;

     

    Then define a function hide/show this elements under <head> tags

    function hideShowCI()
    {
       if (document.main_form.elements["SET.status"].value == "CLREQ")
       {
          detailShowElements(affected_resource_id ,1);
       } else {
          detailHideElements(affected_resource_id,1);
       }
    }

     

    When page is loading if you can hide this element you enter codes loadActions() function

     

    function loadActions()
    {
       detailHideElements(affected_resource_id,1);

     

     

    Last, you can define hideShowCI() function to put onChange attribute of status field like

     

    <PDM_MACRO name=dtlDropdown hdr="New Status" evet="onBlur=\\\"detailSyncEditForms(this)\\\" onchange=\\\"hideShowCI()\\\"" factory=crs_in lookup=no>

     

     

    I hope its your need.

     

    Regards,

     

    Turker



  • 9.  Re: Hide/display the text field in detail form

    Posted Feb 10, 2017 09:48 AM

    Hi birolturker.kara

    do we need to define detailShowElements function , hide element is working as expected but detailShowElements is not parsing getting the below error.

    Uncaught ReferenceError: detailShowElements is not defined(…)

     

    Regards,

    Venkat



  • 10.  Re: Hide/display the text field in detail form
    Best Answer

    Posted Feb 10, 2017 09:57 AM

    You can use the following function

     

    function detailShowElements(id, count, new_first_id)
    {
       count = 2 * count;
       var e = document.getElementById(id);
       var hiddenElements = new Array();
       if ( e != null ) {
          var td = e.parentNode;
          var tr = td.parentNode;
          var rows = tr.parentNode.childNodes;
          var found = false;
          for ( var i = 0; i < rows.length; i++ ) {
             if ( tr == rows[i] ) {
                for ( var col = 0; col < tr.childNodes.length; col++ ) {
                   if ( tr.childNodes[col] == td ) {
                      found = true;
                      break;
                   }
                }
                break;
             }
          }
          if ( found ) {
             for ( ; i >= 0; i-- ) {
                if ( typeof rows[i].childNodes == "object" &&
                     rows[i].childNodes.length > col ) {
                   e = rows[i].childNodes[col];
                   hiddenElements[hiddenElements.length] = e;
                   e.style.display = "";
                   if ( typeof _dtl.firstField != "object" ||
                        _dtl.firstField == null ||
                        typeof _dtl.firstField.parentNode != "object" ||
                        e == _dtl.firstField.parentNode )
                      if ( typeof new_first_id == "string" )
                        _dtl.firstField = document.getElementById(new_first_id);
                   count--;
                   if ( count <= 0 )
                      break;
                }
             }
          }
       }
       adjScrollDivHeight();
       return hiddenElements;
    }