CA Service Management

  • 1.  convert request to incident and viceversa

    Posted Jan 03, 2017 04:59 AM

    HI All,

     

    Does any one did a customization to convert request ticket to incident ticket along with the ticket number.

     

    we are using 14.1 with c2 patch

     

    can any one suggest how we can achieve this  with same ticket number while converting ticket from Request to incident and Viceversa.



  • 2.  Re: convert request to incident and viceversa along with ticket prefix change

    Posted Jan 03, 2017 05:21 AM

    Well,

     

    if you have different prefix between request and incident that mean you already have a customization that manage this part.

    you will then need to update that one and enhance it with the conversion.

    You may want to post your current customization here and we can see how to adapt..

    You may also want to search on previous post as If I recall correctly they been also some post already on the R/I/P type conversion.

     

    But the combination of the two may be tricky and will be confuse for your end users as they reference number may completely change over the time.

     

    Hope this help

    /J



  • 3.  Re: convert request to incident and viceversa along with ticket prefix change

    Posted Jan 03, 2017 05:37 AM

    ok can you help on converting request to incident or any idea how we can achieve it.



  • 4.  Re: convert request to incident and viceversa along with ticket prefix change

    Posted Jan 03, 2017 06:10 AM

    Hi,

    I did in the past by creating a new htmpl form and call it from the menu bar of the ticket.

    The code will look if the category is valid for the convertion and will not allow you to do if not.

    Below is a example but this is not considering your prefix and  if you want to keep them this solution will not be adequate and you better start from your prefix customization code

    My 2 cents

    /J

     

    in menubar_sd.htmpl under the action menu section:

     

    <pdm_if 0> START Adaptation Adding convert to incident functionality</pdm_if>
    var zquery_str = w.cfgCgi + "?SID=" + w.cfgSID + "+FID=" +
    w.fid_generator() + "+FACTORY=" + factory +
    "+PERSID=" + w.argPersistentID + "+OP=UPDATE";
    var zesc_str = "+HTMPL=conv_cr_in.htmpl";
    if (factory == "cr" || factory == "in")
    {
    <PDM_OBJECT>
    <PDM_MACRO name=menuItemLocal label="Convert to Incident/Request..." function="JavaScript: popupWithURL('\" + zquery_str + zesc_str + \"')">
    </PDM_OBJECT>
    }
    <pdm_if 0>END Adaptation</pdm_if>

     

    the new form conv_in_cr.htmpl derivated from the xfer_esc_cr.htmpl:

     

    <PDM_IF 0>
    conv_in_cr.htmpl
    WHEN PRESENTED:
    When an Incident needs to be converted to a Request from the Action menu.
    INTENT:
    Allow an Analyst to convert an Incident to a Request to work around the fact that employees may create an Incident by accident. Copied from xfer_esc_cr.htmpl.
    VARIABLES:
    See $NX_ROOT/bopcfg/majic/cm.maj for the
    definition of attributes for 'OBJECT alg'
    int logged_in A flag to say we have a user login object.
    object cst cst A cst object (customer) that is the logged in user.
    </PDM_IF>
    <html lang="en"><HEAD>
    <PDM_PRAGMA RELEASE=110>
    <PDM_INCLUDE FILE=styles.htmpl>
    <SCRIPT LANGUAGE="JavaScript">
    alg_factory = "alg";
    var toType = "Request";
    form_title = "Convert $args.type.sym $args.ref_num to " + toType + " $args.ref_num";

    function switch_to_escalate()
    {
    detailSwitchToEsc(document.main_form.elements["SET.alg.type"]);
    }
    </SCRIPT>
    <PDM_INCLUDE FILE=std_head.htmpl>
    <SCRIPT LANGUAGE="JavaScript">
    edit_form = 1;
    var argPersistentID = "$args.persistent_id";
    var argCstID = "$cst.id";
    var argRefNum = "$args.ref_num";
    var argID = "$args.id";
    </SCRIPT>
    <SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/arrow_button.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/check_submit.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/img_link.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/detail_form.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/val_type.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/sitemods.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript" src="$CAisd/scripts/apc.js"></SCRIPT>
    <SCRIPT LANGUAGE="JavaScript">

    /////// Variables for Priority calculation Starts/////////
    var pri_cal_matrix=new Array();
    var ticket_factory='$args.KEEP.ticket_factory';
    var pri_cal_enabled = "$args.KEEP.auto_pri_cal";
    var capture_reason = "$args.KEEP.cap_reason";
    var matrix_data = '$args.KEEP.mat_data';
    pri_cal_matrix = matrix_data.split("@,@");
    var defualt_impact = "$args.KEEP.imp_def";
    var defualt_urgency = "$args.KEEP.urg_def";
    var current_impact = "$args.impact";
    var current_urgency = "$args.urgency";
    var escalate_form = true;
    var manual_change = false;
    var parent_cai_main = null;
    /////// Variables for Priority calculation Ends/////////
    //////////////////////Functions for priority calculations Starts/////////////////////////////////
    //This function will get called detail_form.js and it will get called on Blur event of tenant combo control.
    function tenantOnBlur()
    {
    if ( ahdframe.currentAction != ACTN_COMPLETE ) {
    if ( typeof ahdframe.resumeAction != "string" ||
    ahdframe.resumeAction.length == 0 )
    {
    ahdframe.resumeAction = "tenantOnBlur()";
    }
    return;
    }

    var tenantUUID = "";
    if (ticket_factory.length <= 0 && "$args.type" == "R")
    ticket_factory = "$args.type" == "R" ? "cr" : "" ;

    if (ticket_factory.length > 0 && ( ticket_factory == "cr" )
    {
    tenantUUID = get_form_tenant_id();
    var url = cfgCgi + "?SID=" + cfgSID + "+FID=" + fid_generator() +
    "+OP=GET_PRI_CAL"+
    "+TENANT_ID="+tenantUUID+
    "+FACTORY="+ ticket_factory+
    "+CALLBACK=got_pri_cal_info";
    SyncAjaxJSCall(url);
    //alert(url);
    }
    }

    //////////////////////Functions for priority calculations Ends/////////////////////////////////

    <PDM_IF "$args.type" == "R" || "$args.type" == "">
    <PDM_LIST ESC_STYLE=JS2 prefix=list factory=response where="delete_flag=0 AND (response_owner IS NULL or response_owner = U'$cst.id') AND cr_flag=1">
    resp_sym[resp_sym.length] = decodeURIComponent('$list.sym');
    resp_ids[resp_ids.length] = '$list.id';
    </PDM_LIST>
    <PDM_ELIF "$args.type" == "I">
    <PDM_LIST ESC_STYLE=JS2 prefix=list factory=response where="delete_flag=0 AND (response_owner IS NULL or response_owner = U'$cst.id') AND in_flag=1">
    resp_sym[resp_sym.length] = decodeURIComponent('$list.sym');
    resp_ids[resp_ids.length] = '$list.id';
    </PDM_LIST>
    <PDM_ELIF "$args.type" == "P">
    <PDM_LIST ESC_STYLE=JS2 prefix=list factory=response where="delete_flag=0 AND (response_owner IS NULL or response_owner = U'$cst.id') AND pr_flag=1">
    resp_sym[resp_sym.length] = decodeURIComponent('$list.sym');
    resp_ids[resp_ids.length] = '$list.id';
    </PDM_LIST>
    </PDM_IF>

    function backfill_cnt_event( form_name, base_name, lname, fname, mname,
    cntID, caller_type )
    {
    detailCntBackfill( form_name, base_name, lname, fname, mname,
    cntID, caller_type );
    detailXferEscBackfill( base_name, lname, fname, mname, cntID, caller_type );
    }

    // Returns the parent window of this form if both the forms are in edit mode.
    function getParentWindow()
    {
    var cai_main = null;
    var ahdwin = null;
    var edit_windows = getEditWindows(argPersistentID);
    for ( var i = edit_windows.length-1; i >= 0 ; i-- ) {
    var w = edit_windows[i];
    if ( typeof w._dtl == "object" ) {
    ahdwin = w.ahdframeset;
    break;
    }
    }
    if ( ahdwin != null ) {
    if ( ahdwin.ahdframe.name == "frmDTUserNode" && // Case when switching from DT viewer to DT editor
    ahdwin.ahdframe.parent.name == "cai_main")
    {
    cai_main = ahdwin.ahdframe.parent;
    }
    else
    {
    cai_main = ahdwin.ahdframe;
    }
    }
    return cai_main;
    }

    // Returns 1 if a manual change has been made.
    function chk_for_manual_change()
    {
    //var parent_cai_main = getParentWindow();
    var man_change = false;
    var impact_ele = document.main_form.elements["SET.impact"];
    var urgency_ele = document.main_form.elements["SET.urgency"];
    if ( impact_ele != null && urgency_ele != null && parent_cai_main ) // The incident form is in edit mode
    {
    var auto_urgency = parent_cai_main.document.main_form.elements["SET.auto_urg"];
    var auto_impact = parent_cai_main.document.main_form.elements["SET.auto_imp"];
    if ( auto_urgency.value == "-1" && auto_impact.value == "-1" &&
    ( ( current_impact != impact_ele.value ) || ( current_urgency != urgency_ele.value ) ) )
    {
    man_change = true;
    }
    if ( ( auto_urgency.value != "-1" && auto_urgency.value != urgency_ele.value )
    || ( auto_urgency.value == "-1" && current_urgency != urgency_ele.value ) )
    {
    if ( parent_cai_main.esc_urg == -1
    || ( parent_cai_main.esc_urg != -1 && parent_cai_main.esc_urg != urgency_ele.value ) )
    man_change = true;
    }
    if ( ( auto_impact.value != "-1" && auto_impact.value != impact_ele.value )
    || ( auto_impact.value == "-1" && current_impact != impact_ele.value ) )
    {
    if ( parent_cai_main.esc_imp == -1
    || ( parent_cai_main.esc_imp != -1 && parent_cai_main.esc_imp != impact_ele.value ) )
    man_change = true;
    }
    }
    else if ( parent_cai_main == null ) // If the parent is in RO mode
    {
    if ( ( current_impact != impact_ele.value ) || ( current_urgency != urgency_ele.value ) )
    {
    man_change = true;
    }
    }

    return man_change;
    }

    // To update the 'Current Impact' and 'Current Urgency' when the escalate form is loaded for new tickets
    function updateCurrentFields()
    {
    var fields = ["urgency", "impact"];
    // For tickets created from templates, current impact and urgency are set already.
    if ( typeof parent_cai_main.base_template != "undefined" && parent_cai_main.base_template.length != 0 )
    {
    if ( parent_cai_main.esc_imp == -1 && parent_cai_main.esc_urg == -1 && parent_cai_main.escalateActivity != 3 )
    {
    addHtmlElementToForm("KEEP.FOR_CAPREASON", "3"); // For disabling the parent's tenant field
    if ( parent_cai_main.pri_cal_enabled != 'true' )
    pri_cal_enabled = 'false';
    }
    }
    // Sync the current elements with the parent form when priority calculation is enabled.
    else if ( ( parent_cai_main && parent_cai_main.context == "initial" && parent_cai_main.esc_imp == -1 && parent_cai_main.esc_urg == -1 && parent_cai_main.escalateActivity != 3 )
    )
    {
    if ( ( pri_cal_enabled == "true" ) ||
    ( typeof parent_cai_main.created_from_other_src != "undefined" &&
    parent_cai_main.created_from_other_src.length > 0 ) )
    {
    var init_urgency = parent_cai_main.document.main_form.elements["SET.init_urg"];
    var init_impact = parent_cai_main.document.main_form.elements["SET.init_imp"];
    if ( init_urgency )
    current_urgency = init_urgency.value;
    if ( init_impact )
    current_impact = init_impact.value;
    }
    // For tickets created from KDs, current impact and urgency are set already.
    if ( typeof parent_cai_main.created_from_KD != "undefined" && parent_cai_main.created_from_KD.length > 0 )
    ; // do nothing
    else if ( ( pri_cal_enabled == "true" ) ||
    ( typeof parent_cai_main.created_from_other_src != "undefined" &&
    parent_cai_main.created_from_other_src.length > 0 ) )
    {
    values = [ current_urgency, current_impact ];
    var new_element, current_element;
    for ( var i=fields.length-1; i>=0 ; i-- )
    {
    current_element = document.getElementById("current_" + fields[i]);
    new_element = document.main_form.elements["SET."+fields[i]];
    if ( values[i].length == 0 )
    {
    current_element.innerHTML = "";
    continue;
    }
    for ( var j=new_element.options.length-1; j>=0 ; j-- )
    {
    if ( new_element.options[j].value == values[i] )
    {
    current_element.innerHTML = new_element.options[j].innerHTML;
    }
    }
    }
    }
    addHtmlElementToForm("KEEP.FOR_CAPREASON", "3"); // For escalate activity without a manual change
    }
    }

    // Check if the latest values of Urgency/Impact are different from the current values and if so make them disabled
    function setFieldsForCapReason()
    {
    if ( ("$args.type" == "R" || "$args.type" == "P") && parent_cai_main )
    {
    updateCurrentFields();
    if ( pri_cal_enabled == "true" && capture_reason == "1" && parent_cai_main )
    {
    if ( parent_cai_main.reasonCaptured == 1 )
    {
    if ( chk_for_manual_change() )
    {
    manual_change = true;
    CapReasonFormUpdates(1);
    }
    }
    }
    }
    }

    // Adds hidden html element to the form
    function addHtmlElementToForm(name, value)
    {
    var element = document.main_form.elements[name];
    if ( element == null )
    {
    var newinput = document.createElement("input");
    newinput.setAttribute("id", name);
    newinput.setAttribute("name", name);
    newinput.setAttribute("type", "hidden");
    newinput.setAttribute("value", value);
    document.main_form.appendChild(newinput);
    }
    else
    element.value = value;
    }

    // When Urgency/Impact are modified, check if they are differnt from the current values and update the form accordingly.
    function CapReasonFormUpdates(override_check)
    {
    if ( parent_cai_main && typeof parent_cai_main.base_template != "undefined" && parent_cai_main.base_template.length != 0 )
    {
    if ( ("$args.type" == "R" || "$args.type" == "P") && parent_cai_main.pri_cal_enabled != 'true' && pri_cal_enabled == 'true' )
    {
    pri_cal_enabled = 'false';
    return;
    }
    }
    if ( ("$args.type" == "R" || "$args.type" == "P") && (pri_cal_enabled == "true") && capture_reason == "1" )
    {
    var back_to_original_values = true;
    if ( override_check == 1 || chk_for_manual_change() )
    {
    back_to_original_values = false;
    }
    if ( ( manual_change == false || override_check == 1 ) && back_to_original_values == false )
    {
    detailMakeReq("alg.description");
    var alertmsgdiv = document.getElementById("alertmsgText");
    if ( alertmsgdiv )
    {
    alertmsgdiv.innerHTML = msgtext("Reason_for_manual_change");
    var alertmsgtable = document.getElementById("alertmsg");
    if ( alertmsgtable != null && alertmsgtable.style.display != "block" )
    {
    alertmsgtable.style.display = "block";
    adjScrollDivHeight();
    }
    }
    addHtmlElementToForm("KEEP.FOR_CAPREASON", "1"); // For escalate activity with a manual change
    manual_change = true;
    }
    else if ( back_to_original_values == true && manual_change == true )
    {
    detailMakeReq("alg.description", true);
    var alertmsgtable = document.getElementById("alertmsg");
    if ( alertmsgtable != null )
    {
    alertmsgtable.style.display = "none";
    adjScrollDivHeight();
    }
    //var parent_cai_main = getParentWindow();
    if ( parent_cai_main && parent_cai_main.context == "initial" && parent_cai_main.esc_imp == -1 && parent_cai_main.esc_urg == -1 && parent_cai_main.escalateActivity != 3 )
    addHtmlElementToForm("KEEP.FOR_CAPREASON", "3"); // For escalate activity without a manual change
    else
    document.main_form.removeChild(document.getElementById("KEEP.FOR_CAPREASON"));
    manual_change = false;
    }
    }
    }

    </SCRIPT>
    </HEAD>
    <BODY onload="load_from_scratchpad('0');" onUnload="unload_check();" class=editform>
    <PDM_INCLUDE FILE=std_body.htmpl>
    <CENTER>
    <SCRIPT LANGUAGE="JavaScript">
    ahdframeset.top_splash.next_persid = "$args.persistent_id";
    if ( typeof parent.opener == "object" && parent.opener != null &&
    typeof parent.opener._dtl == "object" )
    parent.opener._dtl.tabReloadOnSave = "";
    <PDM_MACRO NAME=dtlForm factory=in>
    <PDM_MACRO NAME=dtlStart>
    docWriteln("<INPUT TYPE=hidden NAME=HTMPL VALUE='show_main_detail.htmpl'>");
    docWriteln("<INPUT TYPE=hidden NAME=KEEP.IsModified VALUE='1'>");

     

    if (_dtl && _dtl.next_persid == "")
    _dtl.next_persid = 'show_main_detail.htmpl';

    <PDM_MACRO NAME=dtlStartRow>
    <PDM_IF "$args.category.cr_flag" == "1" && "$args.type" == "I" >
    docWriteln("<INPUT TYPE=hidden NAME=SET.type VALUE='R'>");
    docWriteln("<INPUT TYPE=hidden NAME=SET.alg.type VALUE='CVTI'>");
    docWriteln("<tr><td><span class=detailro>Clicking on the Save button will convert this $args.type.sym into a Request.</span></td></tr><br />");

    <PDM_ELSE>
    docWriteln("<tr><td><span class=detailro>This ticket is already a Request or this category is not valid for this type of ticket.</span></td></tr><br />");

    </PDM_IF>
    <PDM_MACRO NAME=dtlStartRow>
    <PDM_MACRO NAME=dtlReadonly hdr="$args.type.sym Number" attr="ref_num">
    <PDM_MACRO NAME=dtlStartRow>
    <PDM_MACRO NAME=dtlReadonly hdr="Category" attr="category">
    <PDM_MACRO NAME=dtlStartRow>
    <PDM_MACRO NAME=dtlReadonly hdr="$args.type.sym Summary" attr="summary" colspan=2>

     

    </SCRIPT>
    <PDM_MACRO NAME=dtlEnd>
    </PDM_FORM>
    </CENTER>
    <PDM_INCLUDE FILE=std_footer.htmpl>
    </BODY>
    </HTML>
    <PDM_IF 0>
    @(#)$Id: xfer_esc_cr.htmpl ANDERSON.16 2010/02/03 12:17:36 mehsu01 Exp $
    </PDM_IF>
    <PDM_WSP>