- 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 05:43 AM
Yes, both the UI action and UI page are in same scope, I tried the below line no luck as of now. will check further.
<input type="hidden" name="record_sysIds" id="record_sysIds" value="${entity}"/>
- 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-20-2023 01:43 AM
Hi Ankur,
I was able to see the sys_id with Method 2.
Method 2:
<g:evaluate var="jvar_id" expression="RP.getWindowProperties().sysparm_entity"/> <input type="hidden" name="record_sysIds" id="record_sysIds" value="${jvar_id}"/>
It worked. Thank you very much for the help and support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 05:21 AM
can you check if value comes here?
<?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"/>
<p>${jvar_id}</p>
<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>
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 12:41 AM
Hi @saint , I had a similar requirement and I achieved it via calling Script Include from UI Page itself.
- Added a button to footer on UI Page and and called a function On click of the button.
<footer class="modal-footer">
<button class="btn-default btn" style="min-width: 5em" onclick="return onCancel();" name="cancel" id="cancel">${gs.getMessage('Cancel')}</button>
<button class="btn-primary btn" onclick="return onSubmit();" name="submit" id="submit" style="min-width: 5em">${gs.getMessage('Submit')}</button>
</footer>
- Written function definition in Client Script of UI Page as below :
function onSubmit() {
if (!isSubmitted) {
var ga = new GlideAjax("SNUtils");
ga.addParam('sysparm_name', "createInitiativeTask");
ga.addParam('sysparm_expectedDate', trim(gel("expected-target-date-input").value)); //Passed selected date as parameter
ga.addParam('sysparm_expectationFromSIS', trim(gel("expectation-text-area").value));
ga.getXML(validateSubmission);
isSubmitted = true;
setTimeout(refresh, 700);
return false;
} else {
return false;
}
function validateSubmission(response) {
GlideDialogWindow.get().destroy();
var answer = JSON.parse(response.responseXML.documentElement.getAttribute('answer'));
return false;
}