You need to sign in to do that
Don't have an account?
MaheemSam
Bulkify the code
Hi,
Below code works as expected by passing account id it will return the top account id only issue I see in below code is query is inside the while loop is there any other way to fix this issue and make the code bulkify.
Thanks
Sudhir
Below code works as expected by passing account id it will return the top account id only issue I see in below code is query is inside the while loop is there any other way to fix this issue and make the code bulkify.
public static String GetTopLevleElement(Id objId ){ Boolean topLevelParent = false; if( objId <> null){ while ( !topLevelParent ) { Account a = [ Select Id, ParentId From Account where Id = :objId limit 1 ]; if ( a.ParentID != null ) { objId = a.ParentID; } else { topLevelParent = true; } } } return objId ; }
Thanks
Sudhir
Hi Sudhir,
I don't think your code needs to be bulkified. Because your while loop will be called only once. so you are good.
pls let me know you are calling this method in another loop.
Thanks,
Manohar
Below is the helper class how am using the method calling the class inside the trigger. please the code comment I am calling the method. Thanks
Sudhir
Hi Sudhir,
Is this code working for you? If bilkification is the problem then you don't have to worry about that. Because its not in loop..
if its not, then you can try something like this.
if this doesn't help please let me know more about the condtions when you are trying to create opportunity team member.
Thanks,
Manohar
I tried executing your code in line 48 of your code it is giving me Error: Compile Error: Unexpected token 'public'. at line 201 column 5