You need to sign in to do that
Don't have an account?
pierrefrazny.ax358
Passing field name as a method parameter, possible?
I wrote a method which is called by a trigger. This method sums all records matching a
specific criteria and update a field on a parent object.
I have to write several methods which should behave the same way except that the criteria is different adn the field
on the parent object to update is also different.
Is it possible in Apex to pass the name of a field as a parameter of
a method?
Hello
I wrote a method which is called by a trigger. This method sums all records matching aspecific criteria and update a field on a parent object. I have to write several methods which should behave the same way except that the criteria is different and the field on the parent object to update is also different.
Is it possible in Apex to pass the name of a field as a parameter of a method? And then use this parameter in a DML and SOQL statements?
Thanks.
Pierre
I can't see any reason why you wouldn't be able to do this. The field name is just a string, and you can use dynamic soql to include it in a query or the sobject get/put methods to get/put values to it.