7

I'm using describe functions to retrieve a DescribeFieldResult. Now on an Object I have two fields: one is a formula and the other is a rollup-summary. How can I differentiate between these two "types"?

I found already, that both have isCalulate=true but that is not enough to tell them apart.

Any ideas?

6

You can tell because when you describe a Rollup Summary Field, its describe returns null when you call getCalculatedFormula(), unlike a Formula Field.

system.assertEquals(null, rollupDescribe.getCalculatedFormula());
system.assertNotEquals(null, formulaDescribe.getCalculatedFormula());
| improve this answer | |
  • Theorycrafting. Heh, I like that. – Adrian Larson Aug 4 '17 at 19:38
  • Thanks guys, that works perfectly. Might there be a way to find out about what is being rolled-up, like which field on which child object? – Uwe Heim Aug 4 '17 at 19:40
  • @UweHeim Pretty sure you're SOL there unless you want to break out one of the APIs. Even then I'm not sure what you would actually retrieve. – Adrian Larson Aug 4 '17 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.