You need to sign in to do that
Don't have an account?
Naishadh
Retrieve Parent Campaign : too many sql query
Hi,
I want to retrieve ultimate parent of each campaign.
E.g.
Campaign1
--- Campaign1.a
-------Campaign1.a.1
So the ultimate parent of Campaign1.a.1 is Campaign1.
I have developed following code which is working fine in small number of record but if I tried to update bulk records it gives "Too many SQL query" error.
public static String getUltimateParent(String pId) {
Campaign[] campdata = [Select c.Id,c.ParentId From Campaign c where c.Id = :pId];
if(campdata.size() > 0) {
if(campdata[0].ParentId == null) {
return campdata[0].Id;
} else {
return getUltimateParent(campdata[0].ParentId);
}
}
return null;
}
Any help?
I want to retrieve ultimate parent of each campaign.
E.g.
Campaign1
--- Campaign1.a
-------Campaign1.a.1
So the ultimate parent of Campaign1.a.1 is Campaign1.
I have developed following code which is working fine in small number of record but if I tried to update bulk records it gives "Too many SQL query" error.
public static String getUltimateParent(String pId) {
Campaign[] campdata = [Select c.Id,c.ParentId From Campaign c where c.Id = :pId];
if(campdata.size() > 0) {
if(campdata[0].ParentId == null) {
return campdata[0].Id;
} else {
return getUltimateParent(campdata[0].ParentId);
}
}
return null;
}
Any help?
Hello Naishadh,
It really is a problem. You are not allowed to make more than 100 calls to db at the same time. I came across this problem. What i did is that, I needed 32 fields from the db so i wrote 32 quries (Dynamic) and in each query I got the specific field and after getting all the fields i merged them in one. Your scenario may be different but you have to do something like I did.
Thanks and Regards
Osman Ashraf Bajwah
Technosoft Solutions.
SalesForce Developer.
Hi,
Thanks for reply. I need only two fields from campaign but total number of records are almost 5000 and Salesforce dont allow more than 1000 record in list.