We often use scripts when creating catalog items. Here are some useful scripts based on various use cases. I hope these will help.
- Reference -> Variable attributes:ref_auto_completer=AJAXTableCompleter,ref_ac_columns_search=true,ref_ac_display_value=false,ref_ac_columns=user_name;u_sso_id;email
- Encode query with OrderBy: 'ORDERBYsource^ORDERBYDESCtime_of_event'
- Show list of users from a specific group: Type specification -> User reference qualified (Advance-> Reference Qual):'active=true^sys_idIN' + getIDs("f65370340047a2d126c42e705c"); //GroupSysIDfunction getIDs(grp) {var m = GlideUserGroup.getMembers(grp);var ids = '';while (m.next()) {ids += (m.user + ',');}return ids;}
- Choice data Dependent on other variables:javascript:var check = checkFunc(); //Returns true or flaseif(check == "INDIA"){ //Update'country=india' //Update}function checkFunc(){var ans = '';var sub = current.variables.subject_person;var grSysUser = new GlideRecord('sys_user');grSysUser.addQuery('sys_id',sub);grSysUser.query();if (grSysUser.next()){ans = grSysUser.getValue('country'); //Update}return ans;}
- Choice data Dependent on other variables:javascript:'name=incident^element=subcategory^dependent_value='+current.variables.category;
And make sure you set the variable attribute as follows: ref_qual_elements=category - More will come.
- More will come.
- More will come.
- More will come.
- More will come......