How to set values for location have region field ,according to that when

Rajababu
Giga Guru

Hi ,

There is requirement , currently they are using hard coded on sys-id .

But I want to change that script because day by day location increase and it hard to update every sys id on code.

 

So found that on location table there was region ,

So  can any onhelp how set values on task for example-

 

RITM created ,task generated and it auto get assign to group.

On task , i want to set when location selected San Francisco , script the on location table there is field name Region so there is only 4 region .

Like when region is USA then group set to be FAC-USA

IF region is EMEA the it set to be group as FAC-EMEA by script . 

 

 

6 REPLIES 6

rajmasurkar
Giga Guru

Hi,

  I would advice you to create a reference field 'Group' on location table referencing to Group table.

Then you can write an OnChange client script and script include or a Business rule before insert/update to set the assignement group.

 

Raj

Can explain what logic you will used for business rule .

Like 50 Location every 10 different location ,of Group only can handled .

 

For example Group A to H - Group FAC-USA will handled and I to P group FAC-CAN will handle So what logic will you set for .

Kishore8
Kilo Guru

Can you give more information on this..

Kishore8
Kilo Guru

it is in Catalog item--

find_real_file.png

 

OnChange Script:

function onChange(control, oldValue, newValue, isLoading) {

                       if (!isLoading )

{

g_form.clearOptions('site');

g_form.addOption('site', '', '-- None --', 0);

     g_form.setValue('site', '');                          

                                                                                               

                                                                                               

  var hh = g_form.getValue('region');

var lChoices = new GlideRecord('u_desktop_support_location');

lChoices.addQuery('u_region', hh);

lChoices.addOrderBy('u_site_name');

lChoices.query(function(lChoices){

         var i = 1;

         var used_options = [];

        while (lChoices.next())

{

                                                                                                                                                                                                               

           if (!used_options[lChoices.u_site_name])

used_options.push(lChoices.u_site_name);

g_form.addOption('site', lChoices.u_site_name, lChoices.u_site_name, i);

i++;

            }

            }

               });

      }

}

 

 

 

OnLoad:

 

function onLoad()

 {

g_form.clearOptions('site');

                                                                                                                                                                                                g_form.addOption('site', '', '-- None --', 0);

    g_form.setValue('site', '');                      

                                                                                               

  var hh = g_form.getValue('region');

var lChoices = new GlideRecord('u_desktop_support_location');

lChoices.addQuery('u_region', hh);

lChoices.addOrderBy('u_site_name');

lChoices.query(function(lChoices){

         var i = 1;

         var used_options = [];

        while (lChoices.next())

 {                                                                                                                                                                            

           if (!used_options[lChoices.u_site_name])

{               

used_options.push(lChoices.u_site_name);

g_form.addOption('site', lChoices.u_site_name, lChoices.u_site_name, i);

i++;

            }

            }

               });

  }