How to pass reference field value to <script> tag in html of UI Page?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 09:02 PM - edited 02-05-2024 09:03 PM
Hi Community,
Below is the highlighted html script where I need to pass reference field value to script tag:-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 09:35 PM
Hello @Ankita Kolhe ,
Using getElementById method yo can get field value in script tag:
<script>
var entity = document.getElementById('entity').value;
</script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 09:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 10:09 PM
Add alert and check the value of the entity and please let me know.
<script>
var entity = document.getElementById('entity').value;
alert(entity);
</script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 10:26 PM
Hello @Ankita Kolhe
Give a try to the code below and see how it works for you.
<?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:evaluate var="jvar_isNextPg" expression="RP.getParameterValue('sysparm_next_pg')"/>
<j:choose>
<j:when test="${jvar_isNextPg != 'true'}">
<script>
// Extract the value of the reference field "entity"
var entityValue = g_form.getValue('entity');
// Pass the value to the IFrameMessagingHelper.prototype.confirm method
iframeMsgHelper.confirm(entityValue);
</script>
<script>
// ... Your existing script continues here
// Ensure the rest of your script is not affected by the modification
document.getElementById("ok_button").focus();
</script>
<g:ui_form>
<g:ui_reference name="entity" id="entity" table="x_kpm79_kpmgi_iogc_kpmgi_iogc_entity_management_base" completer="AJAXTableCompleter" ng-model="group"/>
<g:dialog_buttons_ok_cancel ok="return ok()" ok_style_class="btn btn-destructive" ok_text="${gs.getMessage('Submit')}" cancel="return cancel()" ok_type="button" cancel_type="button"/>
</g:ui_form>
</j:when>
<j:otherwise></j:otherwise>
</j:choose>
<style>
.btn-destructive {
background-color: rgb(220, 20, 60);
}
.outputmsg_div, #page_timing_div {
display:none !important;
}
.modal-alert, .modal-md {
width: 100%;
}
.modal-alert .modal-footer {
padding: 10px 0px;
}
.modal-md .modal-footer {
padding: 20px 10px 5px;
}
div.empty-space:after {
content: "\00a0";
}
</style>
</j:jelly>
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket