- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2016 10:21 AM
[currently on Fuji Patch 10]
My company is looking to start using Inventory Management, and I'm having an issue with the default Stock Rule functionality. According to the Wiki, I should be able to apply a stock rule with the "Vendor" Restocking Option and automatically receive a task and email: Stockrooms and Stock Rules - ServiceNow Wiki
- I can see the "Asset Restocking" Email Notification that appears to be the right one (sysevent_email_action.do?sys_id=cb3d87a2c3131000b959fd251eba8f81).
- From there, I can see the "asset.restock" Event Registration that matches (sysevent_register.do?sys_id=e42bc3a2c3131000b959fd251eba8f23).
- However, I can't find any functionality in the system that would fire the event.
From reading the Wiki (and this post), it seems like the "Stock Rule Runner" Scheduled Job should be the key: sysauto_script.do?sys_id=c7962096c3802000b959fd251eba8f1d
Unfortunately, the default in my system doesn't carry out anything but creating Transfer Orders (using the "StockRuleTransfer" Script Include). Could someone confirm what the "Stock Rule Runner" Scheduled Job is supposed to contain by default?
Here are the contents I see in mine:
runStockRules();
function runStockRules() {
var stockRules = new GlideRecord('alm_stock_rule');
stockRules.addQuery('active', 'true');
stockRules.addQuery('restocking_option', 'stockroom');
stockRules.query();
gs.include('StockRuleTransfer');
var transfer = new StockRuleTransfer();
while (stockRules.next()) {
var parent = stockRules.parent_stockroom;
var stockroom = stockRules.stockroom;
var model = stockRules.model;
var supply = transfer.getTotalRecordCount(stockroom, model);
var thresh = parseInt(stockRules.threshold,10);
var need = thresh - supply;
var order = 0;
var size = parseInt(stockRules.order_size,10);
if (need > 0) {
while (order < need)
order += size;
var stock = transfer.checkStockroomTransferAvailability(parent, model);
if (stock >= order) {
if(model.sys_class_name == 'cmdb_consumable_product_model' || model.asset_tracking_strategy == 'track_as_consumable')
transfer.consumableTransfer(parent, stockroom, model, order);
else
transfer.assetTransfer(parent, stockroom, model, order);
}
//if it does not have enough, it will run each night until the parent stockroom has enough supply
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2016 01:43 PM
Thanks for keeping me honest. I actually received a response in the HI portal just last week!
Apparently, there is a Known Error being sorted out that has led to multiple customers having this out-of-date version of the Scheduled Job. (It's PRB621428, if you'd like to get your own instance hooked into it.)
The workaround is to fill in your Scheduled Job with the correct contents Ben shared. (As for user modifications, because it's a Scheduled Job, nothing of the sort is tracked, so I'm not sure what the true "solution" to the PRB will be.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2016 08:41 AM
I couldn't even find this scheduled job in my instance but I have an admin who has really messed up some of our instance (deleting contract types, etc.) so I thought perhaps he deleted it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2016 10:21 AM
Sorry if this is a dumb question, but are you sure you have the appropriate plugin installed on your instance?
I assume it's Asset Management (com.snc.asset_management), but if I'm understanding the Plugin Files related list on the Plugin form correctly, then I don't actually see it listed there...I guess I'm not actually sure where the job came from! (but it was created before our instance was live: "02-09-2012 02:25:11 PM by admin")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2016 10:28 AM
Yes we have that plugin installed. I'm not sure where it came from either. And we did receive notifications over 6 months ago and then something happened. I haven't really dove into it too much but it's definitely messed up. I'm going to be focusing on this soon so thought I'd follow this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2016 12:32 PM
Yes, my Scheduled Job is the same as yours and on Line 7 you can see that it's only in regards to Stock Rules that create a transfer order to move assets from one stockroom to another. It isn't for notifying/creating task for the stockroom manager (I dunno why they mentioned it in the Wiki). I am looking to get that going in my instance where it will create a task or email notification to the stockroom manager too so will probably create a Business Rule on alm_consumable table that whenever quantity changes it will check for a Stock Rule and if below threshold to make a catalog task to the stockroom manager (on behalf of stockroom manager).
I'll also have it check for active tasks and POL's so it won't create another task if it already has been triggered before.
Nobody else has theirs working out of the box?