Need help in passing value from UI Page to UI action?

saint
Tera Expert

Hi Experts,

 

I have a scenarios where,

List choice UI action is on a location table, when I select multiple locations and click the UI action, a record is created for each selected location in one of the custom table, I have achieved this functionality.

Now the further requirement is when user selects the locations and clicks the UI action, he/she should also be able to enter a date which will then be populated in a date field on the new record created in custom table. Let me know if I can solve this with any method other than below which I'm trying.

 

I am using a UI page to show a popup of date field for user input, but now I cannot use my script in UI action itself to pass the values of selected locations. What I want to achive now is  pass the values of selected locations from UI page to UI action to process further or ( pass it from UI page to its processing script and then to SI for updation )

 

Please let me know if any more info or inputs are needed. 

 

Thanks 

1 ACCEPTED SOLUTION

@saint 

can you try this?

    modal.setPreference('sysparm_entity',selected_entities);

Method 1:

 <input type="hidden" name="record_sysIds" id="record_sysIds" value="${sysparm_entity}"/>

Method 2:

<g:evaluate var="jvar_id" expression="RP.getWindowProperties().sysparm_entity"/>

 <input type="hidden" name="record_sysIds" id="record_sysIds" value="${jvar_id}"/>

 

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

View solution in original post

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

@saint 

the selected date on UI page you can pass to the logic which is creating the records into custom table

please share the relevant scripts developed so far

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

@saint 

update as 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 id="scope">
		<g:evaluate var="jvar_id" expression="RP.getParameterValue('entity')"/>
		<input type="hidden" value="${jvar_id}" id="record_sysIds"/>
		<table>
			<tr>
				<td>Due date</td>
				<td><input type="date" id="date_id" name="date"/></td>
				<td><input type="hidden" id="jvar_answer" name="jvar_answer" value=""/></td>
			</tr>
			<g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
		</table>
	</g:ui_form>

</j:jelly>

Client Script:

function onCancel() {
	GlideDialogWindow.get().destroy();
	return false;
} 

function onSubmit() {

	var date = gel('date_id').value;
	var sysIds = gel('record_sysIds').value;

	// now you can use GlideAjax and pass the sysIds and the date selected
}
Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

Thank you very much. I'm using this script, the issue I see currently is, I'm able to see the selected sys_id in my UI action, but when I pass them and try to alert them in the UI page client script onSubmit fucntion I get null. I'm still trying to find what's wrong, please assist if you can.

 

function onSubmit() {

alert("test")// gets printed
	var date = gel('date_id').value;
	var sysIds = gel('record_sysIds').value;
alert(date); // gets printed
alert(sysIds);// returns empty.

 

@saint 

update as this. Also are you using my HTML in the UI page?

function launch() {

var selected_entities = g_list.getChecked(); // I want to pass this value till SI to create new records
***NEED HELP IN THIS****CHECK ABOVE COMMENT****
var modal = new GlideDialogWindow('sn_risk_advanced_scopeduedate');
modal.setTitle('Select Due Date');
modal.setPreference('sysparm_view', 'default');
modal.setPreference('entity',selected_entities);
modal.render();
}

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