Make the worknote mandatory based on subject person's country & the reason field HR suspenddialogbox

Rishi Ravishank
Tera Contributor

Hello all , 

 

I am looking for some help on setting the field worknote to mandatory in the HR suspend dialog box . 

This should happen if subject person's country is Netherlands / Belgium & the reason is other than user . 

 

Is this possible in the UI page HR Suspend Dialog ? 

 

Looking forward fir your response 🙂 

 

RishiRavishank_0-1696919092959.png

 

Code: (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:evaluate object='true' jelly="true">
var suspension_type = RP.getWindowProperties()["sysparm_suspension_type"];
var tableName = RP.getWindowProperties()["sysparm_table_name"];
var parent = RP.getWindowProperties()["sysparm_parent_case_table_name"];
var sys_id = RP.getWindowProperties()["sysparm_order_sys_id"];
 
if (tableName === 'sn_hr_core_task') {
tableName = parent;
}
<!-- for use in the jelly while loop below -->
var i = 0;

<!-- Querying sys_choice here instead of using GlideChoiceList API
because we want to avoid choices from child tables.
Currently there aren't any APIs that avoid
the choices from the child tables-->
var tableHierarchy = new GlideTableHierarchy(tableName).getTables();
var j = 0;
 
for(var j = 0; j &lt; tableHierarchy.length; j++){
 
var choiceGr = new GlideRecord("sys_choice");
choiceGr.addQuery("element", "sla_suspended_reason");
choiceGr.addQuery("name", tableHierarchy[j]);
choiceGr.addQuery("inactive",false);
choiceGr.addQuery("language", gs.getSession().getLanguage());
choiceGr.orderBy("sequence");
choiceGr.orderBy("label");
choiceGr.query();

if(choiceGr.hasNext())
break;
}

var choiceList = [];
while(choiceGr.next()){
choiceList.push({
"label": choiceGr.getValue("label"),
"value": choiceGr.getValue("value")
});
}

</g:evaluate>

<g:ui_form id="HR Suspend Order">
<!--
Parameters
sysparm_table - type of the object
sysparm_suspension_type - type of suspension
sysparm_state_sys_id - SysID of the suspended object state
sysparm_order_sys_id - SysID of the object to suspend
sysparm_ok_button_name - localized name for the ok button
-->
<style type="text/css">
#suspend_dialog_footer input {
width: 100%;
}
#info_message {
margin-left:10px;
color:#667
}
</style>
<div>
<!-- Add onclick validation -->
<div class="form-group has-error row">
<label class="col-sm-3 control-label" style="text-align:right" for="suspend_reason">${gs.getMessage('Reason')}</label>
<span class="col-sm-9">
<select id="suspend_reason" class="form-control" name="suspend_reason">
<j:while test='${choiceList.length > i}'>
<j:if test="${choiceList[i].value == suspension_type}">
<option value="${choiceList[i].value}" selected='selected'>${choiceList[i].label}</option>
</j:if>
<j:if test="${choiceList[i].value != suspension_type}">
<option value="${choiceList[i].value}">${choiceList[i].label}</option>
</j:if>
<g:evaluate>i++</g:evaluate>
</j:while>
</select>
</span>
</div>
 
<div class="form-group is-required row">
 
<label for="suspend_comments" class="control-label col-sm-3" style="text-align:right">
<span class="required-marker"></span>${gs.getMessage('Work note')}
</label>
<span class="col-sm-9">
 
<input id="suspend_comments" class="col-sm-9 form-control" required="required" rows="3" type="textarea" aria-required="true" placeholder="${gs.getMessage('Work notes')}" name="suspend_comments" />
 
</span>
 
</div>
</div>

<footer id="suspend_dialog_footer" class="modal-footer">
<input type="hidden" id="form_id" name="form_id" value="form.${sys_id}"></input>
<input type="hidden" id="table" name="table" value="${sysparm_table_name}"></input>
<input type="hidden" id="suspension_type" name="suspension_type" value="${sysparm_suspension_type}"></input>
<input type="hidden" id="order_sys_id" name="order_sys_id" value="${sysparm_order_sys_id}"></input>
<input type="hidden" id="button_clicked" name="button_clicked" value="ok"></input>
<button type="button" id="cancel_button" class="btn btn-default" onClick="return submitCancel(); ">
${gs.getMessage('Cancel')}
</button>
<button id="ok_button" class="btn btn-primary" onClick="return submitOk();">
${gs.getMessage('Ok')}
</button>
</footer>
</g:ui_form>
</j:jelly>

 

Thanks in advance,

Rishi

1 REPLY 1

Rishi Ravishank
Tera Contributor

Update :

 

We can ignore the subject person condition which I mentioned above instead just want to set the worknote mandate based on the reason field . 

Can anyone help me with the code in HTML section UI page ?