CA Service Management

  • 1.  Copy and attach as child

    Posted Apr 09, 2018 06:59 AM

    We are currently on SDM 14.1 and will be upgrading in this quarter to 17.1.

    We have a process in service desk whereby we are able to "copy" a ticket as a child and the relationship to the parent is automatically filled in.  We have simply called this process - Create Child.

    However, this has been completely done in the detail_in.htmpl screen and does not consider any properties on the parent ticket (that would originate from the category).

    The system function for "Copy" considers the properties and completes them in the copied ticket as well.  I am trying to combine the two functions together so that I can create a "child" that has both the properties and the relationship to the parent created.

    Is there anyone that has built a similar requirement that can perhaps assist?

     

    Any suggestions will be much appreciated.

     

    chris saunders



  • 2.  Re: Copy and attach as child

    Posted Apr 09, 2018 09:42 AM

    Hi  Chris

    You might try the following, by adopting the "user exit" when copying incidents:

    • copy the file $NX_ROOT/bopcfg/majic/tmplcopy_site.spl to your $NX_ROOT/site/mods/majic directory
    • edit this copied file
    • find the method "cr::copy_cr_site(...)"
    • add :
          send_wait(0,new,"call_attr","parent","set_val",old.persistent_id);
      just before the return.
    • save the file and restart the service or spelsrvr process only.
    • login to the GUI and open the  detail of an existing incident
    • Select File->Copy
    • the incident gets copied , all the properties gets copied and the old incident is already set as the parent.

    I hope this meets your requirement and helps.

    Best regards

    ......Michael



  • 3.  Re: Copy and attach as child

    Posted Apr 10, 2018 05:58 AM

    Hi Michael

    Thank you very much for the information.  I have checked it and it is working in my environment as you described. 

    I am now having difficulty in trying to trace the functions through the form to the actual code.  The reason that I would like to do this is as follows:

    1. I do not want to change the original functionality of the "copy" function.

    2. I would like add an additional option to the dropdown list of the menubar_sd.htmpl called "Create Child" and then leverage off the original copy functionality together with your supplied code and include the other functionality that we have built for our current "Create Child" functionality. 

    I would imagine it would then be necessary to copy the cr::copy_cr_site(...) section in the tmplcopy.site.spl and rename it to something like cr::child_cr_site().

    The only thing that I am struggling with is that the copy button on the menubar_sd.htmpl form calls a function="make_copy()" and I don't know where the relationship between this function and the method "cr::copy_cr_site() is found.

     

    Is it as simple as creating the button on the form

         <PDM_MACRO name=menuItem label="Create Child" function="make_child()">

    and then renaming the method in the .spl file to

         cr::child_cr_site (...) {

             etc

             }

     

    Your assistance is valued if this is at all possible or if you could explain how the relationship between the two is established.

     

    Regards

    chris



  • 4.  Re: Copy and attach as child

    Posted Apr 10, 2018 07:41 AM

    Hi Chris.

    Sometime it is much more easier to change an existing function, like I did in the last example, than to create a new function, even if it is only slightly different to the existing one.

    Unfortunately, I wasn't able to find a solution for your requirement based on my first suggestion.

    My second approach is completely independent from my first, so please remove the   $NX_ROOT/site/mods/majic//tmplcopy_site.spl  file again

    Instead do the following:

    1. add the following code block to your menubar_sd.htmpl just behind
        <PDM_MACRO name=menuItem label="Copy" function="make_copy()">
      line:
        if( w.propFactory == "cr" ) {
           <PDM_MACRO name=menuItem label="Create Child" function="make_child()">
        }

       

    2. add the following functions to the end of your head script block in detail_in.htmpl just before the </script></head> tags
      function make_child() {
         make_copy("","KEEP.make_child_for_pid=$args.persistent_id","KEEP.make_child_for_ref_num=$args.ref_num");
      }
      function init_child() {
      if( _dtl.edit && "$args.KEEP.make_child_for_pid" != "" && "$args.KEEP.make_child_for_ref_num" != "") {
        document.main_form.elements["SET.parent"].value="$args.KEEP.make_child_for_pid";
        document.main_form.elements["KEY.parent"].value="$args.KEEP.make_child_for_ref_num";
      }
      }

       

    3. add init_child() as an additional onload event function so that it looks like
      <body class="detailro" onload="loadActions();init_child()" onunload="unloadActions()">

       

    4. after restarting the service, you should see the additional "Create Child" menu item in your file menu in the incident detail view. When selecting this menu item, two keep variable will be set while executing the normal make_copy function. When the new detail for the copy popups, the keep variables will be used to set the parent attribute of the copy. As you can see , this is a pure GUI solution.

    Hope that fits better to your approach.

    regards

    .............Michael



  • 5.  Re: Copy and attach as child

    Posted Apr 11, 2018 07:51 AM

    Afternoon Michael.


    Thank you very much for your assistance.  The second option is definitely more suited to meet my requirement.  I wonder if you could assist with a few answers as I am not following the logic of the statements (even though most of it is working).


    1.  I have added the following logic to the supplied code:

    function make_child()
    {
      make_copy("","KEEP.make_child_for_pid=$args.persistent_id","KEEP.make_child_for_ref_num=$args.ref_num","KEEP.make_child_customer_id=$args.customer.id","KEEP.make_child_customer_name=$args.customer.combo_name");
    }

    function init_child()
    {
      if (_dtl.edit && "$args.KEEP.make_child_for_pid" != "" && "$args.KEEP.make_child_for_ref_num" != "")
      {
     document.main_form.elements["SET.parent"].value="$args.KEEP.make_child_for_pid";
     document.main_form.elements["KEY.parent"].value="$args.KEEP.make_child_for_ref_num";
     document.main_form.elements["SET.description"].value=<PDM_FMT ESC_STYLE=JS2>"$args.description (created from Incident $args.KEEP.make_child_for_ref_num)"</PDM_FMT>

    document.main_form.elements["SET.requested_by"].value="$args.KEEP.make_child_customer_id";

    document.main_form.elements["KEY.requested_by"].value="$args.KEEP.make_child_customer.name";

    document.main_form.elements["SET.customer"].value="$cst.id";

    document.main_form.elements["KEY.customer"].value="$cst.combo_name"

    }


    2.  I have had no success in getting the Customer value of the parent to populate through to the Requestor Field on the Child.  I have tried adding the following line at the end of the function but to no avail:

    <input type="hidden" name="SET.requested_by" value="$args.customer">


    3. When I interrogate the created child form through IE Developer tools, I am able to see that the correct values for $cst.id and $cst.combo_name are correct, but they will not populate into the customer field and I am unable to see any values that are necessary to populate the requested by field.  I have tried outputting it to the Console Log as well but I am having very little joy.

     

    I am not asking you to write all the code for me, but if you could tell me what I am doing incorrectly or point me in the right direction, I might be able to battle through this and meet the requirements.

     

    Much appreciated.

    chris



  • 6.  Re: Copy and attach as child

    Posted Apr 11, 2018 08:38 AM

    Hi Chris.

    your problem might be related to the fact that cnt srel attributes consist of more than SET and KEY input fields. These get automatically created when using the pdm_macro dtlLookup. For all other factory srels the KEY input element is always the visible one, while the SET is always generated hidden. For cnt srel attributes the hidden elements are created (example for requested_by)

    requested_by_combo_name :The visible input field

    requested_by_lname : a hidden element for the last_name

    requested_by_fname : a hidden element for the first_name

    requested_by_mname : a hidden element for the middle_name

    SET.requested_by : the SET element.

    Key.requested_by : a hidden KEY field

    I don't have time to test this on my own.I suggest the following two tries:

    1. use SET.requested_by and requested_by_combo_name
    2. use SET.requested_by and KEY.requested_by and requested_by_combo_name .

     

    Dont create hidden fields on your own

    Best regards and good luck

    ....Michael