The CreatorCon Call for Content is officially open! Get started here.

Check that the Incident State moves to 'In progress'

Mark_10
Tera Contributor

Hi,

I have an issue where if the Incident state is moved from 'New' straight to 'Resolved' then the SLA Definition is not attached to the Incident record. Ideally I need to force the user to move the Incident state from 'New' to 'In progress' before it is moved to 'Resolved'.

 

I believe I need to create a Client Script but I'm not sure on the script to validate if the Incident State value has moved to 'In progress' before it is moved to 'Resolve'.

 

Any help appreciated.

 

Thank you in advance!

 

 

1 ACCEPTED SOLUTION

This needs to be done on onchange client script with the state filed as the column

if (oldValue == newValue)
        return;
	
	if(oldValue == "2" && newValue =="6"){
		//write your script
	}
Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

View solution in original post

6 REPLIES 6

Murthy Ch
Giga Sage

Hi @Mark_10 

You can do this using before update BR on your incident table.

Use the below logic and update it as per your needs if necessary.

Give the BR condition like when state changes

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

    // Add your code here
    if (previous.state == "1" && current.state == "6") { //please map your state values it it's different
        gs.addErrorMessage("You cannot change the state directly from New to Resolved");
        current.setAbortAction(true);
    }
//it will if the state is new and if the user is changing the state to resolved it will abort the action and throws the error message..
})(current, previous);

or if you want to go with no code follow the below images:

MurthyCh_0-1674167536356.png

 

MurthyCh_2-1674167559457.png

Hope it helps

 

 

Thanks,
Murthy

Hi @Murthy Ch ,

 

That works, however I noticed it only works if the Incident record has already been submitted or saved while the state = New.

There is a scenario where a new record can be created and moved direct to Resolved prior to being submitted or saved.


What is required to ensure the record is saved first?

 

Thanks

Basheer
Mega Sage

Hi @Mark_10 

In client script we have oldValue and newValue objects, from there you can easily findout what was the previous value.

Let me know if you need help in scripting that.

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

Mark_10
Tera Contributor

Thanks @Basheer .

 

Do you have an example script I could try please?

Thanks