CA Service Management

Expand all | Collapse all

Put "Attach Document" in menubar

Jump to Best Answer
  • 1.  Put "Attach Document" in menubar

    Posted 01-26-2016 12:54 PM

    Hi everyone,

     

    I need to put the "Attach Document" command (from Attachment tab) into menubar in detail_cr.htmpl form. However, no matter what I do, the JavaScript calling does not work.

     

    Here is my code in menubar_sd_l2_analyst.htmpl:

     

    <PDM_OBJECT>
    function do_attach_doc() {
       var add_file_src = "View=Upload+ShowFields=Yes+ShowImgStatus=Yes+ShowRepList=Yes+RepType=0+KEEP.POPUP_NAME=" + top.name + 
                          "+KEEP.PARENT_DIV=" + window.frameElement.parentNode.id + "+KEEP.attmnt_parent=$args.persistent_id";
       AddFile(0, 0, 0, add_file_src, 50 );
    }
    <PDM_MACRO name=menuItem label="Attach_File" function="JavaScript: do_attach_doc()" icon_name="Attachment_16.png" tooltip="anexar arquivo">
    </PDM_OBJECT>
    

     

    Note: the do_attach_doc function is from xx_attmnt_tab.htmpl.

    Note 2: the Attach_File item is inside "Activities" menu.

     

    When I try to click on Attach_File menu item, nothing happens and I get the following error: "ReferenceError: do_attach_doc is not defined". Already tried to execute AddFile without the do_attach_doc, without success. I tried with the "Attach Document" code from detail_cr in analyst/employee too, no success neither.

     

    Any ideas?



  • 2.  Re: Put "Attach Document" in menubar
    Best Answer

    Posted 01-27-2016 03:35 AM

    hi,

    better way to move your function directly to detail_***.htmpl form,

    for simplify the distribution, you can create file and then include it to derived forms:

         xx_attmnt_include.htmpl:

    <PDM_IF 0>
    // not tested
    </PDM_IF>
    <script type="text/javascript" src="$CAisd/scripts/attmnt_lib.js?20151101"></script>
    <script type="text/javascript" src="$CAisd/scripts/attmnt_upload.js?20151101"></script>
    <script type="text/javascript">
    function add_attmnt() {
      var add_file_src = "View=Upload+ShowFields=Yes+ShowImgStatus=Yes+ShowRepList=Yes+RepType=0+KEEP.POPUP_NAME=" + ahdframe.top.name + 
      "+KEEP.PARENT_DIV=" + ahdframe.window.frameElement.parentNode.id + "+KEEP.attmnt_parent=";
      add_file_src += ahdframe.argPersistentID;
      AddFile(0, 0, 0, add_file_src, 50);
    }
    </script>
    

     

         detail_xx.htmpl:

    note: put somewhere in <head> area beyond <script> tag

    <PDM_INCLUDE FILE=xx_attmnt_include.htmpl>
    

     

         menubar_xx.htmpl:

    <PDM_OBJECT>
    if ( (factory_new == "detail_cr.htmpl") || (factory_new == "detail_chg.htmpl") || (factory_new == "detail_in.htmpl") ) {
      <PDM_MACRO name=menuItemLocal label="Add attmnt" function="ahdframe.add_attmnt()" icon_name=new_attmnt_16.png tooltip="Add attmnt">
    }
    </PDM_OBJECT>
    

     

    I have limited menubar item with some contstraint to make it available only on active Request/Incident/Change forms.

     

    Regards,

    cdtj



  • 3.  Re: Put "Attach Document" in menubar

    Posted 02-10-2016 03:42 PM

    Hi cdtj

     

    I tested here, but unfortunately, it didn't work... Did you test this? Thanks!



  • 4.  Re: Put "Attach Document" in menubar

    Posted 02-11-2016 11:57 AM

    Hi Diogo,

    it worked in my test env in SDM 12.7 CP2, as far as I know 14.1 uses new alogrithm if you on it,

    check browsers console and stdlog is there any errors?

     

    Regards,

    Timur



  • 5.  Re: Put "Attach Document" in menubar

    Posted 02-11-2016 01:14 PM

    Hi Timur,

     

    I checked browser console and it showed that "factory_new" was not defined. I tried to put another conditions, such like if ( factory == "cr" ) or PDM_IF "$args.type" == "R" but both was ignored - the menuItem was placed anyway.

     

    So I just removed the "if" condition and it worked!

     

    Thank you.

     

    Diogo



  • 6.  Re: Put "Attach Document" in menubar

    Posted 02-11-2016 01:24 PM

    Just one more little thing... do you know how to "focus" the Attachment tab automatically after sending the file? Is it possible? It would be useful if, when someone sends a file, he/she could see the file in attachments tab.

     

    * this would be useful in another situation too, but focusing another tab.