You need to sign in to do that
Don't have an account?
Generating a List of Products NOT Related to Other Objects
We want to clean up our product data, and we want to start by focusing on the products that are NOT related to anything. While we have multiple objects related to products, there are really only 3 main objects that use products, so for simplicity I will be focusing on those. However the problem I'm having is generating this list. With a report I know I am able to filter out products without 2 of our custom objects, but that feature doesn't support filtering out opportunity line items (or even pricebook entries), which is one of the 3 objects we need. I then considered using GROUP BY queries on the 3 objects to find all the ones related to products, and then add all those IDs to a set and then query for all the products that aren't in that set, but this hits the governor limit for query rows very quickly, so that's not an option either. Is there any way at all I could build this list?
Sounds like you have the process down but are just hitting limits... have you tried running it as a batch?
Can you post the code for the process? I'm sure we can find a way to optimize it a bit and get it figured out.
Lets say There are Three objects A, B , C which are using PRoduct obj so to delete Products which are not being used in any other object can be done as below :
Delete [ Select id from Product2 where id not in (Select productid from A__C) AND id not in (Select productid from B__C) And id not in (Select productid from C__C) ];