Can you get Show valid states values to work on the Service Portal?

lghamloush
Mega Contributor

Hi all,

I'm relatively new to ServiceNow, but i have created an internal Service Portal for change requests to be processed. The problem i'm having is that the state field is showing all options available to the users, even though the client script 'Show valid state values' has been switched to run in all ui types. Can anyone tell me why its not working on the Service Portal but it is in the standard ui?

Many thanks in advanced for your help!

Service Portal:

find_real_file.png

Standard UI:

find_real_file.png

1 ACCEPTED SOLUTION

lghamloush
Mega Contributor

So I finally got this working, and thank you to Michael for your help.



I created a new onLoad client script that removes the unwanted states.



Make sure to set the UI Type to Mobile / Service Portal



function onLoad() {


    //Type appropriate comment here, and begin script below



  if (g_form.getValue('state') == '-5')// For state use your database value and same for other states


{


  g_form.removeOption('state', '-3');


  g_form.removeOption('state', '-2');


  g_form.removeOption('state', '-1');


  g_form.removeOption('state', '0');  


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


  g_form.removeOption('state', '4');



  }


}



repeat as necessary through all the state values.


View solution in original post

6 REPLIES 6

The onload client script calls several script includes that uses the Change type to determine which States are available for that type. I doubt you can get it working using the desktop scripts. You'll probably have to write your own script to get the correct state values based on type, then use client script to show 2 values, the current state, and future state.



Is the goal to allow users to work their change requests? I'd check with your sales rep before doing that to make sure licensing allows for this.


lghamloush
Mega Contributor

So I finally got this working, and thank you to Michael for your help.



I created a new onLoad client script that removes the unwanted states.



Make sure to set the UI Type to Mobile / Service Portal



function onLoad() {


    //Type appropriate comment here, and begin script below



  if (g_form.getValue('state') == '-5')// For state use your database value and same for other states


{


  g_form.removeOption('state', '-3');


  g_form.removeOption('state', '-2');


  g_form.removeOption('state', '-1');


  g_form.removeOption('state', '0');  


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


  g_form.removeOption('state', '4');



  }


}



repeat as necessary through all the state values.