BR to check if number of asset is less then threshold value in stockrule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 09:55 AM
Hey
Requirement-Need to send notification when number of assets is less then threshold value in stock rule.
Issue-how can I fetch number of assets in that particular stockrule.
Please suggest
Thanks,
Shweta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 10:11 AM - edited 10-29-2024 10:13 AM
Try this:
Create an After Business Rule and Check Update
Table: alm_asset
Condition: current.quantity < current.threshold
Script as below:
// Check if an asset quantity has gone below the threshold
(function executeRule(current, previous /*null when async*/) {
// Ensure quantity and threshold fields are available
if (current.quantity < current.threshold) {
// Example: Trigger a notification or alert the relevant team
gs.addInfoMessage("The asset " + current.name + " has gone below the threshold.");
// Optionally create an incident or task for restocking
var incident = new GlideRecord('incident');
incident.initialize();
incident.short_description = "Asset " + current.name + " has gone below the threshold";
incident.description = "The asset quantity for " + current.name + " is " + current.quantity +
", which is below the threshold of " + current.threshold + ".";
incident.insert();
}
})(current, previous);
Regards
Paul

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 10:19 AM
Is this a count of all assets in a stockroom? Because that doesn't make sense. It should be model specific. "Tell me when the number of Lenovo X3 laptops drop below X number"
If it's the latter, a stock rule and the 'Stock Rule Runner' scheduled job will do the functionality you're wanting. An asset.restock event is triggered which could be used to trigger a notification