Clarity Service Management

Expand all | Collapse all

Is there a method to copy request attachments to a change order when creating a change order from a reguest

Jump to Best Answer
  • 1.  Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-16-2017 02:16 PM

    We get security requests from employee self service with forms attached. When we create a change order from that request, the attached forms are not attached to the new change order. This requires the customer service people to download the attachments then attach them to the change. It seems like since this involves an lrel table, there should be a method to link the attachments to the change order also...



  • 2.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-16-2017 07:42 PM

    Hey cdtj, do you know if your z_lrel_copy script can work for this use case? I was going to check today but ran out of time.



  • 3.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-17-2017 01:13 AM
      |   view attached

    hi,

    I have adapted previous script but didnt tested it.

     

    new syntax:

    // z_lrel_copy(object old_obj,          // Old object (copy from)
    //             object new_obj,          // New object (copy to)
    //             string old_lrel,          // old lrel name
    //             string new_lrel,          // new lrel name
    //             string old_key,          // old lrel key attribute (reference to REL_ATTR of copied object)
    //             string new_key,          // new lrel key attribute (reference to REL_ATTR of copy to object)
    //             ...) {                    // attributes to copy, most lrels have only 2 attrs, parent and child, here should be child
    z_lrel_copy(old, new,
         "lrel_attachments_requests", "lrel_attachments_changes",
         "cr", "chg",
         "attmnt"
    );

     

    theodore.hoosick, main question, is spel customization acceptable for your needs?

     

    Regards,

    cdtj

    Attachment(s)

    zip
    z_lrel_copy2.zip   1016B 1 version


  • 4.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-17-2017 09:00 AM

    I have no problem with using custom spel. I can use one of our non-production servers to test.



  • 5.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-21-2017 10:56 AM

    Hi cdtj,

    I am not sure where I can call this code from to move the attachments in conjunction with the "Create Change Order" button on a request form. (detail_cr.htmpl). Do you have any insight?

     

    Thanks,

    Ted



  • 6.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-21-2017 01:57 PM

    Hi Ted,

     

    This is a bit more complicated than modifying the copy/template functions as they are not defined in tmplcopy_site.  You have to create a new Create Change Order function and add a new spel trigger to call the Attach CHG to CR method when it’s used. This example writes the request persid to the change orders string6 attribute then triggers a spel script to attache the change to the request and copy the requests attachments.  Let me know if you have questions about any of the steps.

     

    Thank you cdtj for the update to the z_lrel_copy script!

     

    1. Update detail_cr.htmpl

    1.1Find the area of code that has the following.

    <form name="frm002">
    ...
    </form>

    Directly after this place the following code

    <form name="zCOMapping">
    <input type="hidden" name="SET.requestor" value="$cst.id">
    <input type="hidden" name="requestor_combo_name" value="$cst.combo_name">
    <input type="hidden" name="SET.affected_contact" value="$cst.id">
    <input type="hidden" name="affected_contact_combo_name" value="$cst.combo_name">
    <input type="hidden" name="assignee_combo_name" value="$args.assignee.combo_name">
    <input type="hidden" name="SET.assignee" value="$args.assignee">
    <input type="hidden" name="KEY.assignee" value="$args.assignee.combo_name">
    <input type="hidden" name="group_combo_name" value="$args.group.combo_name">
    <input type="hidden" name="SET.group" value="$args.group">
    <input type="hidden" name="KEY.group" value="$args.group.combo_name">
    <input type="hidden" name="SET.impact" value="$args.impact">
    <input type="hidden" name="SET.description" value=<PDM_FMT ESC_STYLE=JS2>"&#13;&#13;(created from Request $args.ref_num)"</PDM_FMT>>
    </form>

     

     

    1.2 Next find the following code

    // detailExtraSaveButtons()
    // Provide extra save buttons for edit form
    function detailExtraSaveButtons(generate)
    {
      var count = 0;
         <PDM_IF $ACCESS.FAC_chg == 2 && "$args.change" == "">
      if ( cfgUserAuth \> 1 ) {
        count++;
        if ( generate ) {
          <PDM_MACRO NAME=button caption="Create Change Order[!ea]" hotkey_name="Create Change Order[!ea]" id=btnchg
              func="detailSave('NEW_CHANGE')" Tooltip="Save and Create Change Order">
        }
      }
    </PDM_IF>
    <PDM_IF "$args.problem" == "">
      if ( cfgUserAuth \> 1 ) {
        count++;
        if ( generate ) {
          <PDM_MACRO NAME=button caption="Create Incident[!eaI]" hotkey_name="Create Incident[!eaI]" id=ITIL_INCIDENT
           func="itil_incident()" Tooltip="Save and Create Incident">
        }
      }
    </PDM_IF>
      return count;
    }

    and change it to

    // detailExtraSaveButtons()
    // Provide extra save buttons for edit form
    function detailExtraSaveButtons(generate)
    {
      var count = 0;
    <PDM_IF 0>
    //Commenting out ootb Save and Create Change Order button
         <PDM_IF $ACCESS.FAC_chg == 2 && "$args.change" == "">
      if ( cfgUserAuth \> 1 ) {
        count++;
        if ( generate ) {
          <PDM_MACRO NAME=button caption="Create Change Order[!ea]" hotkey_name="Create Change Order[!ea]" id=btnchg
              func="detailSave('NEW_CHANGE')" Tooltip="Save and Create Change Order">
        }
      }
    </PDM_IF>
    </PDM_IF>
    <PDM_IF "$args.problem" == "">
      if ( cfgUserAuth \> 1 ) {
        count++;
        if ( generate ) {
          <PDM_MACRO NAME=button caption="Create Incident[!eaI]" hotkey_name="Create Incident[!eaI]" id=ITIL_INCIDENT
           func="itil_incident()" Tooltip="Save and Create Incident">
        }
      }
    </PDM_IF>
    <PDM_IF  $ACCESS.FAC_chg == 2 && "$args.change" == "">
      if ( cfgUserAuth \> 1 ) {
        count++;
        if ( generate ) {
          <PDM_MACRO NAME=button caption="Create Change Order[!ea]" hotkey_name="Create Change[!ea]" id=ZCREATECO
           func="zCreateCO()" Tooltip="Save and Create Change Order">
        }
      }
    </PDM_IF>
      return count;
    }

     

    1.3 Find the following code

    <PDM_IF "$prop.form_name_3" != "edit">
    if ( typeof parent.createIncident == "boolean" &&
         parent.createIncident ) {
      if (typeof ahdframeset.workframe == "object")
        ahdframeset.workframe.SkipInitialFocus = "1";
    <PDM_IF "$prop.MultiTenancy" != "on">
      create_new('cr',0,0,0,'PRESET=type:I','INITFROM=frm002');
    <PDM_ELSE>
      create_new('cr',0,0,0,'PRESET=type:I@@tenant:'+argTenantId,'INITFROM=frm002');
    </PDM_IF>
    }
    </PDM_IF>
    parent.createIncident = void(0);

    and change it to

    <PDM_IF "$prop.form_name_3" != "edit">
    if ( typeof parent.createIncident == "boolean" &&
         parent.createIncident ) {
      if (typeof ahdframeset.workframe == "object")
        ahdframeset.workframe.SkipInitialFocus = "1";
    <PDM_IF "$prop.MultiTenancy" != "on">
      create_new('cr',0,0,0,'PRESET=type:I','INITFROM=frm002');
    <PDM_ELSE>
      create_new('cr',0,0,0,'PRESET=type:I@@tenant:'+argTenantId,'INITFROM=frm002');
    </PDM_IF>
    }

    if ( typeof parent.createChange == "boolean" &&
         parent.createChange ) {
      if (typeof ahdframeset.workframe == "object")
        ahdframeset.workframe.SkipInitialFocus = "1";
      create_new('chg',0,0,0,'PRESET=string6:$args.persistent_id','INITFROM=zCOMapping', '');
    }
    </PDM_IF>
    parent.createIncident = void(0);
    parent.createChange = void(0);

     

    1.4 Find the following code

    <PDM_IF $ACCESS.FAC_chg == 2 && "$args.change" == "">
       if ( cfgUserAuth > 1 ) {
    <PDM_MACRO name=button Caption="Create Change Order[!ea]" Func="detailSave('NEW_CHANGE')" hotkey_name="Create Change Order[!ea]" ID=btnchg Tooltip="Save and Create Change Order">
       }
    </PDM_IF>

    and change it to

    <PDM_IF 0>
    //Commenting out ootb Save and Create Change Order button
    <PDM_IF $ACCESS.FAC_chg == 2 && "$args.change" == "">
       if ( cfgUserAuth > 1 ) {
    <PDM_MACRO name=button Caption="Create Change Order[!ea]" Func="detailSave('NEW_CHANGE')" hotkey_name="Create Change Order[!ea]" ID=btnchg Tooltip="Save and Create Change Order">
       }
    </PDM_IF>
    </PDM_IF>

     

     

    2. Add spel files to nx_root/site/mods/magic

    2.1 Download cdtj's z_lrel_copy from his post above and extract to nx_root/site/mods/magic

    2.2 Create a file named zAttachChangeToRequest.mod with the following contents and place in nx_root/site/mods/magic

    MODIFY chg     POST_CI zAttachChangeToRequest(persistent_id,string6) 100051 FILTER( string6 {} );

    2.3 Create a file named zAttachChangeToRequest.spl with the following contents and place in nx_root/site/mods/magic

    chg::zAttachChangeToRequest(...)
    {

         // The following lines can be un commented for debugging
        
         string method;
         method="chg::zAttachChangeToRequest";
         logf(SIGNIFICANT, "%s started", method);
        
         int x;
         for(x=0; x<argc; x++) {
              logf(SIGNIFICANT,"argv[%d]=%s",x,argv[x]);
         } 
        
         //logf(SIGNIFICANT,method);

         // End debugging lines
        
         // Variables required for this function are defined here
              string          crPersid, chgPersid, desc;
              uuid          who;

         // Argument values that were sent to the function are copied into their respective variables here
              chgPersid          =argv[3];
              crPersid          =argv[6];

         desc = "Change Order ";
             
         send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");
         who=msg[0];    


         send_wait(0, top_object(), "call_attr", "api", "get_object_values", who, chgPersid, 0, "chg_ref_num"); 
         if (msg_error()) { 
           logf(ERROR, "get_failed %s",msg[0]); 
         } 
         else 
         { 
         int i; 
         for (i=0;i<msg_length();i++) { 
           logf(SIGNIFICANT, "msg[%d]: '%s'", i, msg[i]); 
           }
         desc += msg[1] + " created.";
         } 
        
         send_wait(0, top_object(), "call_attr", "api", "attach_chg_to_request", who, crPersid, chgPersid, desc);
         logf(SIGNIFICANT, "%s ended", method);
        
        
        
         object old, new;

         // Get cr dob ref
         send_wait(0, top_object(), "call_attr", "cr", "dob_by_id", 0,
                             crPersid, NULL);
         old = msg[0];
         if (msg_error()) {
              logf(ERROR, "Error getting location ref: %s", loc_dob);
              set_error(1);
              return;
         }
        
         // Get chg dob ref
         send_wait(0, top_object(), "call_attr", "chg", "dob_by_id", 0,
                             chgPersid, NULL);
         new = msg[0];
         if (msg_error()) {
              logf(ERROR, "Error getting location ref: %s", loc_dob);
              set_error(1);
              return;
         }
        
         z_lrel_copy(old, new,
         "lrel_attachments_requests", "lrel_attachments_changes",
         "cr", "chg",
         "attmnt"
        );

    }


  • 7.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-21-2017 10:58 PM

    Hey Ted,

     

    I made some edits to my example. Not sure if the system sends notifications for edits and I wanted to make sure you saw it.



  • 8.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-22-2017 07:18 AM

    Thanks for the update,Grant. I didn't get a notification on the modifications. I will try to get this into my dev environment today.



  • 9.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-27-2017 10:43 AM

    Thanks gbruneau for sharing this with Ted!

    @theodore.hoosick - let us know if Grant's idea works for you!



  • 10.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-29-2017 02:59 PM

    I had a chance to try this in my DEV environment today, however there is a problem in the zAttachChangeToRequest.spl file.

    Does "at (71)" refer to the line number?

    Possibly a copy error...

     

    11/29 14:22:00.27 EHS-DV-CA-WWB1 spelsrvr             3164 ERROR        script.y              3871 C:/PROGRA~2/CA/SERVIC~1/site/mods/majic/zAttachChangeToRequest.spl at (71) syntax error



  • 11.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-29-2017 03:23 PM

    Update: Found the error in the .spl file, a  missing "}" at the end. Still getting an error in the mod file, but the app starts now. I will look further tomorrow.

    Thanks...

    11/29 15:15:13.10 EHS-DV-CA-WWB1 domsrvr:hw           2848 ERROR        majic.y               4622 mods/majic/zAttachChangeToRequest.mod:0 syntax error, unexpected YACC_NUMBER, expecting $end or YACC_LREL or YACC_MODIFY or YACC_OBJECT at "1"



  • 12.  Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 11-29-2017 06:46 PM

    Hi Ted,

     

    If you're running an older version of SDM you may need to use different syntax in the mod file.  The one I shared worked in my 17.0 test environment.  

     

    Try this instead in the mod file I originally posted.

    OBJECT chg { 
    TRIGGERS {
    POST_CI zAttachChangeToRequest(persistent_id,string6) 100051
    FILTER( string6 {} );
    } ;
    } ;


  • 13.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 09-10-2019 08:17 AM
    Hi Guys,
    It worked fine for me in 14.1 but does no longer works on 17.2.
    When the users role data partition restricts from viewing on the ticket that the attachment was originaly attached to he can see the attachment on the cloned ticket but can not open it.
    Do you have the same problem? Did you fix it?


  • 14.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 09-10-2019 12:29 PM
    Does the end user receive any type of error message?

    Is there anything recorded in the STDLOGs?

    ------------------------------
    Paul Coccimiglio
    Principal Support Engineer
    Broadcom Inc.
    ------------------------------



  • 15.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 09-10-2019 01:39 PM
    The user gets a Tomcat error 400 – Wrong redirection
    There are no errors in stdlog.





  • 16.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 09-10-2019 02:53 PM
    @TED HOOSICK or @Grant Bruneau - any ideas? ​​

    ------------------------------
    Paul Coccimiglio
    Principal Support Engineer
    Broadcom Inc.
    ------------------------------



  • 17.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

     
    Posted 09-12-2019 02:10 AM
    The user gets a Tomcat error 400 – Wrong redirection
    > There are no errors in stdlog.


    1) Try and differentiate between "The code is wrong" and "End user can't get to the Attachments/code/Tomcat/other problems."

    See if you can do your testing directly on the server as an Admin. with full rights, before sharing it out to an Employee on a remote computer. Just in case.

    2) The message by itself is quite general (Tomcat can't find what it wants). And need to narrow it down (See above).
    But as you're trying to do something with Attachments, check out this Knowledge Article, just in case the Attachments in a location that your default Repository (and Tomcat) aren't expecting.

    HTTP Status 400 received when attempting to open attachments after upgrading

    3) You can bump the error logging up if needed.
    * Increasing Tomcat logging will let you see more about what Tomcat is complaining about.
    * Increasing the stdlog logging on the spelsrvr, webengine and domsrvr will record more ***if*** the request is making it that far.

    But unless we get lucky, we're diving into more complex logs than we can effectively (and confidentially) troubleshoot here. Still, you might be able to pluck out the key message and then that is something we can work on.

    Tomcat logging is here:
    https://ca-broadcomcsm.wolkenservicedesk.com/wolken/esd/knowledgebase_search?articleId=54282

    Service Desk logging is here:
    https://ca-broadcomcsm.wolkenservicedesk.com/wolken/esd/knowledgebase_search?articleId=26081

    And yes, they're high level. Sorry.  But I'm kind of hoping that we can use (1) to narrow it down a bit more first.

    Thanks, Kyle_R.






  • 18.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 09-12-2019 02:41 AM
    Hi Kyle_R,
    Thanks for writing.
    1) I tried with Admin and it works fine. The URL looks exactly the same as for the role with restricted acces except the Bpsid (what's that?), SID and FID are changing which is obvious.
    2) I can't open the Article. I'm getting ​the "Grant not available. Please contact the admin." error.
    3) I will try to investigate with error logging and let you know.

    Thanks, Marcin



  • 19.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 09-12-2019 08:14 AM
    See if the following KB URLS work for you:

    https://ca-broadcom.wolkenservicedesk.com/external/article?articleId=129210

    https://ca-broadcom.wolkenservicedesk.com/external/article?articleId=54282

    https://ca-broadcom.wolkenservicedesk.com/external/article?articleId=26081

    ------------------------------
    Paul Coccimiglio
    Principal Support Engineer
    Broadcom Inc.
    ------------------------------



  • 20.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 09-12-2019 08:24 AM
    Thanks Kyle, does URLs works fine.
    This is not the problem described in the first one as all of the folders are copied and teh attachment is accessible by admin.


  • 21.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

    Posted 09-12-2019 08:50 AM
    It looks like there are some access settings on the attachment (attmnt) table. Do you know anything about it?
    Do you know how does work the following attributes on attmnt object: dont_check_perm, inherit_permission_id (Inherit Permission Flag), READ_GROUP_LIST, read_pgroup?

    Thanks,
    Marcin


  • 22.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest
    Best Answer

    Posted 09-18-2019 10:00 AM
    I finaly got it worlking by modyfing the spel code to create a copy of record in attmnt table and then creating new record in lrel table with the created attmnt record not the original one.

    Marcin


  • 23.  RE: Re: Is there a method to copy request attachments to a change order when creating a change order from a reguest

     
    Posted 09-18-2019 09:22 PM

    Thanks for letting us know.

    You might be able to flag your own post as "Best Answer".

    Kyle_R.