How can I add conditions to Dictionary Override option

Akash4
Kilo Sage
Kilo Sage

My requirement is "When Create New Incident is clicked and the created member is not a member of a Service Desk, the Contact Type should default to Self-Service, else to 'Phone'.

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.
1 ACCEPTED SOLUTION

If they are allowed to pick anything, then I would recommend the business rule. The user experience would look something like this.



  • Any user enters the form (service desk or anyone else.)
  • They fill out the form including the contact type.
  • No matter what they pick, if they are service desk, it gets set to self-service when the record is created. If not, they are set to phone. This is the business rule I wrote above. It does not apply to users with admin role. They stay with what they picked.
  • If they like, they can go back and change it later as the business rule doesn't apply to 'update' operations, only insert.

View solution in original post

8 REPLIES 8

pravalika2
Kilo Expert

Hi Akash,



You can write a onLoad script which gives only two options either self-service or phone for users who doesn't belong to 'Service Desk' group:


function onLoad() {


    var user = g_user.userID;


  var ir = new GlideRecord('sys_user_grmember');


  ir.addQuery('group', 'd625dccec0a8016700a222a0f7900d06');


  ir.addQuery('user', user);


  ir.query();


  if(ir.next()){


    g_form.removeOption('contact_type','email');


  g_form.removeOption('contact_type','walk-in')


  }


}



Hope this serves your requirement



Kind Regards,


Poojitha


Requirement is to perform this task from Dictionary Overrides, as this would be the best practice.


Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.

Hi Akash,



A dictionary override is used to set a default value different than the base (parent) table. For example, the default state for incident can be 2 while the default state for task is 1. It's meant to be a table thing, not a condition thing.



The use case you've given sounds like a business rule than a dictionary override.



Something like this:



Name: Set default contact type


When: before


Insert: checked


Update: NOT checked


Condition: (empty)


Script:


if (gs.getUser().isMemberOf('Service Desk'))


        current.contact_type = 'self-service';


else


        current.contact_type = 'phone';



Note; this is untested and may require tweaking on option names and other areas.


Ok, let me turn to scripting then, and can you suggest the best practice for this?


Client side scripting or business rule


Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.