You need to sign in to do that
Don't have an account?
Manolito Mendoza 27
How can I prevent governor limits using Visual Flow?
Hi,
I've created this Visual Flow to delete records one at a time to prevent it from reaching the governor limits.
This Flow works fine with less then 50000 records. When I tried to use it with an object that has 700K+ records, the first element (Fast Lookup) reaches the governor limits right away.
How do I fix this?
Thanks in Advance!
I've created this Visual Flow to delete records one at a time to prevent it from reaching the governor limits.
This Flow works fine with less then 50000 records. When I tried to use it with an object that has 700K+ records, the first element (Fast Lookup) reaches the governor limits right away.
How do I fix this?
Thanks in Advance!
public class getLimitedRecord {
@InvocableMethod(label='getLimitedRecords')
public static list<AccountContactRole> getLimitedRecords() {
list<AccountContactRole > lmtAccRole =[select name,Role from AccountContactRole where Role <>'Key Contact Role' limit 50000];
return lmtAccRole;
}
}
Please mark as best answer if this solution works for you.
All Answers
Use this Apex in your flow as first step replacing your Fast Lookup. here assign the output of the apex to object variable and loop through and delete based on condition by keeping all your other step as it is. Create one more outter loop that check the apex class output and loops through if the apex output returns any values. Apex class will do query every time excluding the deleted records and hence you can achive any no. of record in your flow. I hope this helps, if so please mark as best answer.
However, I am not an expert in Apex coding. Do you happen to have a sample code? The object is AccountContactRole and records should be deleted except for the Role assigned as Key Contact Role.
TIA
TIA
public class getLimitedRecord {
@InvocableMethod(label='getLimitedRecords')
public static list<AccountContactRole> getLimitedRecords() {
list<AccountContactRole > lmtAccRole =[select name,Role from AccountContactRole where Role <>'Key Contact Role' limit 50000];
return lmtAccRole;
}
}
Please mark as best answer if this solution works for you.
I'll have this looked at by tomorrow and get back to you.
Cheers!