Business rule is not generating the error message but is aborting the action as expected

Rhonda9
Tera Expert

Hello,

 

I need help with a business rule I created to validate if a person attempt to create a timesheet with the date 30 days in future to abort action from mobile agent.  The br is aborting the action as expected but none of the error messages are being displayed.  The message I am getting is "no results found".

   Here is the before business rule 
// Ensure the required field is available
    if (!current.week_starts_on) {
        current.addErrorMessage('The "week_starts_on" field is required.');
        return;
    }

    // Get the current date and add 30 days
    var curDate = new GlideDateTime();
    curDate.addDaysLocalTime(30);

    // Convert the 'week_starts_on' field to GlideDateTime
    var wsoDate = new GlideDateTime(current.week_starts_on);

    // Log for troubleshooting
    gs.debug('Current date: ' + curDate + ', Week start date: ' + wsoDate);

    // Compare dates and check if the 'week_starts_on' date is more than 30 days in the future
    if (wsoDate.compareTo(curDate) > 0) {
        current.addErrorMessage('You cannot submit a time card for a date more than 30 days in the future.');
       
        // Abort the action to prevent the time sheet from being created
        current.setAbortAction(true);

        gs.debug('Action aborted due to invalid "week_starts_on" date.');
        return;
    }
})(current, previous
7 REPLIES 7

Here's a screenshot of how my BR is defined.

 

Screenshot 2024-11-23 160706.png

 

And a screenshot of the "Default time Sheet Policy" in my instance.

Screenshot 2024-11-23 161112.png

Community Alums
Not applicable

current.addErrorMessage or gs.addErrorMessage?