Stock rule create a duplicate Service request to Stockroom manager daily post Stock rule runner job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-06-2025 08:16 AM
In Stock Rule Form, I have create a model name with threshold value as 15 and order size as 10. Also, I have activated the stock rule and aligned the stock rule runner job @ 3:00 PM on daily basis. I can see the email notification is triggered to stockroom manager and service request in the request item table (sc_req_item.LIST). However it create an another duplicate request on next day for the same model (Stock rule which was created) and also i verified whether pending deliver flag as "True" for the stock rule, it is true only. i could find the duplicate request has created on daily.
How to prevent the duplicate request for the same model threshold if already existing active ticket is on queue with the respective team?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-06-2025 12:07 PM - edited ā03-06-2025 01:18 PM
On way is to create a Business Rule for the sc_req_item table, that runs on "Before" and on "Insert", with Advanced checked. The use script logic to check for a 'Duplicate' (based on your fields such as cat_item and requested_for) record and if one exists abort the creation of the duplicate. Check OOB examples of BRs for examples. for your use case, try:
with script (in the Advanced tab:
(function executeRule(current, previous /*null when async*/) {
// prevent duplicates
var scri = new GlideRecord('sc_req_item');
// Build query to check for duplicate record
scri.addQuery('field_1', current.field_1);
scri.addQuery('field_2', current.field_2);
//...
scri.query();
if (scri.hasNext()) {
current.setAbortAction(true);
}
})(current, previous);
Substitute the fields that define a Duplicate in the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-09-2025 09:45 PM
Thank you for the reply. However, the above mentioned Script will restrict the stock rule schedule job to create a new request for another stockroom stock rule right?
my query, the job should not create a duplicate request for the particular stockroom stock rule. But it should create a request for another stockroom if threshold went below.