Add required question to interceptor

taddparris
Kilo Expert

Wondering if I can achieve a mandatory field value and make it required.   Currently we use the Change Request interceptors with three questions.   Normal Change, Standard Change, and Emergency Change.   Currently if you select Emergency Change it opens up the Emergency Change record.   This is fine, but we would like to ask a required question before the record opens.   That question would be that the user selects the Priority 1 or Priority 2 Incident that the Emergency Change is resolving.   I am new at Interceptors and the knowledge article look outdated.   I will also add that we do not appear to have Wizards enabled so I am looking for an alternative.

Below is what we envision it would look like... TYIA

Step 1

find_real_file.png

Step 2: Select Emergency Change

*Would like this question to be a Reference Field or a field that will only accepted incident.priority(1) || incident.priority(2)

What P1/P2 Incident will this resolve?

8 REPLIES 8

Do you need to transfer anything to the new change_request form? If not then it's easy, if yes, then you also need to create a formatter that grabs the passed value from the URL sysparm.



A UI page could look like this:



HTML



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<g:ui_form>


  <input type="hidden" id="submit_cancelled" name="submit_cancelled" value="false"/>


    <!-- Set up form fields and labels -->


    <table width="100%">


        <tr id="description_row" valign="top">


              <td colspan="2" style="text-align:right;">


                    <!-- Short description value used as a label -->


                    ${gs.getMessage('What P1/P2 incident will this resolve?')}


              </td>


        </tr>


        <tr>            


      <td style="text-align:right;"><label>${gs.getMessage('Incident:')}$[SP]</label></td>


            <td><g:ui_reference name="select_incident" id="select_incident" table="incident" query="active=true^priority=1^ORpriority=2"/></td>    


        </tr>


        <tr>


            <td colspan="2">


            </td>


        </tr>


        <tr id="dialog_buttons">


              <td colspan="2" align="right">


                    <!-- Pull in 'dialog_buttons_ok_cancel' UI Macro for submit/cancel buttons.


                  'ok' option will call the 'actionOk' Client script function from the UI Page-->


                    <g:dialog_buttons_ok_cancel ok='return actionOk()' cancel="actionCancel()" />


              </td>


        </tr>


  </table>


</g:ui_form>


</j:jelly>



Client Script



function actionCancel() {


  var c = gel('submit_cancelled');


  c.value = "true";


  GlideDialogWindow.get().destroy();


}




function actionOk() {


  var incident = gel('select_incident').value;


  if (incident != '' && incident != undefined && incident != null){


  return true;


  }


  alert('Please select an incident');


  return false;


}



Processing script



if (submit_cancelled == "false") {


  response.sendRedirect("change_request.do");


}


Tadd, if you are just selecting which P1 or P2 incident you are resolving with the change, why not have a reference field on the Emergency form, made mandatory. And in the reference field use an advanced reference qualifier to list only incidents that are active, P1 and P2, and any other filters required.


This is the new option we are considering and will likely use.   Before a user can submit an Emergency change they must related the P1/P2 Incident.


Hi Tadd, sorry to bother you again, but be reminded that this solution will result in a one to one relation. In that you would be able to select one P1 or P2 incident for a change. What id the change is going to solve multiple incidents? In this case you might consider out of the box functionality were you can link incidents to a change, or 1 incident to multiple changes. Am referring to the "Related Links"