How to make the "Reason for rejection" and "Comments" fields mandatory on Record Review and Rejection and Record Introduction screens?

How to make the "Reason for rejection" and "Comments" fields mandatory on Record Review and Rejection and Record Introduction screens?

book

Article ID: KB0089566

calendar_today

Updated On:

Products Versions
TIBCO MDM -
Not Applicable -

Description

Description:

Out-of-the-box, it is not possible to make the "Reason for rejection" (on "Record Review and Rejection" page) and "Comments" (on "Record Introduction" page) fields mandatory. This can be achieved by using custominit.html. The custominit.html should be placed under the $MQ_COMMON_DIR/<enterprise_short_name>/htmlprops directory.


Symptoms:
N/A
Cause:
N/A

Issue/Introduction

How to make the "Reason for rejection" and "Comments" fields mandatory on Record Review and Rejection and Record Introduction screens?

Resolution

The following is a sample script, the element IDs may change in future releases:

<SCRIPT id="customInitId" language="JavaScript" type="text/javascript">
function customInit(){
 var scrid = document.getElementById("hiddenScreenID").value;
 if( scrid == 106 ){
  customizeRejectionApprovalScreen();
 } else if( scrid == 413 || scrid == 409 || scrid == 408 ){
  customizeApprovalScreen();
 }
}

function customizeRejectionApprovalScreen(){
 jQuery('form:last').submit(function(event){
  if( !checkReasonForRejection() ){
   if(document.productapproval.action.value != 'cancel'){
    document.productapproval.action.value = "";
    event.preventDefault();
   }
  }
 });
}

function customizeApprovalScreen(){
 jQuery('#btnSubmitImage').bind('click', function(){
  if( jQuery('#SubHeaderComment').val().trim().length == 0 ){
   alert("Comments field can't be empty.");
   event.preventDefault();
  } else {
   doSubmit('PROCESS');
   document.WorkItemForm.submit();
  }
 });
 jQuery('#btnCancelImage').bind('click', function(){
  doSubmit('CANCEL');
  document.WorkItemForm.submit();
 });
 jQuery('form:last').submit(function(event){
  if( jQuery('#SubHeaderComment').val().trim().length == 0 ){
   event.preventDefault();
  } else {
   document.WorkItemForm.submit();
  }
 });
}


function checkReasonForRejection(){
 var canSubmit = true;
 var reasonInput;
 jQuery("td[abbr='reject']").each(function(){
  var tdObj = this;
  jQuery(tdObj).find('input:checked').each(function(){
   reasonInput = jQuery(tdObj).next().find('input');
   if( reasonInput.val().trim().length == 0 ){
    reasonInput.poshytip({content: "Reason can't be empty. Enter the reason for rejection.", showOn

: 'focus', alignTo: 'target', alignX: 'right', alignY: 'center',offsetX: 5})
    .poshytip('hide')
    .css('border-color','red');
    canSubmit = false;
   } else {
    reasonInput.poshytip('destroy')
    .css('border-color','');
   }
  });
 });
 if( canSubmit ){
  return true;
 } else {
  reasonInput.trigger("click");
  return false;
 }
}

</SCRIPT>

Additional Information

N/A