CA Service Management

Expand all | Collapse all

Add a Submit Button to Update Change Status

Jump to Best Answer
  • 1.  Add a Submit Button to Update Change Status

    Posted 09-03-2015 10:30 AM

    I'm looking to add a 'Submit Change' button to my Change Order record when in View Mode that can be clicked to update the status of the change from RFC to Review.  This way our customers (who will have analyst access) can just click this button to send the change off for review.  I've been playing around with pdm_submit() to try to get this to work, but I'm not getting my desired results.  Any suggestions?

     



  • 2.  Re: Add a Submit Button to Update Change Status

    Posted 09-03-2015 10:54 AM

    You should take a look at the post from cdtj about custom webengine operations!

     

    you can update value via url call with his explanations.

     

    SPEL: Register custom webengine OP



  • 3.  Re: Add a Submit Button to Update Change Status

    Posted 09-03-2015 11:02 AM

    I forgot to mention that our implementation has to not include any customized SPEL code.  This absolutely looks like this would be the solution if not for our restriction.



  • 4.  Re: Add a Submit Button to Update Change Status

    Posted 09-03-2015 10:55 AM

    Hi,

    As I see there is 2 way customization:

    1. Open form to edit with specified code which will be trigger autosave with new status;

    2. Create Webengine OP which will update status and refresh page.

    I am inclined to the second option.

    Regards,

    cdtj



  • 5.  Re: Add a Submit Button to Update Change Status

    Posted 09-03-2015 11:02 AM

    I forgot to mention that our implementation has to not include any customized SPEL code.  Is the first option something that can be done without SPEL?



  • 6.  Re: Add a Submit Button to Update Change Status

    Posted 09-03-2015 11:04 AM

    Can you explain me why JavasScript customization is okay and not SpelCode?

     

    Both aren't supported by CA.



  • 7.  Re: Add a Submit Button to Update Change Status

    Posted 09-03-2015 11:14 AM

    We've just had issues with it in the past and for our JavaScript we can contain that to the htmpl file that can be quickly removed to restore the OOB functionality quickly.  I don't make the rules, I just follow them. 



  • 8.  Re: Add a Submit Button to Update Change Status

    Posted 09-03-2015 11:54 AM

    You can make a button that will open modified update status form and then automaticaly submit it. Your update status form will have to contain hidden field to set the status. Anyway this method is not bullet proof, it may work differently on different browsers or even may depend on browser version. And most probably you will have troubles migrating to the new version. So why not to do this in CA way, as suggested by cdtj ;)



  • 9.  Re: Add a Submit Button to Update Change Status

    Posted 09-03-2015 12:07 PM

    Well riddle me this... would it be possible for the Submit Change button to trigger a PAM Workflow that could update the status?  This would also allow me to build in some logic because our Normal Change will go to a Review status and our Standard change will go to an Implementation status.  I can build the PAM workflow, and Macro and Event to call this, but how would the button trigger it?



  • 10.  Re: Add a Submit Button to Update Change Status

    Posted 09-03-2015 01:29 PM

    Personnaly, if you were my customer, i would recommand : Use the ootb functionnalities. Just click the Actions menu at the top, Update status, and click on the blue bubble that set the next status (default transition). Put an event on this status and trigger pam.

     

    This how my current customer manage change request.

     

    As a consultant, i will say that customizing a product to overcome laziness of users isn't a viable solution. They should follow documented work instructions, and follow the process.



  • 11.  Re: Add a Submit Button to Update Change Status

     
    Posted 09-03-2015 09:14 PM

    An alternative might be to investigate how the 'Activity / Update Status' dialog (order_status_change.htmpl) works and do a custom version of that which hard-codes the new status to 'Review'.  That way you can add it to the activities menu, and you also would give the analyst the option to cancel if they'd clicked the wrong button :-).



  • 12.  Re: Add a Submit Button to Update Change Status
    Best Answer

    Posted 09-04-2015 02:33 AM

    here is method to call edit with autosave (pure HTMPL without any SPEL):

    // Place this within buttons block

    <PDM_MACRO name=button Caption="Sumbit Change" Func="WF2NEWSTATUS('<NEW_STATUS_CODE>')" hotkey_name="Edit[d]" ID="btn001" Width=120>

    function WF2NEWSTATUS(new_status_str) {
         var query_str = cfgCgi + "?SID=$prop.SID+FID=$prop.FID+OP=UPDATE" +
         "+FACTORY=chg+PERSID=" + "$args.persistent_id" + "+KEEP.new_status=" + new_status_str; // here might be ID instead of persistent_id due to chg factory specification.
         browseWithURL(query_str);
    }

    function saveOnLoad() {
         function saveIfTrue() {
              if (currentAction == 0) {
                   clearInterval(myInterval);
                   ahdframe.document.getElementsByName('SET.status')[0].value = "$args.KEEP.new_status";
                   detailSave();
              }
         }
         if (('$args.KEEP.new_status' != '') && ('$prop.form_name_3' == 'edit')) {
              var myInterval = setInterval(saveIfTrue, 100);
         }
    }

     

    note: Status field should exist on edited form.



  • 13.  Re: Add a Submit Button to Update Change Status

    Posted 11-09-2016 05:28 PM
    Hello, Try to implement this, but the ticket stays in edit mode and does not change the state. Have I done something wrong? The function saveOnLoad, from where it is called?

    It's possible to call the change_status_change.htmpl every time the button is pressed?

    best regards,
    Fabian


  • 14.  Re: Add a Submit Button to Update Change Status

    Posted 11-10-2016 06:58 AM

    Hi Fabian,

     

    I used this customization on detail_cr_wf.htmpl. When you click on the approval or reject button, the status of the task automatically change, and then you click save.

     

    Take a look on the entire code of my detail_cr_wf.htmpl:

     

     

     

    <PDM_IF 0>
    detail_iss_wf_ro.htmpl
    WHEN PRESENTED:
    When we need to display a detail of a single Workflow Task
    INTENT:
    Display the detail info for the Workflow Task
    VARIABLES:
    string image The location of the image directory as specified in
    in the config file.
    object iss_wf args The Workflow Task object we are displaying.
    See $NX_ROOT/bopcfg/majic/cm.maj for the
    definition of attributes for 'OBJECT iss_wf'
    </PDM_IF>
    <html lang="pt_BR"><head>
    <PDM_PRAGMA RELEASE=110>
    <PDM_INCLUDE FILE=styles.htmpl>
    <script language="JavaScript">
    var hdrTitle = "Detalhes do fluxo de trabalho da solicitação/incidente/problema";
    var hdrTitleUpd = "Atualizar fluxo de trabalho da solicitação/incidente/problema";
    var hdrTitleNew = "Criar fluxo de trabalho de solicitação/incidente/problema";
    </script>
    <PDM_INCLUDE FILE=std_head.htmpl >
    <script>
    var argHumantouchLog = "$args.KEEP.humantouch_log";
    var argPersistentID = "$args.persistent_id";
    var argCstID = "$cst.id";
    var argRefNum = "$args.ref_num";
    var argID = "$args.id";
    var rptName = new Array("issuesum.rpt", "issuedtl.rpt");
    var argSearchSqlClause = "id = $args.id";
    var formEnduser = new Array("main_form","requestor");

    </script>
    <script language="JavaScript" src="$CAisd/scripts/sitemods.js"></script>
    <script language="JavaScript" src="$CAisd/scripts/detail_form.js"></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/val_type.js"></script>
    <script language="JavaScript" src="$CAisd/scripts/attevts.js"></script>

    <script language="JavaScript">
    argPersistentID = "$args.persistent_id";

    function unloadActions()
    {
    if ( _dtl.edit )
    unload_check();
    }


    //Customizado
    function z_salvaStatusSolesp()
    {
    if("$args.KEEP.status_code" =="APP")
    {
    document.main_form.elements['SET.status'].value='APP';
    //document.main_form.submit();
    }
    else if("$args.KEEP.status_code" =="REJ")
    document.main_form.elements['SET.status'].value='REJ';

    document.main_form.elements['SET.description'].focus();
    }
    function z_defineStatus(status)
    {
    var frm = document.forms["zSolespForm"];
    frm.elements["KEEP.status_code"].value = status;
    document.zSolespForm.submit();
    }
    </script>
    </head>
    <!-- Customizado -->
    <PDM_IF "$args.KEEP.aprovado" == "1" && "$prop.form_name_3" == "edit">
    <body class="detailro" onload="z_salvaStatusSolesp()" onunload="unloadActions()">
    <PDM_ELSE>
    <body class="detailro" onunload="unloadActions()">
    </PDM_IF>
    <PDM_INCLUDE FILE=std_body.htmpl filename="Fluxo de trabalho da solicitação">
    <center>

    <!-- Customizado -->

    <PDM_IF "$prop.form_name_3" != "edit">
    <FORM NAME="zSolespForm">
    <INPUT TYPE=HIDDEN NAME=OP VALUE=UPDATE>
    <INPUT TYPE=HIDDEN NAME=FACTORY VALUE=cr_wf>
    <INPUT TYPE=HIDDEN NAME=PERSID VALUE="$args.persistent_id">
    <INPUT TYPE=HIDDEN NAME=KEEP.aprovado VALUE="1">
    <input TYPE=HIDDEN NAME=DESCRIPTION>
    <input TYPE=HIDDEN NAME=KEEP.status_code>
    <INPUT TYPE=HIDDEN NAME=NEXT_PERSID VALUE="$args.persistent_id">
    <INPUT TYPE=HIDDEN NAME=SET.id VALUE="$args.id">
    <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
    docWriteln('<INPUT TYPE=HIDDEN NAME=SID VALUE='+cfgSID+'>');
    docWriteln('<INPUT TYPE=HIDDEN NAME=FID VALUE='+cfgFID+'>');
    //document.write("<INPUT TYPE=HIDDEN NAME=KEEP.aprovadkko VALUE=\"0\">");
    </SCRIPT>
    </FORM>
    </PDM_IF>

    <input type="hidden" name="FACTORY" value="cr_wf">
    <PDM_IF "$prop.form_name_3" == "edit">
    <input type="hidden" name="OP" value="UPDATE">
    <PDM_IF 0 == $args.id>
    <SPAN class="labeltext">Você não tem permissão para criar um fluxo de trabalho</SPAN>
    <PDM_ELSE>
    <PDM_IF $args.id>
    <input type="hidden" name="SET.id" value="$args.id">
    </PDM_IF>
    </PDM_IF>
    </PDM_IF>

    <script language="JavaScript">
    <PDM_MACRO name=dtlForm button=false factory=cr_wf>
    <PDM_IF "$prop.form_name_3" == "edit">
    <PDM_MACRO name=btnStartRow>
    <PDM_MACRO name=button Caption="Salvar[S]" Func="detailSave()" hotkey_name="Save[S]" ID=btn001 Width=120>
    <PDM_MACRO name=button Caption="Cancelar[n]" btnType=negative Func="cancel_update('$prop.form_name_2','$args.id','$args.NEXT_PERSID')" hotkey_name="Cancel[n]" ID=btncncl Width=120>
    <PDM_MACRO name=button Caption="Redefinir[R]" Func="pdm_reset()" hotkey_name="Reset[R]" ID=btn003 Width=120>
    <PDM_MACRO name=btnEndRow>
    </PDM_IF>
    </script>
    <PDM_IF "$prop.form_name_3" == "ro">
    <script type="text/javascript">
    <PDM_MACRO name=btnStartRow>

    //Customizado - Cria botões
    function allow_wf_edit() {
    if ("$args.status.allow_task_update" == "1") {
    return true;
    }
    if ("$args.status.task_complete" == "1" && reopen_id != 0) {
    var has_reopen = false;
    <PDM_LIST SOURCE=args.behavior_templates PREFIX=list WHERE=" " FACTORY=bhvtpl>
    if($list.context_attrval==reopen_id) { has_reopen=true; }
    </PDM_LIST>
    if (has_reopen) {
    return true;
    }
    }
    return false;
    }
    if (allow_wf_edit() && "$args.status.code" != "WAIT" && "$args.status.code" != "REOPWAIT" && cfgMOPreviewMode == 0)
    {
    var fieldset = "<td>";
    if ( _browser.isIe )
    fieldset += "<fieldset>";
    else
    fieldset += "<fieldset class=firefox_fieldset>";
    var legend = "Ações";
    docWriteln(fieldset + "<legend class=button_legend>" + legend + "</legend>");

    <PDM_MACRO name=btnStartRow>
    <PDM_MACRO name=button Caption="Aprovar" Func="z_defineStatus('APP');" hotkey_name="APR" ID="APRSOLESP" Tooltip="Aprovar SOLESP">
    <PDM_MACRO name=button Caption="Rejeitar" Func="z_defineStatus('REJ');" hotkey_name="REJ" ID="REJSOLESP" Tooltip="Rejeitar SOLESP">

    docWriteln("</fieldset></td></tr></table>");
    }
    </script>
    <PDM_IF $UserAuth \> 1>

    <PDM_FORM NAME="frmDTLRO">
    <input type="hidden" name="FACTORY" value="cr_wf">
    <input type="hidden" name="SET.id" value="$args.id">
    <input type="hidden" name="OP">
    <script language="JavaScript">
    if (allow_wf_edit()) {
    var fieldset = "<td>";
    if ( _browser.isIe )
    fieldset += "<fieldset>";
    else
    fieldset += "<fieldset class=firefox_fieldset>";
    var legend = "Ações";
    docWriteln(fieldset + "<legend class=button_legend>" + legend + "</legend>");

    <PDM_MACRO name=btnStartRow>
    <PDM_MACRO name=button Caption="Aprovar" Func="z_defineStatus('APP');" hotkey_name="APR" ID="APRSOLESP" Tooltip="Aprovar SOLESP">
    <PDM_MACRO name=button Caption="Rejeitar" Func="z_defineStatus('REJ');" hotkey_name="REJ" ID="REJSOLESP" Tooltip="Rejeitar SOLESP">

    docWriteln("</fieldset></td></tr></table>");
    }
    </script>
    </PDM_FORM>
    </PDM_IF>
    <script language="JavaScript">
    <PDM_MACRO name=button Caption="Histórico de eventos" Func="show_evt('cr_wf', 'atev', $args.id)" hotkey_name="Event History" ID=SHOW_EVT_HISTORY Width=120>
    <PDM_MACRO name=btnEndRow>
    </script>
    </PDM_IF>
    <script>
    <PDM_MACRO name=dtlStart>
    <PDM_MACRO name=dtlStartRow>
    <PDM_MACRO name=dtlReadonly hdr="Tarefa" attr=task.sym>
    <PDM_MACRO name=dtlLookup hdr="Concluída por" attr=done_by colspan=2>
    <PDM_MACRO name=dtlDate hdr="Data de conclusão real" attr=completion_date>
    <PDM_MACRO name=dtlStartRow>
    <PDM_MACRO name=dtlReadonly hdr="Sequência" attr=sequence>
    <PDM_MACRO name=dtlStartExpRow label="Informações do chamado" colspan="5" exp_rows="1,2,3,4" form_name="detail_cr_wf">
    <PDM_MACRO name=dtlStartRow>
    <PDM_IF "$prop.form_name_3" == "edit">
    <PDM_MACRO name=dtlReadonly hdr="Status" attr=status colspan=2>
    <PDM_MACRO name=dtlStartRow>
    detailRowHdr("Status", 1 , "$args.REQUIRED_status");
    var item = '<PDM_SELECT NAME=SET.status ESC_STYLE=HTML FACTORY=tskstat WF_FAC_FOR_TSKSTAT=wf SELECTED="$args.status" SELECTED_SYM="$args.status.COMMON_NAME">';
    var ins_pos = item.indexOf("NAME=");
    if (ins_pos > 0)
    {
    _dtl.tabIndex++;
    item = item.substring(0, ins_pos) + " tabindex=" + _dtl.tabIndex + " " + item.substring(ins_pos, item.length);
    }
    detailSetRowData(item);
    <PDM_MACRO name=dtlReadonly hdr="Nº da solicitação" attr=cr.ref_num>
    <PDM_ELSE>
    <PDM_MACRO name=dtlStartRow>
    <PDM_MACRO name=dtlLookupReadonly hdr="Nº da solicitação" attr=cr>
    <PDM_MACRO name=dtlReadonly hdr="Usuário solicitante" attr="cr.customer.combo_name" colspan="2">
    <PDM_MACRO name=dtlStartRow>
    <PDM_MACRO name=dtlReadonly hdr="Categoria" attr=cr.category.sym colspan=4>
    <PDM_MACRO name=dtlStartRow>
    <PDM_MACRO name=dtlReadonly hdr="Descrição do chamado" attr=cr.description colspan=4>
    </PDM_IF>
    <PDM_MACRO name=dtlStartRow>
    <PDM_MACRO name=dtlTextbox hdr="Comentário adicional" attr=description colspan=4 keeplinks=yes rows=4 size=70 spellchk=yes>
    <PDM_MACRO name=dtlEndTable>
    </script>

    <PDM_MACRO name=dtlEnd>
    <PDM_MACRO name=startNotebook hdr=wf_nb>

    <PDM_INCLUDE FILE=std_footer.htmpl>
    </body>
    </html>
    <PDM_WSP>



  • 15.  Re: Add a Submit Button to Update Change Status

    Posted 11-10-2016 08:36 AM

    Hi,

    I have updated my previous message, there was a syntax error.

     

    Try this one:

    - copy saveOnLoad function into change_status_change.htmpl;

    - in change_status_change find <body> html tag and add saveOnLoad function into onload property:

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

    - modify WF2NEWSTATUS function adding +HTMPL=change_status_change.htmpl to the end of query_str.

     

    Regards,

    cdtj



  • 16.  Re: Add a Submit Button to Update Change Status

    Posted 09-08-2015 07:58 PM

    Hi Kenneth - Did the responses help you resolve your issue? If so please mark the appropriate as Correct Answer. Thanks! Chris



  • 17.  Re: Add a Submit Button to Update Change Status

    Posted 09-20-2016 04:07 PM

    Hello guys,

     

    How can I add this buttons to approve or reject workflow tasks (request/incidents/problems)?

    I'm trying to customize this code on the detail_cr_wf.htmpl form.

     

    Regards.