Overriding Script Include: Question?

Community Alums
Not applicable

Hey Everyone, 

 

I learned that you can override ServiceNow's read only script includes by extending using the Object.extendsObjext. 

 

Below is the editable script include. I thought if I copied and pasted the function that I wanted to override in MIMWorkbenchUtilSNC, it would override, but it isn't. What am I missing? 

 

Script Include.PNG

 

The code from the read only script include. 

Script Include II.PNG

 

Has anyone tried this? Please let me know. 

5 REPLIES 5

Filip12
Tera Contributor

You can for sure extend a Script include and override the methods. But that also mean, that the new Script Include would have to be called instead of the original one.

Community Alums
Not applicable

Quick Question, 

 

What do you mean? 

 

I'm calling the script include within the UI Page (the one that I created), but it isn't working. 

 

It isn't overriding. 

Community Alums
Not applicable

Here is the code for UI page. 

<g:evaluate var="jvar_sysparm_sys_id" expression="RP.getParameterValue('sysparm_sys_id')" jelly="true"/>

	<g:evaluate var="jvar_incidentgr" jelly="true" object="true">
		var incidentGr = new GlideRecord('incident');
		incidentGr.get(RP.getParameterValue('sysparm_sys_id'));
		incidentGr;
	</g:evaluate>

	<g:evaluate var="jvar_iframeUrl" jelly="true" object="true">
		var uiPage = gs.getProperty('sn_major_inc_mgmt.pir_export_pdf_ui_page');
		var iframeUrl = uiPage + '?sysparm_sys_id=' + RP.getParameterValue('sysparm_sys_id');
		iframeUrl;
	</g:evaluate>

	<g:evaluate var="jvar_canExportPIR" jelly="true" object="true">
		var canExportPIR = new global.MIMWorkbenchUtil().canExportPIR(jelly.jvar_incidentgr);
		canExportPIR;
	</g:evaluate>
	
	<g:evaluate var="jvar_canExportToPDF" jelly="true">
		var canExportToPDF = new global.MIMWorkbenchUtil().canExportToPDF();
		canExportToPDF;
	</g:evaluate>

	<j:if test="${incidentGr.isValid() == false}">
		<div class="notification notification-danger" style="margin: 10px;">
			<div class="outputmsg_text">
				${gs.getMessage('Invalid Incident SysId')}
			</div>
		</div>
	</j:if>

	<j:if test="${incidentGr.isValid() == true &amp;&amp; canExportPIR == false}">
		<div class="notification notification-danger" style="margin: 10px;">
			<div class="outputmsg_text">
				${gs.getMessage('Security constraints prevent viewing this page')}
			</div>
		</div>
	</j:if>

	<j:if test="${incidentGr.isValid() == true &amp;&amp; canExportPIR == true}">
	<div class="preview-header">
		<div class="left">
			<h2>${gs.getMessage('Post Incident Report')}</h2>
		</div>
		<j:if test="${jvar_canExportToPDF == true}">
			<div class="right">
				<button onclick="exportPDF();" class="btn btn-primary download-report">${gs.getMessage('Download Report PDF')}</button>
			</div>
		</j:if>
	</div>
	<div class="preview_iframe">
		<iframe src="${jvar_iframeUrl}" width="100%" height="100%"/>
	</div>
	<input type="hidden" id="url" name='url' value="${jvar_iframeUrl}" />
	</j:if>

Narsing1
Mega Sage

I think since this is a client callable script include, you cannot pass the parameters while initializing.  You need to use "this.getParameter" in your initialization script and in your UI Page need to use GlideAjax

Thanks,

Narsing