CA Service Management

Expand all | Collapse all

Displaying count of active attachments in tab

  • 1.  Displaying count of active attachments in tab

    Posted Mar 15, 2016 01:47 PM

    We have implemented a modification to display the attachments tab with a count of the number of attachments so that a person can tell without having to check the attachments tab whether or not there are any attachments to look at.  Below is the modification we've made, and it works great except for one thing.  It includes inactive attachments.

    <PDM_MACRO name=tab title="Attachments($args.attachments.length)" height=350 id=attmnt src="OP=SHOW_DETAIL+HTMPL=xx_attmnt_tab.htmpl+FACTORY=cr+PERSID=$args.persistent_id+NO_DP=yes">

    attachments is a BREL to the lrel_attachments_requests table.  In the lrel_attachments_requests table is the SREL to attmnt where the delete_flag is located.

    Is there a way to do this where we can exclude records where the attmnt value in the delete_flag is 0?

     

    Thanks,



  • 2.  Re: Displaying count of active attachments in tab

    Broadcom Employee
    Posted Mar 15, 2016 04:33 PM

    Hello,

     

    There are two ways one could conceive of this being possible.

     

    1.  Calculate the number of active attachments on the fly.  So you take attachments.length value and subtract 1 from each inactive entry.  This would likely require custom scripting to pull off.

     

    2.  Create a custom int field on the call_req table that keeps a running count of attachments.  Each time an attachment is added/removed, increment/decrement the custom field, and read off the custom field in place of attachments.length.  While this might also require similar scripting to increment/decrement the given value, one might be able to use a trigger to keep count.

     

    In either event, it is not likely that this will be possible without additional customisations, which are outside the scope of Support.



  • 3.  Re: Displaying count of active attachments in tab

    Posted Mar 15, 2016 04:51 PM

    Hi.
    How about creating a new QREL containing only the active attachments and then using the same mechanism to display the length of this QREL attribute?
    Regards
    .....Michael



  • 4.  Re: Displaying count of active attachments in tab

    Posted Mar 16, 2016 09:23 AM

    That's a really good idea, I'll give that a try.  Thanks!



  • 5.  Re: Displaying count of active attachments in tab

    Posted Mar 16, 2016 02:35 PM

    Hi,

    I don't think thi is necessary to modify the schema with a new Qrel.

    You can always retrieve that value using a pdm_list and put it in a js variable that you can use in your htmpl form.

    something like below in your head:

     

    <script type="text/javascript">

    function get_att_length(){

    var attLength = "";

    var att_ids = new Array();

    <PDM_LIST prefix="listActiveAtt" factory="lrel_attachments_requests" where="cr='$args.persistent_id' and attmnt.delete_flag=0">

      att_ids[att_ids.length] = '$listActiveAtt.id';

    </PDM_LIST>

    attLength = att_ids.length;

    }

    </script>

    and then call the function in your body onload:

    <body class="detailro" onload="loadActions();get_att_length();" onunload="unloadActions()">

     

    Hope this help

    /J



  • 6.  Re: Displaying count of active attachments in tab

    Posted Mar 16, 2016 11:08 PM

    Let me slightly adapt your solution to andholmes's requirements

    Code will look like:

     

    var z_impact_customer_length = 0;
    <PDM_LIST prefix="zIC" factory="zlrel_impact_customer" where="tkt_persid='$args.persistent_id' AND delete_flag=0">
    <PDM_IF "$zIC.id" != "0">
    z_impact_customer_length++;
    </PDM_IF>
    </PDM_LIST>
    start_pdm_tab("Impact Customers (" + z_impact_customer_length +  ")","","imp_cst","OP=SEARCH+FACTORY=zlrel_impact_customer+QBE.EQ.tkt_persid=$args.persistent_id+QBE.EQ.delete_flag=0+KEEP.TKT_PERSID=$args.persistent_id+KEEP.parentFac=$prop.factory","300","","","true");
    

     

    Regards,

    Timur



  • 7.  Re: Displaying count of active attachments in tab

    Posted Mar 17, 2016 03:57 AM

    Hi Timur, In fact I prefer your proposal as this is more complete that mine that was just providing the idea of using pdm_list

     

    Please allow me in return to adapt your to andholmes requirements as he was looking for active attachment counts

     

    andholmes you will have to replace your current line:

     

    <PDM_MACRO name=tab title="Attachments($args.attachments.length)" height=350 id=attmnt src="OP=SHOW_DETAIL+HTMPL=xx_attmnt_tab.htmpl+FACTORY=cr+PERSID=$args.persistent_id+NO_DP=yes">

     

    by:

     

    <script>

    var z_atmnt_active_length = 0;

    <PDM_LIST prefix="listActiveAtt" factory="lrel_attachments_requests" where="cr='$args.persistent_id' and attmnt.delete_flag=0">

    <PDM_IF "$listActiveAtt.id" != "0">

    z_atmnt_active_length++;

    </PDM_IF>

    </PDM_LIST>

    start_pdm_tab("Attachments (" + z_atmnt_active_length +  ")","","attmnt","OP=SHOW_DETAIL+HTMPL=xx_attmnt_tab.htmpl+FACTORY=cr+PERSID=$args.persistent_id+SDBP_FLAG=1","350","","","true");

    </script>

     

    Hope this help

    I love team work

    /J



  • 8.  Re: Displaying count of active attachments in tab

    Posted Mar 18, 2016 10:57 AM

    It doesn't error, but it also isn't working.  It always shows 0 regardless of how many records are added (active or inactive).



  • 9.  Re: Displaying count of active attachments in tab

    Posted Mar 18, 2016 11:30 AM

    I have tested it and this work perfectly for me on a 12.9 instance

    Can you share the part of your htmpl form where your included it  so we can look for possible error

    /J



  • 10.  Re: Displaying count of active attachments in tab

    Posted Mar 29, 2016 04:24 PM

    Sorry it's taken me so long to get back to this.  Had some other things come up.  I went ahead and used the example for zlrel_impact_customer as it's much simpler.  Here's what I have.  I should perhaps also mention we're on 14.1 rather than 12.9.

    <script>

    var z_impact_customer_length = 0;

    <PDM_LIST prefix="zIC" factory="zlrel_impact_customer" where "tkt_persid='$args.persistent_id' and delete_flag=0">

    <PDM_IF "$zIC.id" != "0">

    z_impact_customer_length++;

    </PDM_IF>

    </PDM_LIST>

    start_pdm_tab("Impact Customers (" + z_impact_customer_length + ")","","zlrel_impact_customer","OP=SEARCH+FACTORY=zlrel_impact_customer+QBE.EQ.tkt_persid=$args.persistent_id+QBE.EQ.delete_flag=0+KEEP.TKT_PERSID=$args.persistent_id+KEEP.parentFac=$prop.factory","300","","","true");

    </script>

    Thanks!!



  • 11.  Re: Displaying count of active attachments in tab

    Posted Mar 16, 2016 12:22 PM

    Okay, I've created the QREL.  That took some work to get it created without it throwing an error.  However, when I try to use the QREL in the tab, it crashes the entire system.  I've tried first on a different tab because the lrel_attachments_requests table does not contain the delete_flag, it's in the attmnt table and I wanted to try it in a simpler situation first.

     

    This is the tab that CA Global Services built for us when we first implemented:

    <PDM_MACRO name=tab title="Impact Customers ($args.z_brel_impact_customer.length)" height=300 src="OP=SEARCH+FACTORY=zlrel_impact_customer+QBE.EQ.tkt_persid=$args.persistent_id+QBE.EQ.delete_flag=0+KEEP.TKT_PERSID=$args.persistent_id+KEEP.parentFac=$prop.factory">

     

    I changed the $args.z_brel_impact_customer.length to z_qrel_impact_customer.length.

    The QREL, z_qrel_impact_customer, has the Query Information set to:

    DYNAMIC {

      WHERE "delete_flag = 0 AND tkt_persid = ?" ;

      }

    I had tried creating it with the Query Information as follows, but it errored on Save and set to Test Mode until I changed it to the above.

    DYNAMIC {

      WHERE delete_flag = 0 AND tkt_persid = ? ;

      PARAM_NAMES persistent_id ;

      }

    Thanks!