- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 01:37 AM
I have the below script where i am trying to update the state of record from open > duplicate request before insert in BR. I have below script but its not working.
1) should I make it After insert ?
2) Is the script wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 03:55 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 03:57 AM
Ah okay, so you're not wanting to mark the record that is being inserted with this new state of '8', but the other records that are found by the query?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 02:07 AM
Hello,
Have you tried using current.update() ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 02:13 AM
You shouldn't use current.update in a business rule - there shouldn't be a need if you're doing things correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 02:07 AM - edited 06-12-2024 02:16 AM
Hello @Anna_Servicenow
try on after insert BR
try script:
(function executeRule(current, previous /*null when async*/ ) {
var caseid = current.case;
var amount = current.amount;
var serv_type = current.type_of_service;
// Query records based on specified conditions
var gr = new GlideRecord('x_inffr_task');
gr.addQuery('case', caseid);
gr.addQuery('amount', amount);
gr.addQuery('type_of_service', serv_type);
gr.addQuery('sys_created_on', '>', gs.daysAgo(30));
gr.query();
if (gr.hasNext()) {
// Exclude the first record from being marked as a duplicate
if (gr.next()) {
// Update the state of the current record to '8' (Duplicate Request)
current.setValue('state' , '8');
}
})(current, previous);
If my answer is helpful please mark it as helpful or correct!!
Pratima.k
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 03:18 AM
This didnt work