CA Service Management

Expand all | Collapse all

Change Order - Required Field for Emergency Type Only

Jump to Best Answer
  • 1.  Change Order - Required Field for Emergency Type Only

    Posted 09-14-2017 02:21 PM

    My ECAB group would like to know why a Change Order was put in as Emergency .. .their suggestion is to add a new field (comment box) somewhere on the Change Order form and make it required when the change order type = Emergency and the ticket is initially opened.

     

    Is the best way to do this by creating a new field in the DB / Schema and then add it to the form with some code that makes it required or can I somehow make the Business Justification field (on the Additional Information > Properties tab) required when the change order type is = Emergency?

     

    Any help on this would be appreciated.

     

     

    thank you

    Katherine



  • 2.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-14-2017 02:31 PM

    Katherine, what is an emergency change order? you mean a priority=1 change order? Thanks _Chi



  • 3.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-14-2017 02:45 PM

    Chi,

     

    For us, an Emergency (change type) change order can have any priority and/or risk level set. I believe this is partly why the group wants the additional field so the end user can briefly explain why they believe it is an emergency.



  • 4.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-14-2017 04:25 PM

    Katherine, can you add a picture here? That will help the guys to understand the emergency change orders that you env has. Thanks _Chi



  • 5.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-14-2017 04:55 PM

    Here are 2 examples of Change Orders that are set as type= Emergency but have different risk level, priority and impact set.

     

     

     

    Here is a list of current Change Orders set with type = Emergency ... you can see what types of things are being logged.

     

    Also here is the Business Justification field on the Additional Information tab I was thinking of possibly trying to use instead of having to create a new field in the db / schema.

     

     

    I also have an email out to the Change Order group asking them for a little more information on how and why they use Change Orders as well as what defines the number that gets entered into the fields (priority, risk and impact).

     

    thank you

    Katherine



  • 6.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-15-2017 03:02 AM

    hi,

    if you want to store that info in a existing field no need then for extra mdb atributes.

    You will just need a small piece of javascript code  to change the property of this field based on your condition.

     

    /J



  • 7.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-15-2017 01:28 PM

    Can someone posts the js script here, using the Business Justification field as an example?



  • 8.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-18-2017 02:43 AM

    HI Chi Chen,

    Below is a script example writen on the fly so need to be tested.

    You will need to put it in your sitemods folder or if you already have one put the code in your sitemods.js file.

    PresSaveTrigger is already called by SDM so no need to redefine in your form.

    Hope this help.

    /J

    function preSaveTrigger(){

     var factory;
     factory = propFactory;
     if (factory == "chg"){
     element = document.main_form.elements;
      if (typeof element['SET.chgtype'] == "object"){
       if (typeof element['SET.justification'] == "object"){
           var z_chgtype = element['SET.chgtype'].value;
           var z_justification = element['SET.justification'].value;

        if (z_chgtype == '300'){ //emergency type = 300
           var z_justificationid = element['SET.justification'].id;
           var z_justificationtemp = document.getElementById(z_justificationid);
            if (z_justification == ''){
                detailReportValidation(z_justificationtemp,true,'Business justification is required for emergency type change');
             return false
            }
            else {
                detailReportValidation(z_justificationtemp,false);
            }
        }
       }
      }
     }
    return true
    }



  • 9.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-19-2017 09:47 AM

    Thank you for posting the script. I was thinking making the field required(that is, add a * on the field to say this is

    a required field) on the display when the "emergency" is selected.



  • 10.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-19-2017 11:53 AM

    Jerome,

     

    I tried to incorporate the above code into our detail_chg.htmpl file (since this is the only place/form where it would be used) and tested it - results: did NOT work.

    1. Added the code to the file and copied it over to the background, standby and app servers.
    2. Ran the pdm_webcache -v command on the background server to be sure I was using the form with the changes
    3. Started a new Change Order ticket, setting the type = Emergency (Normal is our default setting)
    4. Clicked the Save button
    5. Change Order ticket created ... I was never prompted or saw any message stating that the Business Justification field needed to be filled out before saving or creating ticket

     

    Wondering if this code needs to be in a specific location within the detail_chg file?

    Also while reading over the code I saw where it mentioned that the change order detail form uses the file (xx_propr_tab.htmpl) to display a notebook page for properties ... the same file is used for Issues.

     

    this is the code at the bottom of the file (xx_prop_tab.htmpl) where the notes or business justification fields display

    <PDM_MACRO name=dtlStartRow class=tab>
    <PDM_IF "$prop.form_name_2" == "iss">
    <PDM_MACRO name=dtlTextbox hdr="Notes" attr=justification colspan=4 rows=2 size=80 spellchk=yes>
    <PDM_ELIF "$prop.form_name_2" == "chg">
    <PDM_MACRO name=dtlTextbox hdr="Business Justification" attr=justification colspan=4 rows=2 size=80 spellchk=yes>
    </PDM_IF>
    <PDM_MACRO name=dtlEndTable>

     

     

    Any help on why this failed and did not prompt me to enter data into the Justification field before being able to save the ticket?

     

     

    thank you

    Katherine



  • 11.  Re: Change Order - Required Field for Emergency Type Only
    Best Answer

    Posted 09-20-2017 03:35 AM

    Hello TheKaterine,

    As instructed using the preSaveTrigger, you need to put the script in your \site\mods\www\wwwroot\scripts folder and not in the form itself to ensure this will be loaded.

    The code is filtering the object and will only fire for  the chg object

     

    I did a quick test in a 14.1 dev instance and this work perfectly as you can see below.

     

     

    Please also ensure that you clean your client browser cache as pdm_cache -v will only clean htmpl form.

     or use pdm_webache -b -H-v to inform users to do.

    I do have attach the files itself here for your ease of use

     

    /J



  • 12.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-20-2017 02:35 PM

    Jerome,

     

    Thank you so much for the help.

    I added the code to our current sitemods.js file and cleared my client browser cache - success.

     

    Katherine



  • 13.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-15-2017 03:46 PM

    Yes that is what I was thinking and hoping for - don't want to make too many customizations if not needed. I would like to use the Business Justification field, I'm just not sure exactly how to write the javascript code and if it needs to be in a specific location within the change order form file.



  • 14.  Re: Change Order - Required Field for Emergency Type Only

    Posted 09-15-2017 07:08 AM

    I believe that the Business Justification field was provided in Change order for such scenarios and it will best suit for your requirement to avoid adding additional external columns as part of customizations.



  • 15.  Re: Change Order - Required Field for Emergency Type Only

     
    Posted 09-18-2017 12:17 AM

    Another way to deal with this - if your site uses Change Categories that differentiate between Emergency and other change types - would be to add a mandatory Property to the change category.  However, it looks like that might not be the case at your site.

     

    Another possibility is to use a Data Partition.  For a Create or Update partition you could add "not (chgtype = 300 and justification is null)", with an Error message such as "Please supply Business Justification for an Emergency change", which ought to stop a CO from being created or saved with type 'Emergency' and no text in the Business Justification field.  However that would not of course make the Justification field behave as a mandatory field.

     

    If you decide to go down the Javascript route you could start from this offering by kolja02 : Make text field required when check box is checked .

     

    Hope that helps :-)

    Regards,

    James