give the code for following creitiria on basis of Businees Rule

Apoorva A H
Tera Contributor

As an LOA user I need the employee's task and LOA Advocate task to be canceled if the request was canceled.

  1. Verify that if the request is cancel then the state of the all task is "Cancelled" (employee and LOA Advocate task)
  2. Verify that if the state of the task is "Cancelled" then the fields are non-editable (grey out) for the Advocate.
  3. Verify that no changes are needed if the task's state is "Closed" when the request is canceled.
3 REPLIES 3

AnveshKumar M
Tera Sage
Tera Sage

Hi @Apoorva A H ,

 

Are these things on Catalog Request and Catalog Task or a different module.

 

Thanks,
Anvesh

It is in request module.

Amit Gujarathi
Giga Sage
Giga Sage

HI @Apoorva A H ,
I trust you are doing great.
Sample Business Rule Script:

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

    if (current.state == 'cancelled') { // assuming 'cancelled' is the correct state value
        var grTask = new GlideRecord('task_table_name'); // replace 'task_table_name' with your task table name
        grTask.addQuery('request', current.sys_id); // assuming 'request' is the field linking task to request
        grTask.query();

        while (grTask.next()) {
            grTask.state = 'cancelled'; // set to your 'Cancelled' state value
            grTask.setWorkflow(false); // to prevent any further business rules from triggering
            grTask.update();
        }
    }

})(current, previous);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi