How to check if a record is Bulk Updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2024 01:41 AM
Hi Everyone,
I want to check if a record was a part of a bulk update or an individual update, is it feasible?
suppose i update 20 records via update All, is there any way of knowing if it happened via a bulk update?
Thanks,
Kartikey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2024 02:12 AM
hi @kartikey
I don't know what you try to achieve via this --- Are you going to apply it for global or scope Or what things you try to achieve via this tracking ....?
For General tracking, you can follow the below steps
Create a custom boolean field on the table you want to track. Use a business rule to set the value of this field to true whenever a record is updated via bulk update.
Steps:
Create Custom Field:
Add a new field to the table (e.g., u_bulk_updated).
Set the type to True/False.
Make it a read-only field to prevent accidental modifications.
Create Business Rule:
* Create a "before update" business rule on the table.
* In the When condition, check if the update is triggered by the "Update All" action:
You can write the custom script as well and evaluate the boolean field true/false value
If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer🌠 OR mark it Helpful ⛑ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2024 02:34 AM
Hi @MackI ,
How do i put up the when to run condition? i mean what fields would i use to validate?
Thanks,
kartikey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2024 03:10 AM
hi @kartikey
The u_bulk_updated field doesn't get checked or unchecked directly from the list view. Instead, the business rule we created earlier handles the setting of this field.
Here's how the process works when you perform a bulk update on 20 or more records:
1. Bulk Update Action: You select multiple records (20 or more) in the list view and click the "Update All" button.
2. Business Rule Trigger: The "before update" business rule we created is triggered for each of the selected records.
3. Condition Check: The business rule checks the current.operation() value for each record. Since it's a bulk update, current.operation() will return 'update_multiple'.
4. Update Field: Because the condition is met, the business rule sets the u_bulk_updated field to true for each of the 20 (or more) records being updated.
5. Database Update: The records are updated in the database, and the u_bulk_updated field now reflects that these records were part of a bulk update.
Important Note: The u_bulk_updated field is not a checkbox field that you can manually check or uncheck on the list view. It's a "True/False" field, and its value is automatically set by the business rule based on the update operation.
How to Set Up the Business Rule:
1. Table: Choose the table on which you want to track bulk updates.
2. When: "before" (Before the update is saved to the database).
3. Insert: Unchecked.
4. Update: Checked.
5. Delete: Unchecked.
6. Advanced: Unchecked.
7. When to run:
* Condition: current.operation() == 'update_multiple'
* This condition is crucial as it ensures that the business rule will only trigger when a bulk update is performed on the records.
8. Filter Conditions: Add any additional filter conditions if you want the business rule to apply to specific records within the table (optional).
9. Script: Paste the provided script into the script field
(function executeRule(current, previous /*null when async*/) {
// Check if the update is triggered by the "Update All" action
if (current.operation() == 'update_multiple') { // This is the key condition
current.u_bulk_updated = true; // Set custom field to true
}
})(current, previous);
A small request from my end, If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer🌠 OR mark it Helpful ⛑ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2024 02:58 AM
This is not something that is OOB available. The question is: what is your usecase. You would need to create custom functionality. What will it bring you? Why is it important to know if something was part of a bulk update or not? Who wants to know this?
Do realize that bulk updates can be done in multiple ways: update all, update selected, via flow, via script, etc. It could make sense, but without knowing the why behind your requirement, I'm not seeing it.
With every development the main question should be: does the result pay for the effort.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark