
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2014 07:00 AM
I'm trying to figure out a way to make a client script work on all the requested items without having to copy it so many times... If I just leave the field for "Catalog Item" blank, the script apparently doesn't work at all. I could add a variable set to all the items and make the script work on it, but it would still require updating all the items... Can this be done with a UI script maybe?..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2015 04:32 AM
Hi,
I had the same problem but you can easily add whatever variable sets to your items using a scheduled script e.g. a scheculed script that runs every night perhaps checking all cat items against the catitem:var set linking table and creating a relationship if one dosn't exist:
e.g.
var item = new GlideRecord('sc_cat_item');
item.addQuery('active',true);
item.query();
gs.log('I found' + item.getRowCount() + ' items', 'TEST');
while (item.next()) {
var itm = item.sys_id;
var cost = "bf87fe6b6f8b310064b8d7f16e3ee4f2"; //Sys_id of costcentre Variable set
var vset = new GlideRecord('io_set_item');
vset.addQuery('variable_set',cost);
vset.addQuery('sc_cat_item',itm);
vset.query();
if(vset.next()){
gs.log("This item: " + item.name + " Is already linked to cost var set",'TEST');
} else {
gs.log("I need to create a link to Cost for: " + item.name,'TEST');
vset.initialize();
vset.variable_set = cost;
vset.sc_cat_item = itm;
vset.insert();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2014 07:26 AM
I don't believe there is an easy way to do this ... HOWEVER... you can do the following to make it easier...
create a standard variable set that has the variables you need for all items <requested for, approving manager etc>
add to that variable any client scripts you also use on all items.
now create a new item called "template", add the variable set to it.. and set any standard settings you have <no cart no quantity etc>
now when you want to create a new item just open the template and hit copy... find the copy, give it a new name and work from there... this way you don't have to try and remember to set all of your defaults for every item you create.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2014 07:27 AM
UI script is the way to go but this is not recommended at all
this is unnecessary load on the system as the above comment rightly points out, IT RUNS ON EVERYPAGE.....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2014 06:31 AM
Thanks to all for the answers. Yes, I guess I will need to go the "variable set"+catalog client script route. I don't feel comfortable creating a global UI script for this. A learning for me for the future to think of grouping similar variables in sets in advance 😃
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2015 04:32 AM
Hi,
I had the same problem but you can easily add whatever variable sets to your items using a scheduled script e.g. a scheculed script that runs every night perhaps checking all cat items against the catitem:var set linking table and creating a relationship if one dosn't exist:
e.g.
var item = new GlideRecord('sc_cat_item');
item.addQuery('active',true);
item.query();
gs.log('I found' + item.getRowCount() + ' items', 'TEST');
while (item.next()) {
var itm = item.sys_id;
var cost = "bf87fe6b6f8b310064b8d7f16e3ee4f2"; //Sys_id of costcentre Variable set
var vset = new GlideRecord('io_set_item');
vset.addQuery('variable_set',cost);
vset.addQuery('sc_cat_item',itm);
vset.query();
if(vset.next()){
gs.log("This item: " + item.name + " Is already linked to cost var set",'TEST');
} else {
gs.log("I need to create a link to Cost for: " + item.name,'TEST');
vset.initialize();
vset.variable_set = cost;
vset.sc_cat_item = itm;
vset.insert();
}
}