Make field Comments Mandatory when fail to certify on Data certification tasks

Vasavi1
Tera Contributor

we have installed Data certification plugin. When assigned to failed to certify the certification element, we want to Make comments Mandatory. And also, Not allow assigned to certify empty values of Certification elements in certification task.

 

 

4 REPLIES 4

sweetgouri
Tera Contributor

Did you get any solution on this?

Melissa Berry
Tera Guru

I am also looking for a solution for this. I found another answer from the link below, but its not working.

 

https://www.servicenow.com/community/developer-forum/how-to-make-the-field-optional-comment-for-chec...

 

Pavel_Mikeska
Tera Expert

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.

This worked! thank you!