onLoad Client script to hide dropdown values for a field not running fast enough

scocuzza
Kilo Contributor

Hello,

I have a client script that checks for the following items...

1. does the user have a certain role 

2. is the ticket assigned to the appropriate group (assignment group = ) 

3. If the ticket is approved 

if( approvalValue == "approved" && g_user.hasRole('group_name') && assignmentGroupValue == "groupname") {

}

based on this i perform a lot of g_form.removeOptions for a state field that is a dropdown. 

However when clicking on the record i can quickly click on the state field and see all the choices before this script can process and even select ones that should be hidden/removed. After the client script runs to completion then these dropdown options are removed but there is this lag where all options will be present before the script runs.

 

Is there any way to improve the performance of this script or is client scripting not the appropriate method? 

2 REPLIES 2

rahulpandey
Kilo Sage
Hi, I can think of couple of things, since this a choice list, why don't you use addOptions to build the very choice list instead of already built. So you don't have to remove it and try to clear the value on each relative change event.

Ok this should solve my problem where i dont want people quickly choosing choices that shouldnt be available...

 

But unfortunately i have a new problem..

when i add a choice like so..

g_form.addOption('state', '97', 'Development Ready');

and i can choose and set the state find_real_file.png

but when i save the record it switches back the display value to 97..dont know why this happens as it is the database value..

find_real_file.png