How to hide a certain value in the drop down list of the state field?

humblecommitted
Kilo Guru

Hello Community,

I am trying to hide this item in the drop down list (its value is 3):

find_real_file.png

I tried to follow these links but they did not work for me:

Server-side script to hide values in incident state dropdown

How does one filter a field of type "workflow" based on the role of the logged in user?

I tried applying the code in the above forums here but it still appears.

find_real_file.png

  1. answer = true;  
  2. // If has role and the choice is closed (value = 3)  
  3. if (gs.hasRole('role here') && current.value == 3 && current.name == 'change_request' && current.element == 'state') {  
  4.       answer = false;  
  5. }

When I tried flipping the code, it ended up hiding the entire "State" variable from the table which was not desired.

answer = false;  

// If has role and the choice is closed (value = 3)  

if (gs.hasRole('change_request_admin') && current.value == 3 && current.name == 'change_request' && current.element == 'state') {  

      answer = true;  

}

find_real_file.png

Again, I only want to hide the "Closed Complete", from the "State" drop down list.

Any help would greatly be appreciated.

1 ACCEPTED SOLUTION

humblecommitted
Kilo Guru

Hello Community,



I was able to get the piece of code working.



Here is the code that I used


function onChange() {


    //Type appropriate comment here, and begin script below


    var isCSAdmin = g_user.hasRole('change_request_admin');


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


    if (!isCSAdmin){


          g_form.removeOption('state', '3', 'Close Complete');


    }


  else{


  if (isCSAdmin = true){



  }


  }


}



SS of procedure:


find_real_file.png


find_real_file.png


find_real_file.png


View solution in original post

11 REPLIES 11

Hello Dasthagiri,



I tried that piece of code as well.   Unfortunately that did not work as well.


humblecommitted
Kilo Guru

Hello Community,



I was able to get the piece of code working.



Here is the code that I used


function onChange() {


    //Type appropriate comment here, and begin script below


    var isCSAdmin = g_user.hasRole('change_request_admin');


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


    if (!isCSAdmin){


          g_form.removeOption('state', '3', 'Close Complete');


    }


  else{


  if (isCSAdmin = true){



  }


  }


}



SS of procedure:


find_real_file.png


find_real_file.png


find_real_file.png