Issue with popup glideDialog window

Deepthi13
Tera Expert

Hi Team,

I am getting below error and please find the UI page HTML snippet please guide if there is anything i am missing.


SCRIPT: UI PAGE(HTML)

<?xml version="1.0" encoding="utf-8"?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">
<div style="padding:20px">
<!-- receive sys_id from UI Action -->
<input type="hidden" id="sysparam_sys_id" value="${RP.getParameterValue('sysparam_sys_id')}"/>
<h2>Conflict of Interest</h2>
<p>Do you have a conflict of Interest?</p>

<div style="margin-top:20px">
<button class="btn btn-primary" onclick="submitCOI('YES')">Yes</button>
<button class="btn btn-default" onclick="submitCOI('NO')">No</button>
</div>
</div>

<!-- client script wrapped in CDATA -->

function submitCOI(answer) {
var sysIdEl = document.getElementById('sysparam_sys_id');
var sysId = sysIdEl ? sysIdEl.value : '';

// close current dialog safely
try {
var dlg = window.top.GlideDialogWindow.get();
if (dlg) dlg.destroy();
} catch(e) {}

if (answer === 'YES') {
// open second dialog (details page)
var dlg2 = new GlideDialogWindow('review_coi_yes_details'); // second UI PAGE
dlg2.setTitle('COI Declaration');
dlg2.setWidth(600);
dlg2.setPreference('sysparam_sys_id', sysId); // pass along sys_id
dlg2.render();
return;
}

// NO -> navigate back to record (classic nav)
var url = 'sn_bom_internal_investigation.do' + (sysId ? ('?sys_id=' + sysId) : '');
if (window.top.g_navigation) window.top.g_navigation.open(url);
else window.top.location.href = '/' + url;
}
</j:jelly>

 

Deepthi13_0-1767617949141.png

 

7 REPLIES 7

@Deepthi13 

check below links for help

Demonstration Of UI Pages | Making Incident Form in UI Page 

UI pages 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

AnjaliK64227824
Tera Contributor

Hi Deepthi,
I think you are missing 

<script> tag

<![CDATA[ ... ]]> wrapper
as 

Any JavaScript must be wrapped inside <script> tags

And because Jelly is XML-based, it must be enclosed in CDATA
Kindly check that

sagnicdas
Tera Expert

Hi @Deepthi13 ,

Try the below Process once :

HTML :

<?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_sys_id" expression="RP.getParameterValue('sysparam_sys_id')" />

<div style="padding:20px">
<input type="hidden" id="sysparam_sys_id" value="${jvar_sys_id}""")/>>

<h2>Conflict of Interest</h2>
<p>Do you have a conflict of Interest?</p>

<div style="margin-top:20px">
<button class="btn btn-primary" onclick="submitCOI('YES')">Yes</button>
<button class="btn btn-default" onclick="submitCOI('NO')">No</button>
</div>
</div>
</j:jelly>


Client Controller :

function submitCOI(answer) {
var sysIdEl = document.getElementById('sysparam_sys_id');
var sysId = sysIdEl ? sysIdEl.value : '';

var dlg = GlideModal.get() || GlideDialogWindow.get();
if (dlg) {
dlg.destroy();
}

if (answer === 'YES') {
var dlg2 = new GlideModal('review_coi_yes_details');
dlg2.setTitle('COI Declaration');
dlg2.setWidth(600);
dlg2.setPreference('sysparam_sys_id', sysId);
dlg2.render();
return;
}

// NO -> navigate back to record
var url = 'sn_bom_internal_investigation.do?sys_id=' + sysId;
if (window.top.g_navigation) {
window.top.g_navigation.open(url);
} else {
window.location.href = url;
}
}


Try the code mentioned above... 

If the code is helpful for you please put a like on it...