How to prevent the state of a case from reverting to "New" after being set to "Open"

is_12
Tera Contributor

Hello Community,

 

When the request is created from the case in workspace/native UI, then the state of the case should not move back to New. How to prevent this.

 

Requirement : when state of existing request is moved to work in progress  then state of case is moved from new to open ( functionality is already there). When one more request is created for the same case then state of case is moving back to new. Ideally it should be in the open only How to restrict it

 

There is already one BEFORE BR on sc_request for state sync.

 

Tried this way 

if (current.state == 1 && b2bCase.state == 10) {
current.setAbortAction(true);
return;
}

but for the second time request is not getting created.

Thanks,

 

 

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@is_12 

I suggest this

1) modify the logic so that case state is only set to "New" if it's not already in progressed state

2) script like this but please enhance

// Assume b2bCase is the GlideRecord for the associated case
if (b2bCase.state != 1) { // 1 = "New"
    // Do NOT update the case state back to "New"
    // Optionally, add logic to ensure state is set to "Open" or remains as is
} else {
    // If the case is still "New", move it to "Open"
    b2bCase.state = 10; // 10 = "Open"
    b2bCase.update();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar

in the if block

I Tried to add the abort action, but is it restricting request.

So can you help me with the logic to retrict the state

 

Thanks

@is_12 

you can use current.setAbortAction(true) to stop the update

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

Yeah but current.setAbortAction(true) BR is on the sc_request Table

So it is restricting the request creation for the 2nd time

 

Thanks,