Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Created by Jensen Mathews, Sky UK
  3.  * Created on 24/02/2017
  4.  *
  5.  *  This action will cancel the change
  6.  *
  7.  */
  8.  
  9. function sp_cancelChange(){
  10.    
  11.     g_form.modified = false; // We don't want to horrible 1980's OOTB popup alert
  12.     var items = $$('BUTTON').each(function(item){ // We are now in the branch of the implemented process so only valid actions should be available
  13.         if(item.id == 'sp_cancel_change' || item.id == 'sp_reject_cancel'){ // Need to add a cancel button
  14.             item.show();
  15.         } else {
  16.             item.hide();
  17.         }
  18.     });
  19.    
  20.     var CLOSED = '3';
  21.    
  22.     g_form.clearMessages(); // Reset the form and field messages
  23.     g_form.hideFieldMsg('work_notes', true);
  24.     g_form.setValue('state', CLOSED);
  25.     if (g_user.hasRole('change_manager')) {
  26.         g_form.setValue('u_substate', 'Rejected'); //reject the change, if a change manager cancels. For reporting purposes
  27.     } else {
  28.         g_form.setValue('u_substate', 'Cancelled');
  29.     }
  30.     g_form.setReadOnly('u_substate', true);
  31.     g_form.setMandatory('work_notes', true);
  32.    
  33.     var work_notes = g_form.getValue('work_notes').toString().trim();
  34.    
  35.     if(work_notes == ''){
  36.         g_tabs2Sections.setActive(1); // Move to the relevant tab
  37.         g_form.addErrorMessage('Please input a work note with the reason for Cancelling this change');
  38.         g_form.showFieldMsg('work_notes','Please input a work note with the reason for Cancelling this change','error');
  39.        
  40.         return false;
  41.     }
  42.    
  43.     if (confirm("If you proceed, the Change and any related tasks will be cancelled.") == true) {
  44.         gsftSubmit(null, g_form.getFormElement(), 'sp_cancel_change');
  45.     } else {
  46.         reloadWindow(window);
  47.         return;
  48.     }
  49. }
  50.  
  51. if (typeof window == 'undefined'){ // On Submit of the form the Server side action should be completed
  52.     updateAndRedirect();
  53. }
  54.  
  55. function updateAndRedirect() {
  56.     current.update();
  57.     action.setRedirectURL(current);
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement