
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2021 07:44 AM
Hello All,
I hope this one is simple but I really can't figure it out. I have a UI page with the line
<g:evaluate var="sysparm_number" expression="RP.getWindowProperties().sysparm_number" />
inside of the HTML code. This passes the 'number' field of my form to the HTML and it works great.
My next challenge is passing that same number to the Client Script section in the UI page, how would I go about referencing that sysparm_number variable or is there another way to reference it more directly in the client script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2021 08:02 AM
Hi,
Something like this
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:ui_form>
<g:evaluate var="sysparm_number" expression="RP.getWindowProperties().sysparm_number" />
<input type="hidden" id="sysparm_number" name="sysparm_number" value="${sysparm_number}"/>
<table border="0" width="100%">
<tr>
<td>
<g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script:
function onCancel() {
GlideDialogWindow.get().destroy();
return false;
}
function onSubmit() {
return true;
}
Processing Script:
updateRecord();
function updateRecord() {
var app = new GlideRecord("tableName");
if(app.get('number', sysparm_number)){
app.field1 = 'Your Value';
app.update();
}
var urlOnStack = gs.getUrlOnStack();
response.sendRedirect(urlOnStack);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2021 08:02 AM
Hi,
Something like this
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:ui_form>
<g:evaluate var="sysparm_number" expression="RP.getWindowProperties().sysparm_number" />
<input type="hidden" id="sysparm_number" name="sysparm_number" value="${sysparm_number}"/>
<table border="0" width="100%">
<tr>
<td>
<g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client Script:
function onCancel() {
GlideDialogWindow.get().destroy();
return false;
}
function onSubmit() {
return true;
}
Processing Script:
updateRecord();
function updateRecord() {
var app = new GlideRecord("tableName");
if(app.get('number', sysparm_number)){
app.field1 = 'Your Value';
app.update();
}
var urlOnStack = gs.getUrlOnStack();
response.sendRedirect(urlOnStack);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2021 11:38 AM
Thank you for the help. Unfortunately this still didn't solve my issue because I have the UI page automatically printing the window on load which runs into the same problem as before where it won't let me run the function to update the record until the print window is destroyed but once it is destroyed there is no more code to run. Kind of a catch 22.
This solution did work when I typed it as you explained so hopefully it will help somebody else down the road. Thank you again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2021 09:15 PM
Glad to help
Please remember to mark response helpful as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader