remedy

How to Print a Join Form?


Having difficulty figuring out how to print the contents of a Join form in BMC Remedy 9.0. Remedy's docs only explain printing Reports, not Join forms. I would like to either be able to print using Ctrl-P or by an internal Remedy process/action link. My Join form contains mostly character fields. Print preview truncates at the first ~20 px of height, despite a page width: 915 px and height: 1000 px. Does anyone know how I can print forms in the browser?


Solution

  • Figured out how to this - if you place all the content inside a Remedy panel object via the WYSIWYG, then you can add a script in the Web Footer to set the document.body.innerHTML equal to the panel's innerHTML. This little trick organizes the elements in a way that makes the page printable using window.print() or Ctrl-P. Be warned, though, that this innerHTML assignment often corrupts or loses properties like child textarea or input values. So you must scrape for these values and append them back to the page before printing.

    <div>
        <script>
    
        function myPrint() 
        {
            var idTexts = [];
            var textareas = document.querySelectorAll('textarea[id][readonly]');
    
            for(var i = 0; i < textareas.length; i++)
            {
                idTexts.push(textareas[i].id);
                idTexts.push(textareas[i].value);
            }
    
            var inputs = document.querySelectorAll('input[id][readonly]');
    
            for(var i = 0; i < inputs.length; i++)
            {
                idTexts.push(inputs[i].id);
                idTexts.push(inputs[i].value);
            }
    
            //Assume there is only one panel object, so only one .pnl class on the page
    
            var printContents = document.querySelector('.pnl').innerHTML;
            document.body.innerHTML = printContents;
    
            for(var i = 0; i < idTexts.length; i++)
            {
                if(document.getElementById(idTexts[i]))
                {
                    document.getElementById(idTexts[i]).value = idTexts[i+1];
                }
            }
    
            window.print(); 
        }
    
        /*On page load, I noticed the click event fired for a visible button
        without the user actually needing to click. 
        Will not work unless the button's visibility is set to true (Remedy is a weird creature).
        Used the setTimeout to allow time for the initial page load, as the onload event fired too early.
        If you don't want this button to appear on the page when it is printed
        overlay a transparent image on the button's display properties.*/
    
        document.querySelector('a[ardbn="btnPrintMe"]').onclick = setTimeout(function(){ myPrint(); }, 500);
        </script>
    </div>
    

    If you still have problems printing, make sure this btnPrintMe button has at least the correct 6 privileges: 1101/-1101, 1102/-1102, 1103/-1103 and the user you are testing this with has the appropriate privileges as well.