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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 03:00 AM
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 .
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 03:11 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2018 09:09 PM
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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 04:37 AM
Can you give more information on this..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 04:39 AM
it is in Catalog item--
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++;
}
}
});
}