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

have you disabled the ACL which you have created before testing client script changes??


ACL which you wrote might be hiding that field.


If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Hello Sushant,



Do I not need a security rule to perform this?


You could accomplish this by a simply UI policy.



Regards,


Erik Sandberg


Accenture Cloud First


erik.m.sandberg@accenture.com<mailto:erik.m.sandberg@accenture.com> | 817-914-6607



Hello Erik,



How would one go about doing that?   I am having some trouble applying these codes there.


dasthu1
Kilo Expert
  1. answer = false;      
  2. // If has role and the choice is closed (value = 3)    
  3. if (gs.hasRole('change_request_admin') && current.state.value == 3 && current.name == 'change_request') {      
  4.       answer = true;      
  5. }  
  6. if u try like this

Regards,


Dasthagiri