How can I access entered value on UI page to client or server side script?

Sagar24
Tera Contributor

I'm trying to open a UI page on clicking of a UI Button on the incident form and it has a input text field so that user can enter the bridge URL and I want to access it in the Server side script because I'm able to access it in client script of UI page as below. Also, is there any way we can send current object from UI action to UI page and access them in both client and processing script?

 

UI action:

find_real_file.png

 

UI Page:

find_real_file.png

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Hi,

you can pass sysId to UI page from UI action and then get it inside processing script

Remember you need to use g:ui_form to submit the UI page for the processing script to run

Sample below

UI Action:

dialog.setPreference('sysid', g_form.getUniqueValue());

UI Page 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="jvar_sysid"
					expression="RP.getWindowProperties().sysid"/> 

		<g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
		<input type="hidden" id="task_sys_id" name="task_sys_id" value="${jvar_sysid}"/>

	</g:ui_form>
</j:jelly>

Processing script:

var taskSysId = task_sys_id;

find_real_file.png

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

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

View solution in original post

11 REPLIES 11

Hi,

you can pass sysId to UI page from UI action and then get it inside processing script

Remember you need to use g:ui_form to submit the UI page for the processing script to run

Sample below

UI Action:

dialog.setPreference('sysid', g_form.getUniqueValue());

UI Page 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="jvar_sysid"
					expression="RP.getWindowProperties().sysid"/> 

		<g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
		<input type="hidden" id="task_sys_id" name="task_sys_id" value="${jvar_sysid}"/>

	</g:ui_form>
</j:jelly>

Processing script:

var taskSysId = task_sys_id;

find_real_file.png

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

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

Kalyani Jangam1
Mega Sage
Mega Sage

Hi, Please check below link if it will help you

 

https://community.servicenow.com/community?id=community_question&sys_id=76bbe0a1db75b454ddb1d9d9689619ee