stock rules

chercm
Mega Sage

I have setup a stockroom and assigned a manager (and the manager has an email address) I have added an item into the stockroom.

 

Then I have setup a stock rule for the item with a Threshold = 0 and a Restock Option = stock room

 

So now there are 0 in stock and the stock rule should kick in.

 

i tried to change the next action date on the stock rule running but still not getting the sctask created . any idea how to fix this ?

1 ACCEPTED SOLUTION

i found the solution too . to add this part that if the restocking option is set to stockroom , there will be task ticket assigned to the stockroom manager

_processStockoomStockrule: function(stockRuleGr) {
var parent = stockRuleGr.parent_stockroom;
var stockroom = stockRuleGr.stockroom;
var model = stockRuleGr.model;
var supply = this.transfer.getTotalRecordCount(stockroom, model);
var threshold = parseInt(stockRuleGr.threshold, 10);
var need = threshold - supply;
var order = 0;
var size = parseInt(stockRuleGr.order_size, 10);

if (need > 0) {
if (size <= 0) {
order = need;
} else {
while (order < need) {
order += size;
}
}

var stock = this.transfer.checkStockroomTransferAvailability(parent, model);

if (stock >= order) {
if (model.sys_class_name.toString() === this.CONS_MODEL
|| model.asset_tracking_strategy.toString() === this.TRACK_CONS) {
this.transfer.consumableTransfer(parent, stockroom, model, order);
} else {
this.transfer.assetTransfer(parent, stockroom, model, order);
}

// Set pending_delivery to true
stockRuleGr.pending_delivery = 'true';
stockRuleGr.update();

// Create a Task for Asset Manager with requested format
var task = new GlideRecord('task');
task.initialize();
task.assigned_to = stockroom.manager; // Assign to stockroom manager
task.short_description = 'Quantity threshold breached: ' + stockroom.name;
task.description = 'Stockroom: ' + stockroom.name + '\nItem: ' + model.display_name +
'\nQuantity: ' + supply + '\nThreshold: ' + threshold;
task.insert();
} else {
// If stock is unavailable, create a task for asset manager to take action
var task = new GlideRecord('task');
task.initialize();
task.assigned_to = stockroom.manager;
task.short_description = 'Quantity threshold breached: ' + stockroom.name;
task.description = 'Stockroom: ' + stockroom.name + '\nItem: ' + model.display_name +
'\nQuantity: ' + supply + '\nThreshold: ' + threshold +
'\nParent Stockroom: ' + parent.name + '\nRequired: ' + order +
'\nAvailable in Parent: ' + stock;
task.insert();
}
}
}, 

View solution in original post

10 REPLIES 10

Mark Manders
Mega Patron

"I tried to change the next action date [...]". Try is something different than succeeding. Did you change the next action time and did it run? What happens if you trigger it just manually instead of changing the date/time, which could also cause confusion with system time vs local time. 

And not sure what the 'manager has an email address' has to do with an sctask being created. Are you creating sctasks that aren't related to anything for this? Normally sctask is related to a RITM that is related to a REQ. Or are you expecting an email, because then there could be other issues.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

it did not run but the ready word turn red, I change to one day in the past . It should create a sctask to source since I set it to stock room and not vendor I am running it on my pid so email not going to work 

Next action needs to be in the future, even if it's just one minute, otherwise it doesn't run. It checks on the job context for the last run.

But at least it's clear that the cause is in triggering the job. Use the 'execute now' button to trigger it manually. It will just run immediately. I believe OOB the button is set to be available for 'maint' so you may need to change that to 'admin'.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

@Mark Manders  this is how it looks like :  there is no execute buttonimage.png