- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2023 11:23 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 05:48 AM
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}"/>
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2023 11:36 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 02:45 AM
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
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 04:11 AM - edited 06-19-2023 04:12 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 04:16 AM
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();
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader