- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 12:04 AM - edited 03-14-2024 12:05 AM
Hi Experts! @Dr Atul G- LNG
I have a requirement to make the field "Optional Comment for Checked in Element" Mandatory when a certification is marked as "Failed".
This is to ensure there is always a comment whenever a task is failed certifications.
Any suggestions how to do this would be greatly appreciated.
Thanks,
Shantanu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 03:04 AM
Hello @Shantanu1 ,
thank you for confirming that it worked for you too.
For others, you can copy-paste the script into UI Macro "cert_task_data_button_row".
Do not forget to change UI Messages (System UI > Messages) if you care about localizations.
- Newly created message (alert): Please fill in the mandatory comment before failing to certify.
- Rename "Optional comment for checked elements" messages to "Mandatory comment for checked elements" and change message fields.
<?xml version="1.0" encoding="utf-8"?>
<j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<script>
function toggleCertHelp() {
var el = $("cert_help");
if (el.style.display == "none")
el.show();
else
el.hide();
}
// Function to validate the certification comment
function validateCertComment() {
var mandatoryComment = "${gs.getMessage('Please fill in the mandatory comment before failing to certify.')}";
var commentInput = document.getElementById('cert_comment');
if (commentInput.value == '' || commentInput.value == commentInput.alt) {
alert(mandatoryComment);
return false;
}
return true;
}
</script>
<j:if test="${!jvar_cert_task_active}">
<div class="cert_info">${gs.getMessage("Certification data for Certification Task")} ${certTask.getDisplayValue()}</div>
</j:if>
<j:if test="${jvar_cert_task_active}">
<div><span class="cert_info">${gs.getMessage("Certifications required for Certification Task")} ${certTask.getDisplayValue()} </span><span class="cert_help_toggle pointerhand" onclick="toggleCertHelp()">(${gs.getMessage("toggle help")})</span></div>
<div id="cert_help" style="display:none">
<div class="cert_inst_intro">${gs.getMessage("In the list below, field values requiring certification have a checkbox. To certify one or more field values")}:</div>
<div class="cert_inst"><img id="info_1" src="images/outputmsg_success.gif" style="visibility:hidden"/>${gs.getMessage("1) Check the checkboxes for one or more fields requiring certification")}</div>
<div class="cert_inst"><img id="info_2" src="images/outputmsg_success.gif" style="visibility:hidden"/>${gs.getMessage("2) Type an optional comment - the comment will be added as a tooltip to the certified value")}</div>
<div class="cert_inst_last"><img id="info_3" src="images/outputmsg_success.gif" style="visibility:hidden"/>${gs.getMessage("3) Click the green or red button - the green button certifies the checked field values, the red button fails certification")}</div>
<div class="cert_inst_intro">${gs.getMessage("When a certification button is clicked, the list will refresh to reflect the newly certified field values")}</div>
</div>
<j:if test="${!certTask.cert_instance.instructions.nil()}">
<div id="cert_instructions" style="padding:4px">
${certTask.cert_instance.instructions.getDisplayValue()}
</div>
</j:if>
<div id="cert_buttons">
<j:if test="${certTask.cert_instance.is_building != true}">
<span id="cert_comment_span">
<input id="cert_comment" class="comment_out" size="40"
onkeypress="$('info_2').setStyle({visibility:''});if (event.keyCode == 13) Event.stop(event);"
onfocus="commentFocus(this);"
onblur="commentBlur(this);"
alt="${JS:gs.getMessage('Mandatory comment for checked elements')}"
value="${JS:gs.getMessage('Mandatory comment for checked elements')}"
default_value="${JS:gs.getMessage('Mandatory comment for checked elements')}"/>
</span>
<span>
<image class="pointerhand" src="images/certification_success.png" id="certify_checked_elements" onclick="certifyCheckedElements();" title="${JS:gs.getMessage('Certify checked elements')}"/>
</span>
<span>
<image class="pointerhand" src="images/certification_fail.png" id="fail_checked_elements" onclick="if (validateCertComment()) { failCheckedElements() };" title="${JS:gs.getMessage('Fail certification for checked elements')}"/>
</span>
</j:if>
<j:if test="${jvar_cert_task_active}">
<span id="cert_filter_span">
<select id="cert_filter_select" value="pending" onchange="changeCertificationFilter(this)">
<option value="pending" selected="SELECTED">${gs.getMessage("Show Pending Records")}</option>
<option value="all">${gs.getMessage("Show All Records")}</option>
</select>
</span>
</j:if>
</div>
</j:if>
</j:jelly>
Please mark my answer as Correct if you find it useful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 12:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 02:20 AM
Hey @Community Alums Thanks for sharing the links! Unfortunately the solution provided are not working, i am still looking for a feasible solution.
Thanks,
Shantanu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 02:21 AM
May be log a Now Support case buddy.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 02:15 AM
Hi @Shantanu1
Greetings!
@Community Alums already shared the required link , which i was about to share.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************