SObject.describe is a nice convenience method when I want to investigate the SF metadata behind an object.
However, I'm often only looking for a particular field and the object that's returned from this endpoint is rather large and unruly. For example, to get the metadata for a particular field, I run something like this:
MyObject.describe.fields.find { |f| f['name'] == 'My_Field__c' }
Which is kind of verbose and requires having to look up the name of the SF field that maps to the object attribute.
It would be nice if ActiveForce exposed a method that did this for me, including mapping a symbol for the attribute name to the correct SF field name. Something like:
MyObject.describe_field(:my_field)
It should also take a string for the actual SF field as well, which should be pretty easy to implement.
MyObject.describe_field('My_Field__c')
Or, possibly it should be variadic and take one or many field names, returning an array of field metadata:
MyObject.describe_fields(:my_field, :another_field, 'One_More__c')
SObject.describeis a nice convenience method when I want to investigate the SF metadata behind an object.However, I'm often only looking for a particular field and the object that's returned from this endpoint is rather large and unruly. For example, to get the metadata for a particular field, I run something like this:
Which is kind of verbose and requires having to look up the name of the SF field that maps to the object attribute.
It would be nice if ActiveForce exposed a method that did this for me, including mapping a symbol for the attribute name to the correct SF field name. Something like:
It should also take a string for the actual SF field as well, which should be pretty easy to implement.
Or, possibly it should be variadic and take one or many field names, returning an array of field metadata: