Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Jensen Mathews, Sky UK
- * Created on 24/02/2017
- *
- * This action will cancel the change
- *
- */
- function sp_cancelChange(){
- g_form.modified = false; // We don't want to horrible 1980's OOTB popup alert
- var items = $$('BUTTON').each(function(item){ // We are now in the branch of the implemented process so only valid actions should be available
- if(item.id == 'sp_cancel_change' || item.id == 'sp_reject_cancel'){ // Need to add a cancel button
- item.show();
- } else {
- item.hide();
- }
- });
- var CLOSED = '3';
- g_form.clearMessages(); // Reset the form and field messages
- g_form.hideFieldMsg('work_notes', true);
- g_form.setValue('state', CLOSED);
- if (g_user.hasRole('change_manager')) {
- g_form.setValue('u_substate', 'Rejected'); //reject the change, if a change manager cancels. For reporting purposes
- } else {
- g_form.setValue('u_substate', 'Cancelled');
- }
- g_form.setReadOnly('u_substate', true);
- g_form.setMandatory('work_notes', true);
- var work_notes = g_form.getValue('work_notes').toString().trim();
- if(work_notes == ''){
- g_tabs2Sections.setActive(1); // Move to the relevant tab
- g_form.addErrorMessage('Please input a work note with the reason for Cancelling this change');
- g_form.showFieldMsg('work_notes','Please input a work note with the reason for Cancelling this change','error');
- return false;
- }
- if (confirm("If you proceed, the Change and any related tasks will be cancelled.") == true) {
- gsftSubmit(null, g_form.getFormElement(), 'sp_cancel_change');
- } else {
- reloadWindow(window);
- return;
- }
- }
- if (typeof window == 'undefined'){ // On Submit of the form the Server side action should be completed
- updateAndRedirect();
- }
- function updateAndRedirect() {
- current.update();
- action.setRedirectURL(current);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement