Removing options of choices

cipla
Giga Contributor

I have a state field on incident form which has the following values 1,2,3,6,7,8 and 9. I want to set the state field readonly for all states except at state values 2 and 3. And at state values 2 and 3 only these two choices must be visible in state field. State value 2 is for In Progress and 3 is for On Hold.

Exactly what I want is that users cannot change state at any point except at state In Progress and even there they can only change it to On Hold, and same for On Hold state only choice visible in state field should be In Progress. Rest at all five states state field must be read only.

I have made the following On Load client script but it's not working. The removed states in script are even not visible at other states. When I create new Incident, instead of New state it shows In Progress. Even after Resolving the incident the state still remains In Progress. Can anybody help me with this??

g_form.setReadOnly('state',true);

var s= g_form.getValue('state');

  if(s==2||3)

  {

  g_form.setReadOnly('state',false);

  g_form.removeOption('state',1);

  g_form.removeOption('state',6);

  g_form.removeOption('state',7);

  g_form.removeOption('state',8);

  g_form.removeOption('state',9);

  }

2 REPLIES 2

sarfraz3
Mega Expert

You can do something like this:(opposite way)



onload script:


g_form.removeOption('state',1);


  g_form.removeOption('state',2);


  g_form.removeOption('state',3);


  g_form.removeOption('state',4);


  g_form.removeOption('state',5);


  g_form.removeOption('state',6);


  g_form.removeOption('state',7);


  g_form.removeOption('state',8);


  g_form.removeOption('state',9);


g_form.setReadOnly('state',true);



var s= g_form.getValue('state');


  if(s==2||3)


  {


g_form.setReadOnly('state',false);


g_for.addOption('state',2);


....


...


...


} and so on as per requirement...



one more thing... if for other states, it will be read-only   how can someone work on the ticket....for example how can i make it from resolve to close as it will be read-only


cipla
Giga Contributor

for resolve and close there are ACLs and UI actions for particular roles and users.