g_form.checkMandatory = false; is not working accross multiple tabs of a change record

David Trotta
Tera Contributor

Hi everyone,

 

I am trying to bypass mandatory fields on a change record when the "Cancel Change Request" UI action is kicked off.

 

Currently, when someone clicks on Cancel Change Request (our UI action) it forces the user to complete all mandatory fields on the form before allowing them to cancel the change request.

 

Our change records have multiple tabs - a Planning tab with details of change, and Schedule tab with start and end dates of change window.  Both tabs contain mandatory fields.

 

Here is my issue.  The below script command works great on the main Planning tab and removes mandatory requirements for all the fields on that tab, but it doesn't apply to the Schedule tab.  I still have to populate the Start and End date fields on the Schedule tab before it will allow me to cancel the change

g_form.checkMandatory = false;
 
How do I configure the script to perform the function on ALL tabs within the change record?  I've even tried specifically calling out the Start and End date fields in the UI action (see below), but that doesn't work either.
 
function cancel(){  
  if(confirm("Are you sure you want to cancel this change?")){  
    //Cancel mandatory requirement on fields
    g_form.checkMandatory = false;
    g_form.setMandatory('start_date','false');
    g_form.setMandatory('end_date','false');
  //Call the UI Action and skip the 'onclick' function  
  gsftSubmit(null, g_form.getFormElement(), 'cancel_change_request'); //MUST call the 'Action name' set in this UI Action  
  return true;  //Abort submission  
  }  
  return false;  
 

Thanks in advance for any guidance on how to handle

 

Dave

7 REPLIES 7

Brian Lancaster
Tera Sage

What state is the change in? Out of the box nothing is mandatory until you request approval. So if they have requested approval already these fields should have been filled out.

Edit: You can check  your UI policies that make fields mandatory and make sure the canceled is not selected as a state where things are mandatory.

BrianLancaster_0-1715703125227.png

 

We use a custom Cancel Change Request UI action.  Here is what happens, for example, the CR gets rejected based on various business rules, which automatically clears out the start and end date fields, and forces the user to re-enter and submit for approval.  But, for various reasons, the user decides to just cancel the request, but cannot until the start and end date fields are repopulated.

I think you best be would be to make sure cancel state is not selected in the UI Polices that make the fields mandatory. That way when you UI Action sets the state to canceled it should revers the UI Policy and make everything not mandatory.

Thanks Brian.  I did take a look at the UI polices and didn't see any conflicts.  I think the issue is a little different though.  The script won't progress to set the State to Cancelled until all mandatory fields are populated.  Plus, the script works on mandatory fields (sets the requirement to "false") on the Planning tab, but not fields located on the other tab (Schedule tab) in CR.

 

DavidTrotta_0-1715706109689.png