Disabling certain fields on "Emergency change request"

sifynm
Tera Expert

                Please check my previous post which is mentioned at https://community.servicenow.com/thread/251626?q=Emergency%20change%20request and request your help in completing my task.

                  As mentioned by Mr. Sudharsan Vignesh, I was able to edit the "Interceptor:Change Request" - "Direct to Emergency Change" - update the "Target URL" from "change_request.do?sys_id=-1&sysparm_query=type=emergency" to "change_request.do?sys_id=-1&sysparm_query=type=emergency^priority=1" which serves the purpose and solves the problem, but my requirement is to set the "Priority" field value as "1-Critical", "Risk" value as "Very High" and Impact field value as "1-High" along with which no user should be able to change it and it should appear as "Type" field value "Emergency" which as checked in the "Form Design" is of Label Type "Choice type" > "Dropdown with none" but displays a value as "Emergency" when clicked on URL: Emergency: Unplanned changes necessary to restore service. These changes require CAB authorization o...

                Please find the related screenshots or images.

find_real_file.png

For now I am getting this exception on one of our dev instance.

find_real_file.png

                  Kindly help me completing my task.

1 ACCEPTED SOLUTION

Harish,



                As suggested and recommended by you, I have done the following.



  • I included your code in the client script as mentioned in the screenshot.

find_real_file.png



After which clicking on any of the Change Requests that is Normal, Standard or Emergency.


find_real_file.png



                    I was able to receive all the Priority, Risk and Impact fields on read only mode as per the screenshot for all change requests Normal, Standard and Emergency .


find_real_file.png



  • Hence, I clicked on the "Edit Interceptor" on the right side as mentioned in the screenshot.

find_real_file.png



                  I got the next screen where I could edit each and every change request.


find_real_file.png



  •                   I clicked on change request "Normal" and changed the "Target URL" to change_request.do?sys_id=-1&sysparm_query=type=normal^priority=3^risk=3^impact=3.


find_real_file.png



                  When I clicked on change request as "Normal" I was able to few the screen with Priority = 3 - Moderate, Risk = Moderate and Impact = 3 - Low. This was my requirement, hence helped me to accomplish the task.



find_real_file.png




  • Likewise, I am changing it for another change request which are as mentioned :
  • Standard - change_request.do?sys_id=-1&sysparm_query=type=standard^priority=2^risk=2^impact=2
  • Emergency - change_request.do?sys_id=-1&sysparm_query=type=emergency^priority=1^risk=1^impact=1

View solution in original post

9 REPLIES 9

So when you click on that link. When the form loads all these 3 fields should be read only rite?


In that case you can use onload client script.


function onLoad() {


    //Type appropriate comment here, and begin script below


  g_form.setReadOnly('priority',true);


  g_form.setReadOnly('risk',true);


  g_form.setReadOnly('impact',true);



   


}


Regards
Harish

Harish,



                Yes, you are correct. I also want the priority, risk and impact to be set on critical, very high and high according. Referring to your at https://community.servicenow.com/thread/251626?q=Emergency%20change%20request client script which you have suggested is as mentioned, but for some reason it did not work for me.



Client script:


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


  var chg = g_form.getValue('type');


  alert(chg);


  if(chg=='emergency')


  {


  alert('inside');


  g_form.setValue('priority', 1);


  g_form.setValue('risk',1);


  g_form.setValue('impact',1);



  }


    }


Harish KM
Kilo Patron
Kilo Patron

Check whether alert is coming. make sure field name and choice value are correct. It should be on load since you have a separate link.


Regards
Harish

Harish,



                As suggested and recommended by you, I have done the following.



  • I included your code in the client script as mentioned in the screenshot.

find_real_file.png



After which clicking on any of the Change Requests that is Normal, Standard or Emergency.


find_real_file.png



                    I was able to receive all the Priority, Risk and Impact fields on read only mode as per the screenshot for all change requests Normal, Standard and Emergency .


find_real_file.png



  • Hence, I clicked on the "Edit Interceptor" on the right side as mentioned in the screenshot.

find_real_file.png



                  I got the next screen where I could edit each and every change request.


find_real_file.png



  •                   I clicked on change request "Normal" and changed the "Target URL" to change_request.do?sys_id=-1&sysparm_query=type=normal^priority=3^risk=3^impact=3.


find_real_file.png



                  When I clicked on change request as "Normal" I was able to few the screen with Priority = 3 - Moderate, Risk = Moderate and Impact = 3 - Low. This was my requirement, hence helped me to accomplish the task.



find_real_file.png




  • Likewise, I am changing it for another change request which are as mentioned :
  • Standard - change_request.do?sys_id=-1&sysparm_query=type=standard^priority=2^risk=2^impact=2
  • Emergency - change_request.do?sys_id=-1&sysparm_query=type=emergency^priority=1^risk=1^impact=1

So is it working fine now?


If so close the thread or if you still have issues. let me know


Regards
Harish