How to restrict the user to return to previous states?

Community Alums
Not applicable

Hello! I have a requirement that I have a state field which is a dropdown with different states. The idea is that when I change states, it doesn't let me go back to the previous ones. I thought about solving it with a business rule, but should I make a script for this? Or could I just do everything with conditions? any ideas?

2 REPLIES 2

Marcin20
Mega Guru

Hi Rocio,

 

The other option is to use a Client Script ( onChange - on the state field).

Than you can compare newValue with oldValue and you can revert the value in the form when the combination is not allowed.

 

Best Regards,

Marcin

 

If my answer helped you in any way, please mark this answer as helpful

Umasankar Guth1
Tera Contributor

Hi Rocio,

 

try below on change client script on state field.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var gr = g_form.getValue('state');
if (gr == '-5'){
g_form.addErrorMessage("state can't be changed back to pending");
return true;
}
else
return false;
}

 

Please mark helpful if the proposed solution is what you are expecting.