- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 02:20 AM
Hello.
I am creating a new record using Flow.
-> When this record is created it should check the record table and mark duplicate cases as "canceled" where we should check both duplicate product_code and customer_code fields on the records.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 03:50 AM
@Insider ,
I trust you are doing great.
You can try something like this
// This is a conceptual script to be adapted in the Flow Designer
// Assuming 'current' is the newly created record
var productCode = current.product_code;
var customerCode = current.customer_code;
// Lookup duplicate records
var dupRecord = new GlideRecord('your_table_name'); // Replace with your table name
dupRecord.addQuery('product_code', productCode);
dupRecord.addQuery('customer_code', customerCode);
dupRecord.addQuery('sys_id', '!=', current.sys_id); // To exclude the current record
dupRecord.query();
while (dupRecord.next()) {
// Mark each duplicate record as canceled
dupRecord.state = 'canceled'; // Replace 'state' with your field name for record status
dupRecord.update();
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 03:10 AM
Hi @Insider
I am not sure, I understood your requirement fully or not
-> When this record is created it should check the record table and mark duplicate cases as "canceled" where we should check both duplicate product_code and customer_code fields on the records.
Atul: Also add state is not closed or cancelled , so that the check can be done only for active cases not the closed one.
Also what issue you are facing in this? Any screen shot?
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 03:33 AM - edited 11-21-2023 03:33 AM
I was able to cancel the duplicate records using Before BR.
Along with state=cancel, i should also be able to change the date field to "Current date, time" which i ma trying on BR but its not working.
I am using:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 03:50 AM
@Insider ,
I trust you are doing great.
You can try something like this
// This is a conceptual script to be adapted in the Flow Designer
// Assuming 'current' is the newly created record
var productCode = current.product_code;
var customerCode = current.customer_code;
// Lookup duplicate records
var dupRecord = new GlideRecord('your_table_name'); // Replace with your table name
dupRecord.addQuery('product_code', productCode);
dupRecord.addQuery('customer_code', customerCode);
dupRecord.addQuery('sys_id', '!=', current.sys_id); // To exclude the current record
dupRecord.query();
while (dupRecord.next()) {
// Mark each duplicate record as canceled
dupRecord.state = 'canceled'; // Replace 'state' with your field name for record status
dupRecord.update();
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 06:16 AM
This worked great amit. But i am not able to populate the comments on this record.
I need to populate comments as " Auto-Cancelled due to approval of new case + <case Number of the new case record >"