We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Pass form value from UI Action to HTML in UI Page

Chenab Khanna
Tera Expert

Hi

I have a requirement to hide few choice values of a field based on HR Service when the button is clicked.

When a user clicks "Rescind" button in Lifecycle event case, a dialog window appears and user is asked to submit Rescind reason. 

My requirement is, based on the HR Service of the LE Case, i need to display certain choice values.

Backend code -

A UI Page is called in the UI Action which is displaying the choice values - 

UI Action - 

ChenabKhanna_0-1665589846290.png

 

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="LE rescind dialog">
<style type="text/css">
#le_rescind_dialog_footer input {
width: 100%;
}

.required-marker {
content: "*";
}
</style>
<script>
$j(document).ready(function() {
$j("#le_rescind_comment").focus();
});
alert("hello "+RP.getWindowProperties().get('sysparm_v1'));
</script>
<g:evaluate var="jvar_sysparm_v1" expression="RP.getWindowProperties().get('sysparm_v1')" />
<g:evaluate object='true' jelly='true'> var isRequired = 'true'; </g:evaluate>
<g:evaluate var="jvar_gr" object='true' jelly='true'> var reasons = JSON.parse(new
sn_hr_le.LifeCycleEventsClientCallableUtil().getRescindReasonsUIAction("${jvar_sysparm_v1}")); </g:evaluate>

 

The lines highlighted in red is how i am trying to pass HR Service as an argument to the script include but it is returning null.

Can anyone help me with correct syntax or any other way to pass a form value from UI Action to HTML in UI Page?

 

 

5 REPLIES 5

-O-
Kilo Patron

All of the above means that your code should be something like:

 

<g2:evaluate var="jvar_reasons" object="true" jelly="true">

var reasons = new sn_hr_le.LifeCycleEventsClientCallableUtil().getRescindReasonsUIAction(jelly.jvar_sysparm_v1);
reasons;

</g2:evaluate>

 

Not the last statement reasons, which basically counts for a return - that is how one does returns in an evaluate node.

After that node, variable jvar_reasons will contain whatever the called method returns.

But, of course, it will only be available in phase 2 spots, like <g2:evaluate/> and $[ ], but not <g:evaluate/> and ${ } too.