- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 03:47 AM
I have defined two variables in my html code as below :
<g:evaluate var="jvar_number" expression="RP.getWindowProperties().get('sysparm_number')" />
<g:evaluate var="jvar_createdBy" expression="RP.getWindowProperties().get('sysparm_createdBy')" />
<p>${jvar_number}</p>
<p>${jvar_createdBy}</p
Getting these values displayed as expected on ui page.
I am trying to access this on my client script using alert.
I am trying this in my client script..
var nm = gel('jvar_number').value;
alert(nm);
But this alert is not coming..Is this because id needs to be passed ?
Also, can i access this in processing script also becasue i need to append these parameters in my redirection url.
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 04:03 AM
Hello,
I think yes you need to use document.getElementById('your ID').value;
please add this piece of code in your UI page HTML part
<input type="hidden" value=${jvar_number}/ id="value1">
Also add this in client script to access the value
alert(document.getElementById('value1').value);
Please try this and if it works please mark my answer correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 04:03 AM
Hello,
I think yes you need to use document.getElementById('your ID').value;
please add this piece of code in your UI page HTML part
<input type="hidden" value=${jvar_number}/ id="value1">
Also add this in client script to access the value
alert(document.getElementById('value1').value);
Please try this and if it works please mark my answer correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 04:16 AM
This helped. Thanks !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 04:34 AM
Hi Mohith,
how can i access this in my processing script ?
I have to create a url where these parameters will append.
and this url will be redirected, so i need these values in processing script as well i guess.
referring this solution but it's not working in my case..
https://community.servicenow.com/community?id=community_question&sys_id=9d9fe5b5dba6dcd4d5c4d9d9689619c2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 05:12 AM
Hello,
Please try the below method
UI page process scripts
If your UI page contains a form (uses the <g:form> tag), you can submit the form and have the process script run.
Make sure your HTML code is enclosed between <g:ui_form> your HTML code </g:ui_form>
<g:ui_form><p>Click OK to run the processing script.</p> <g:dialog_buttons_ok_cancel ok = "return true"/> <input type = "hidden" name = "application_sys_id" value = "499836460a0a0b1700003e7ad950b5da"/> </g:ui_form>
var application = new GlideRecord('hr_application');
application.get(application_sys_id);
application.status = "Rejected";
application.update();
var urlOnStack = GlideSession.get().getStack().bottom();
response.sendRedirect(urlOnStack);
Please mark it helpful if it helped you