How to prevent users from submitting new change task record?

thrsdy1512
Tera Expert

**submitted in wrong forum by mistake**

 

I need to prevent users from being able to create new change tasks where type = type A, these tasks can only be created automatically when a Change Request is progressed to the Assess state.

I have a before insert business rule that is running on the change_task table where the task type = type A to prevent submission & display error message, which works.

 

The issue I have is when a Change Request move to the Assess state, the change request is displaying the error message. the change task is being created automatically &  and it shows in the change_task table as being created by the same user ID as the person creating the change req. I want this error msg to only be displayed on the change task itself where a user is creating it directly from the change_task table.

 

How can I prevent this error message from being displayed on the change request form when the change req state triggers the creation of the task type = type a.

 

Business rule is:

 

(function executeRule(current, previous /*null when async*/) {

    if (current.change_task_type == 'peer_review') {
     

         
            gs.addErrorMessage('This task cannot be created by users. This  can only be created by the system when progressing a Change request.');

            // Prevent the record from being saved
            current.setAbortAction(true);
        }
    }
)(current, previous);
1 REPLY 1

Voona Rohila
Kilo Patron
Kilo Patron

Hi @thrsdy1512 

The BR is written on which table?

The BR Should be on change task table and add filter conditions 

change_task_type || is || Peer Review

(function executeRule(current, previous /*null when async*/) {

  
            gs.addErrorMessage('This task cannot be created by users. This  can only be created by the system when progressing a Change request.');
            current.setAbortAction(true);
        
    
)(current, previous);

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP