How to show values in Service CI field ( dropdown)

Supriya25
Tera Guru

Hi All,
kindly share your thoughts and suggestions on below issue

we have close to 30+ option values in Service CI .

Please let me know how can we do this, 
1. Do we have to create OnLOAD client script with using removeOption & addOption in script ? Without using addOption and removeOption  can we achieve in another way. ?
2. Without using script can't we achieve this ?
3. If I create a OnLoad client script ,  script crossing 100+ lines , don't we have other alternative way ?

Supriya25_0-1753593577121.png

 

While creating new request user able to select Service CI as per below , on existing record for everyone it should be readonly.

On new record : if 
Logged-In User belongs to below
For Admin's roles users :
Service CI field should be readonly and selected with "General"

For Apple support Group :
Show only Apple related values in Service CI

For Samsung Support Group
Show only Samsung related values in Service CI

For Realme Support Group
Show only Realme related values in Service CI

For OCI P2 Support group
Show only Realme & Samsung related values in Service CI

For OCI P1 Support group
Show only Google Pixel & Apple related values in Service CI

For Partner Groups
Show only Google Pixel & Apple & Samsung related values in Service CI


can't we achieve this with ZERO code ?  
Can't we achieve this without using Client scripts  ? without using addOption, removeOption ? ??




9 REPLIES 9

GlideFather
Tera Patron

Hi @Supriya25 

 

the catalog client script is the best approach, however you mention onLoad, in that case the variable must be already displayed, otherwise it will be onChange

 

Very drafty version could look like this:

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
	
if(newValue == 'apple_support'){
g_form.addOption('name',optionName, optionValue);
g_form.removeOption('name',optionName, optionValue);
}
if(newValue == 'samsung_support'){
g_form.addOption('name',optionName, optionValue);
g_form.removeOption('name',optionName, optionValue);
}
if(newValue == 'realme_support'){
g_form.addOption('name',optionName, optionValue);
g_form.removeOption('name',optionName, optionValue);
}
if(newValue == 'another'){
g_form.addOption('name',optionName, optionValue);
g_form.removeOption('name',optionName, optionValue);
}
}

 Let me know hoy do you progress

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


@Supriya25 then I realised you mentioned some roles.

 

Admin role is clear, but how do you differentiate between Apple support group and Partner support group

 

in the onLoad script it could be HasRole() or hasRoleExactly() to check for the role and eventually do the trick, but if the support groups have same role, how do you distinguish them?

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Hi Kamil,

1. to differentiate , we will use Display Business rule 
g_scratchpad.AppleTeam = gs.getUser().isMemberOf("Apple support group");
we will call in Client script if(g_scratchpad.AppleTeam);

2. We can't use Record producer, because this table is child table to some other table. based on Parent table state value, assigned-to user manually will create one child record in "Service CI" table.

my concern is,  we have 30+values , so for 30+ values if we design code using with addOption and Remove Option code lines will cross 150+ lines . 

can't we achieve this with ZERO code ?  
Can't we achieve this without using Client scripts  ? without using addOption, removeOption ? ??

any alternative options ?


if(g_scratchpad.AppleTeam){
g_form.addOption('name',optionName, optionValue);
g_form.removeOption('name',optionName, optionValue);
}
if(g_scratchpad.SamsungTeam){
g_form.addOption('name',optionName, optionValue);
g_form.removeOption('name',optionName, optionValue);
}
if(g_scratchpad.GoogleTeam){
g_form.addOption('name',optionName, optionValue);
g_form.removeOption('name',optionName, optionValue);
}
if(g_scratchpad.RealmeTeam){
g_form.addOption('name',optionName, optionValue);
g_form.removeOption('name',optionName, optionValue);
}
}

 

Its_Azar
Tera Guru

Hey Supriya!

i think you can use Use a Reference Qualifier on the Service CI field to control what values appear, based on group or role.

You can use something like:

var group = gs.getUser().getUserRoles(); // Or getMyGroups()
 

Client-side control (like making field readonly):

  • Use g_form.setReadOnly('service_ci', true);

  • Do this inside an onLoad script only for new records (g_form.isNewRecord())

If this helps kindly accept the solution thanks much.

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.




Kind Regards,

Mohamed Azarudeen Z

Developer @ KPMG

 Microsoft MVP (AI Services), India