- 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
‎05-10-2016 01:07 PM
Hi everyone,
The logic to create a task for the Stockroom Manager is in the Scheduled Job called Stock Rule Runner (found in System Scheduler > Scheduled Jobs > Scheduled Jobs). I posted the text from the script here: https://community.servicenow.com/message/924150?et=watches.email.thread#924150.
If you updated, it would be marked as user modified and may not have gotten this update, but I'm not sure if it ever existed without the Vendor option. I'm thinking that maybe it did, because the code is very different than what you posted, Michael.
Ben
- 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.)