- 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-19-2023 04:25 AM
I tried this, it still returns empty. I'm using jelly, for buttons I have used <button> tag directly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 04:33 AM
please use <g:dialog>
can you share your updated UI page HTML and client script?
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:35 AM
let me share the code now
UI ACTION:
function launch() {
var selected_entities = g_list.getChecked();
alert(selected_entities); // SHOWS ALL SYSIDs
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();
}
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 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>
</tr>
<tr>
<td><button type="reset" onClick="onReset()" class="btn-primary btn" name="reset" id="reset" style="min-width: 5em">${gs.getMessage('Reset')}</button></td>
<td><button type="submit" onClick="onSubmit()" class="btn-primary btn" name="submit" id="submit" style="min-width: 5em">${gs.getMessage('Submit')}</button></td>
</tr>
</table>
</g:ui_form>
</j:jelly>
UI PAGE CLIENT SCRIPT
function onReset() {
document.getElementById("scope").reset();
}
function onSubmit() {
alert("Inside submit");
var date = gel('date_id').value;
var sysIds = gel('record_sysIds').value;
alert("date : " + date);
alert("SysId : " + gel('record_sysIds').value);
var ga = new GlideAjax('sn_risk_advanced.LRAUtils');
ga.addParam('sysparm_name', 'createScopeForEntity');
ga.addParam('sysparm_selected_entities', sysIds);
ga.addParam('sysparm_due_date', date);
ga.getXML(doAfterServerResponse);
/*Throws error alert when entity scope already exists*/
function doAfterServerResponse(response) {
var ans = response.responseXML.documentElement.getAttribute("answer");
if (ans > 0)
alert("Few records could not be added as record with same risk assessment methodology and entity already exists");
g_navigation.reloadWindow();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 05:19 AM
@Ankur Bawiskar I tried passing a string value in UI action, as below
modal.setPreference('entity',"SYSID_OF_A_RECORD");
Still in the onSubmit CS of UI page alert came as null.
the value is not passing through
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 05:26 AM
I think you are in scoped app.
Can you please try this?
<input type="hidden" name="record_sysIds" id="record_sysIds" value="${entity}"/>
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader