Incident state management or State transitions or State model

Shantharao
Kilo Sage

Hello All,

I want to manage incident state transition flow as below

We have 6 out-of-box choices for incident form as below

/*
state 1 is "New"
state 2 is "In Progress"
state 3 is "On Hold"
state 6 is "Resolved"
state 7 is "Closed"
state 8 is "Canceled"
*/

OnChnage of state field to "New" I have to show below 4 choices as below

"In Progress"
"On Hold"
"Resolved"
"Canceled"

OnChnage of state field to "In Progress" I have to show below 3 choices as below

"On Hold"
"Resolved"
"Canceled"

OnChnage of state field to "On Hold" I have to show below 1 choices as below

"In Progress"

OnChnage of state field to "Resolved" I have to show below 4 choices as below

"In Progress"

"Closed"

 

I created one onChnage client script onChange of "state" filed, I am adding options to same state filed but I am getting infinite loop, not getting proper results

Please suggest me the best practice for implementation, please find the sample script

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
/*
state 1 is "New"
state 2 is "In Progress"
state 3 is "On Hold"
state 6 is "Resolved"
state 8 is "Canceled"
state 7 is "Closed"
*/
// var incState = g_form.getValue("state");

if(newValue == "1"){
g_form.clearOptions("state");
g_form.addOption("state","2","In Progress");
g_form.addOption("state","3","On Hold");
g_form.addOption("state","6","Resolved");
g_form.addOption("state","8","Canceled");
g_form.removeOption("state","7");
alert(newValue);

}
if(newValue == "2"){
g_form.clearOptions("state");
g_form.addOption("state","3","On Hold");
g_form.addOption("state","6","Resolved");
g_form.addOption("state","8","Canceled");
g_form.removeOption("state","1");
 g_form.removeOption("state","7");
 alert(newValue);

}
if(newValue == "3"){
g_form.clearOptions("state");
g_form.addOption("state","2","In Progress");
 g_form.removeOption("state","1");
 g_form.removeOption("state","3");
 g_form.removeOption("state","6");
g_form.removeOption("state","7");
g_form.removeOption("state","8");
alert(newValue);

}
if(newValue == "6"){
g_form.clearOptions("state");
g_form.addOption("state","2","In Progress");
g_form.addOption("state","7","Closed");
 g_form.removeOption("state","1");
g_form.removeOption("state","3");
g_form.removeOption("state","6");
g_form.removeOption("state","8");
alert(newValue);

}

 

 

1 ACCEPTED SOLUTION

Shantharao
Kilo Sage

I found an excellent feature from Madrid release called State Management->State Model

With out writing any coding we can handle the state transitions in smooth manner

Please find the screen shots for reference 

1.Created Incident Flow state model

find_real_file.png

 

2.Created Incident Transitions 

find_real_file.png

3.In Progress State Transition

We can change the state from New or On Hold or Resolved to In Progress, please find the screen shot

find_real_file.png

 

4.On Hold state Transition

We can change the state to "On Hold" from state "New" or "In Progress", find the screen shot

find_real_file.png

Please hit the help if this link is helps you

View solution in original post

2 REPLIES 2

John Longhitano
Kilo Guru

Could you do it onLoad instead?  That way it only loads once on the form load.  Once you save the state to the new value it would run once again to get available choices.

Shantharao
Kilo Sage

I found an excellent feature from Madrid release called State Management->State Model

With out writing any coding we can handle the state transitions in smooth manner

Please find the screen shots for reference 

1.Created Incident Flow state model

find_real_file.png

 

2.Created Incident Transitions 

find_real_file.png

3.In Progress State Transition

We can change the state from New or On Hold or Resolved to In Progress, please find the screen shot

find_real_file.png

 

4.On Hold state Transition

We can change the state to "On Hold" from state "New" or "In Progress", find the screen shot

find_real_file.png

Please hit the help if this link is helps you