Making 'Assigned to' mandatory on resolution

KLynch
Kilo Contributor

Hello

I'm a newbie here, implemented Service-now today and this is my first post.

I've had a quick scan of the forum and I've seen some topics that have touched on this - but not being a Java whiz I've not been sure how to tweak the script.

What I want to do is make the 'Assigned to' field mandatory on resolution or closure. At present it's not a mandatory field as we want to assign to groups, but when the Incident is resolved, we need to see who dealt with it.

At present it's possible to resolve an incident whilst leaving the 'Assigned to' field blank.

Any advice appreciated.

Regards

Karen

7 REPLIES 7

richsnipe
Tera Contributor

Old thread, but I'd like to implement this also.   I tried using a UI Policy, but maybe I don't have it configured correctly.   Can someone help me out?



find_real_file.png


Hi Chris - how we have it set


  • OnLoad - checked
  • Global - checked
  • Reverse if false - checked

Ensure you are using the correct field - out of the box ours is "Status"



UI Policy Action


  • Field Name: assigned_to
  • Mandatory: True
  • Visible: Leave Alone
  • Read Only: Leave Alone
  • Policy Action Type: UI Policy Action


Cheers


Blaze2
Kilo Guru

Try this:



UI Action:


Name: Close Task


Table Catalog Task [sc_task]


Order 100


Action Name close_sctask



Active Checked


Show Insert Checked


Show Update Checked


Client Checked


Form Button Checked



Application Global



On Click closeSCTask()


Condition current.state ❤️ && current.approval != 'requested'



Script


//ensure that assigned to is required.


function closeSCTask(){


          if (g_form.getValue('assigned_to') == '') {


                          g_form.setMandatory('assigned_to', true);


                          g_form.showFieldMsg('assigned_to','Assigned to is required when closing a ticket','error');


                          alert('Assigned to is required when closing a ticket');


              return false;


      }



If you want to make anything else mandatory (Notes, Phone number etc) just copy the text and add it after the last   "}" but start it off with if as such:




//ensure that worknotes are required.


function closeSCTask(){


      if (g_form.getValue('work_notes') == '') {


              g_form.setMandatory('work_notes', true);


              g_form.showFieldMsg('work_notes','Work Notes are required when closing a ticket','error');


              alert('Work Notes are required when closing a ticket');


              return false;


      }


//ensure that assigned to is required.


if (g_form.getValue('assigned_to') == '') {


              g_form.setMandatory('assigned_to', true);


              g_form.showFieldMsg('assigned_to','Assigned to is required when closing a ticket','error');


              alert('Assigned to is required when closing a ticket');


              return false;


      }