• Kevin Gall
  • NEWBIE
  • -1 Points
  • Member since 2017
  • CM&F Group

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I am new to Salesforce development and am trying to write a configurable Apex class using Custom Metadata Types. On the surface, it seems perfect, because what I need to do is associate fields from one object with fields from another object to indicate to my Apex class that it should copy data from one field directly into the other on two separate object types. (Please don't suggest that they should be the same object type. They can't be for org-specific reasons.)

The Metadata Relationships field type allows a user configuring my class to choose an object and a field from that object, not type in a class name and field name which my code assumes is correct to use in an sObject.get() or .put() method call. I planned on using this configured information to discover which objects to relate, grab the value of a field for a concrete record of one object type and copy it to a field in a new record of the other object type.

So I created the Custom Metadata Type and created a couple test records to test my queries, but instead of returning useful sObject or other Schema-related information, the Metadata Relationship fields simply return the Salesforce ID for the relevant object or field type. Note: this is an ID for a Metadata record, not for a Data record.

"OK," I thought, "I can use this."
...Apparently not. It seems impossible to query an sObject type using its ID, which I assume is because it is Metadata, so it's not supported the same way as if I would query a data record.

Fine.

I looked at the Metadata API and thought I'd create a set of wrapper Apex classes around the SOAP web services, basically doing a web callout from within an Apex Class to my Metadata API within my org. The simplest way to do this is supposed to be to download the WSDL for the Metadata API, then "Generate Apex Classes from WSDL" in Apex Class definitions in Setup.

However, whenever I try to import, it tells me there are class name conflicts for the "Metadata" complexType. I've renamed that complex type to something guaranteed org-unique, and searched through the WSDL to find multiple complex type that maybe mistakenly redefined "Metadata," but nothing. And it can't import from WSDL as long as that issue occurs.

So that's everything I've tried. I'm sure I'm missing something somewhere, but I've spent many hours poring through documentation and keep hitting road blocks. How can I use the Metadata Relationships fields within an Apex Class to make my app written in Apex configurable?
I am new to Salesforce development and am trying to write a configurable Apex class using Custom Metadata Types. On the surface, it seems perfect, because what I need to do is associate fields from one object with fields from another object to indicate to my Apex class that it should copy data from one field directly into the other on two separate object types. (Please don't suggest that they should be the same object type. They can't be for org-specific reasons.)

The Metadata Relationships field type allows a user configuring my class to choose an object and a field from that object, not type in a class name and field name which my code assumes is correct to use in an sObject.get() or .put() method call. I planned on using this configured information to discover which objects to relate, grab the value of a field for a concrete record of one object type and copy it to a field in a new record of the other object type.

So I created the Custom Metadata Type and created a couple test records to test my queries, but instead of returning useful sObject or other Schema-related information, the Metadata Relationship fields simply return the Salesforce ID for the relevant object or field type. Note: this is an ID for a Metadata record, not for a Data record.

"OK," I thought, "I can use this."
...Apparently not. It seems impossible to query an sObject type using its ID, which I assume is because it is Metadata, so it's not supported the same way as if I would query a data record.

Fine.

I looked at the Metadata API and thought I'd create a set of wrapper Apex classes around the SOAP web services, basically doing a web callout from within an Apex Class to my Metadata API within my org. The simplest way to do this is supposed to be to download the WSDL for the Metadata API, then "Generate Apex Classes from WSDL" in Apex Class definitions in Setup.

However, whenever I try to import, it tells me there are class name conflicts for the "Metadata" complexType. I've renamed that complex type to something guaranteed org-unique, and searched through the WSDL to find multiple complex type that maybe mistakenly redefined "Metadata," but nothing. And it can't import from WSDL as long as that issue occurs.

So that's everything I've tried. I'm sure I'm missing something somewhere, but I've spent many hours poring through documentation and keep hitting road blocks. How can I use the Metadata Relationships fields within an Apex Class to make my app written in Apex configurable?
I'm using the Salesforce IDE plugin in Eclipse, and I can't figure out how to create a test suite and add test classes to that suite. I can run individual test classes just fine though. Thanks in advance for you help!