I want to assign to and resolve by  name, which should be the same  when we submit the incident

aggarwaltan
Tera Contributor

I want to assign to and resolve by  name, which should be the same  when we submit the incident 

when it's a different name it should not take it and throws a message that a different name should not be there 

Although perform all these things in business logic not in the UI Scripts. 

4 REPLIES 4

Murthy Ch
Giga Sage

@aggarwaltan 

So you want to achieve this via BR?

Thanks,
Murthy

Yesss can you help on that ? 

Runjay Patel
Giga Sage

Hi @aggarwaltan ,

 

while submitting the incident why you want to set resolved by, normally it should populate while resolving the in incident.

 

you can write before br and condition that if the assigned to is same as resolve by then in action section check the checkbox abort action and add your message in message attribute which you want to display.

 

Singha8
Tera Expert

Hi @aggarwaltan 

 

Solution using a Business Rule

Follow these steps:

1. Navigate to Business Rules:

Go to System Definition > Business Rules and click New.

 

2. Configure the Business Rule:

Name: Enforce Assigned to and Resolved by

Table: Incident

When to run: Before Insert and Update

Condition: (No specific condition; applies to all incidents)

Advanced: Check the "Advanced" box..

3. Script:

  • Add the following script under the"Advanced" tab:

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

    // Ensure both 'Assigned to' and 'Resolved by' are populated

    if (current.assigned_to && current.resolved_by) {

        if (current.assigned_to.toString() !== current.resolved_by.toString()) {

            gs.addErrorMessage("Assigned to and Resolved by must be the same person.");

            current.setAbortAction(true); // Prevent the incident from being submitted

        }

    }

})(current, previous);

 

4. Save and activate.

 

If this answer was helpful, kindly mark it as helpful so others can benefit too!

Thank you,

Ananya.