need to remove popup field when clicking on workspace button

Shubham Bongulw
Giga Guru

Hi community,

I have a requirement to remove Business impact field when I click on 'Propose Major incident' button in workspace-

ShubhamBongulw_0-1744968774042.png

 

However, I am unable to trace the UI page who does this can someone help please?

1 REPLY 1

Vishal Jaswal
Giga Sage
Giga Sage

Hello @Shubham Bongulw 

For Workspace:

Navigate to All > System Defintion > UI Actions (Table:sys_ui_action)

VishalJaswal_3-1744996285780.png


Scroll down to Workspace tab and comment the business_impact related code in the Workspace client script and save as shown below:



function onClick(g_form) {
    function proposeMIC(data) {
        var workNotes = data.msg + "\n" + data.workNotes;
        var notes = g_form.getValue('work_notes') + ' ' + workNotes;
        // var bi = g_form.getValue('business_impact') + ' ' + data.businessImpact;
        g_form.setValue('work_notes', notes.trim());
        // g_form.setValue('business_impact', bi.trim());
        g_form.submit('sysverb_mim_propose');
    }
    function openPopup() {
        var missingMandatoryFields = getMissingFields();
        if (missingMandatoryFields.length > 0) {
            g_form.save();
        } else {
            if (!g_form.getControl('work_notes')) {
                getMessage('Cannot propose major incident as "Worknotes" is not visible', function(msg) {
                    g_form.addErrorMessage(msg);
                });
                return false;
            }
            var url = "/sn_major_inc_mgmt_mim_propose.do?sysparm_stack=no&sysparm_workspace=" + true;
            getMessage('Propose Major Incident', function(msg) {
                g_modal.showFrame({
                    title: msg,
                    url: url,
                    size: 'lg',
                    autoCloseOn: 'URL_CHANGED',
                    callback: function(ret, data) {
                        if (ret)
                            proposeMIC(data);
                    }
                });
            });
        }
    }
    function filterForMissingMandatoryFields(field) {
        if (g_form.isMandatory(field)) {
            return !g_form.getValue(field);
        }
    }
    function getMissingFields() {
        var fieldList = g_form.getFieldNames();
        // return only mandatory fields that have no value
        return fieldList.filter(filterForMissingMandatoryFields);
    }
    openPopup();
}



For Native UI: 

Application Scope: Major Incident Management

Navigate to All > System UI > Pages (Table: sys_ui_page)

VishalJaswal_1-1744995874547.png
Name: mim_propose (Apply the filter as shown below)

VishalJaswal_2-1744995911406.png


Comment the Business Impact HTML Code in the HTML Field as shown below:

<?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:evaluate var="jvar_isNextPg" expression="RP.getParameterValue('sysparm_next_pg')"/>
	<j:if test="${jvar_isNextPg == 'true'}">
		<style>
			.no_next {
				display: none !important;
			}
		</style>
	</j:if>
	<style>
		body {
			overflow-x: hidden;
		}
	#mim-propose-form {
		overflow: hidden;
	}
	.form-horizontal {
		margin-top: 5px;
		margin-bottom: 20px;
	}
	.propose-modal-textarea {
		resize: vertical;
		min-height: 120px
	}
	#dialog_buttons .btn{
		margin-left: 10px;
		padding-left: 15px;
		padding-right: 15px;
		text-align: right;
	}
	#work-notes-wrapper .required-marker{
		display: inline-block;
	}
	#work-notes-wrapper label{
		overflow-wrap: break-word;
	}
	#page_timing_div {
		display:none !important;
	}
</style>
	<script>
			var config = {
				workspace: '${JS_STRING:RP.getParameterValue('sysparm_workspace')}' == 'true'
			};
		var iframeMsgHelper = (function () {
				function createPayload(action, modalId, data) {
					return {
						messageType: 'IFRAME_MODAL_MESSAGE_TYPE',
						modalAction: action,
						modalId: modalId,
						data: (data ? data : {})
					};
				}

				function pm(window, payload) {
					if (window.parent === window) {
						console.warn('Parent is missing. Is this called inside an iFrame?');
						return;
					}
					window.parent.postMessage(payload, location.origin);
				}

				function IFrameMessagingHelper(window) {
					this.window = window;
					this.src=location.href;
					this.messageHandler = this.messageHandler.bind(this);
					this.window.addEventListener('message', this.messageHandler);
				}

				IFrameMessagingHelper.prototype.messageHandler = function (e) {
					if (e.data.messageType !== 'IFRAME_MODAL_MESSAGE_TYPE' || e.data.modalAction !== 'IFRAME_MODAL_ACTION_INIT') {
						return;
					}
					this.modalId = e.data.modalId;
				};

				IFrameMessagingHelper.prototype.confirm = function (data) {
					var payload = createPayload('IFRAME_MODAL_ACTION_CONFIRMED', this.modalId, data);
					pm(this.window, payload);
				};

				IFrameMessagingHelper.prototype.cancel = function (data) {
					var payload = createPayload('IFRAME_MODAL_ACTION_CANCELED', this.modalId, data);
					pm(this.window, payload);
				};

				return new IFrameMessagingHelper(window);
			}());

	</script>
<div id="mim-propose-form">
<div class="form-horizontal no_next">
	<div class="form-group" id="work-notes-wrapper">
		<label class="col-sm-2 control-label" for="mim-propose-work-notes">
			<span mandatory="true" class="required-marker"></span>
			${gs.getMessage('Work notes')}
		</label>
		<div class="col-sm-10">
			<textarea required="true" class="form-control propose-modal-textarea" id="mim-propose-work-notes" type="text" oninput="proposeModal.workNotesOnChange()" onchange="proposeModal.workNotesOnChange()"></textarea>
		</div>
	</div>
	<!-- <div class="form-group">
		<label class="col-sm-2 control-label" for="mim-propose-business-impact">${gs.getMessage('Business Impact')}</label>
		<div class="col-sm-10">
			<textarea class="form-control propose-modal-textarea" name="mim-propose-business-impact" id="mim-propose-business-impact"></textarea>
		</div>
	</div>. -->
</div>
<div id="dialog_buttons" class="clearfix pull-right no_next">
		<button type="button" class="btn btn-default" onclick="proposeModal.close()" title="${gs.getMessage('Close the dialog')}">${gs.getMessage('Cancel')}</button>
		<button type="button" class="btn btn-primary disabled" aria-disabled="true" id="mim-propose-button" title="${gs.getMessage('Propose Major Incident')}" onclick="proposeModal.propose()">${gs.getMessage('Propose')}</button>
</div>
</div>
</j:jelly>


Comment the Business Impact related code in the Client script field as shown below:

addLoadEvent(function() {
    (function(global) {
        var workNotes = $("mim-propose-work-notes");
        // var businessImpact = $("mim-propose-business-impact");
        var workNotesWrapper = $('work-notes-wrapper');
        var proposeBtn = $('mim-propose-button');
        var dialog, resizeObserver;
        if(!config.workspace) {
            dialog = GlideModal.prototype.get("sn_major_inc_mgmt_mim_propose");
            var currentWorkNotes = dialog.getPreference('WORK_NOTES');
            if(currentWorkNotes) {
                workNotes.value = currentWorkNotes;
                workNotesOnChange();
            }
            // var currentBusinessImpact = dialog.getPreference('BUSINESS_IMPACT');
            // if(currentBusinessImpact)
            //     businessImpact.value = currentBusinessImpact;
        } else {
            var modalTextAreas = document.querySelectorAll(".propose-modal-textarea");
            var iframeStyle = window.frameElement.style;
            var formContainer = $("mim-propose-form");
            resizeObserver = new ResizeObserver(function(entries) {
                iframeStyle.height = formContainer.offsetHeight + 5 + "px";
            });
            for(var i = 0; i < modalTextAreas.length; i++) {
                resizeObserver.observe(modalTextAreas[i]);
            }
        }
        function _debounce(func, wait, immediate) {
            var timeout;
            return function() {
                var context = this,
                    args = arguments;
                var later = function() {
                    timeout = null;
                    if (!immediate) func.apply(context, args);
                };
                var callNow = immediate && !timeout;
                clearTimeout(timeout);
                timeout = setTimeout(later, wait);
                if (callNow) func.apply(context, args);
            };
        }
        function workNotesOnChange() {
            if (!workNotes.value.trim()) {
                workNotesWrapper.removeClassName('is-filled');
                proposeBtn.addClassName('disabled');
                proposeBtn.writeAttribute('aria-disabled', true);
            } else {
                workNotesWrapper.addClassName('is-filled');
                proposeBtn.removeClassName('disabled');
                proposeBtn.writeAttribute('aria-disabled', false);
            }
        }
        function propose() {
            if (!proposeBtn.hasClassName('disabled')) {
                var msg = getMessage("Proposed as major incident candidate");
                var notes = workNotes.value.trim();
                // var bi = businessImpact.value.trim();
                if(!config.workspace) {
                    g_form.getControl('work_notes').value = msg + "\n" + notes;
                    // if (businessImpact.value && businessImpact.value != currentBusinessImpact)
                    //     g_form.setValue('business_impact', bi);
                    close();
                    gsftSubmit(null, g_form.getFormElement(), 'sysverb_mim_propose');
                } else {
                    iframeMsgHelper.confirm({
                        msg: msg,
                        workNotes: notes
                        // businessImpact: bi
                    });
                }
            }
        }
        function close() {
            if(!config.workspace) {
                dialog.destroy();
            } else {
                resizeObserver.disconnect();
                window.location.href = window.location.href + '&sysparm_next_pg=true';
            }
        }
        global.proposeModal = {
            propose: propose,
            close: close,
            workNotesOnChange: _debounce(workNotesOnChange, 200)
        };
    })(window);
});

 



Additional Information:

Major Incident plugin need to be installed to get the Propose major incident option in Native UI as well as in Workspace:

All > System Defintion > Plugins

VishalJaswal_0-1744995711600.png

 


Hope that helps!