How to make the field 'Optional comment for checked elements' mandatory when failing the checked certification elements?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2018 04:11 AM
On Certification task form there is a ui macro(cert_task_data_button_row) field 'Optional comment for checked elements' above the certification elements list. We have requirements to make that field mandatory when someone clicks on the red '!' icon to fail the checked cert elements.
Does anyone know an way to do that?
I checked the following article with the same requirement, but no solution provided there-
https://community.servicenow.com/community?id=community_question&sys_id=624f3e69db58dbc01dcaf3231f961955
- Labels:
-
Instance Configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2022 02:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 05:37 AM
Hello,
all you have to do is to change UI Macro "cert_task_data_button_row".
In the <script> part add this code:
// 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;
}
Change in the script the button slightly:
<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>
Also the default text for cert_comment element could be changed. Do not forget then to change UI Messages:
<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>
Please mark my answer as Correct if you find it useful.