Metadata.CustomMetadata class causes inspector errors
I'm getting errors from the inspector when using the Metadata.CustomMetadata class in Apex. If I just take the "Deploy Metadata" example from SF docs here:
public class CreateMetadata{
public void updateAndDeployMetadata() {
// Setup custom metadata to be created in the subscriber org.
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
customMetadata.fullName = 'ISVNamespace__MetadataTypeName.MetadataRecordName';
Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
customField.field = 'customField__c';
customField.value = 'New value';
customMetadata.values.add(customField);
Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
mdContainer.addMetadata(customMetadata);
// Setup deploy callback, MyDeployCallback implements
// the Metadata.DeployCallback interface (code for
// this class not shown in this example)
MyDeployCallback callback = new MyDeployCallback();
// Enqueue custom metadata deployment
Id jobId = Metadata.Operations.enqueueDeployment(mdContainer, callback);
}
}
Then, the inspector thinks that:
customMetadata.fullName = 'ISVNamespace__MetadataTypeName.MetadataRecordName';
is using incompatible types. And it cannot find the definition for "add" in the following:
customMetadata.values.add(customField);
Obviously, it's not a show-stopper as I can save my work anyway, but it would be nice to have fewer red lines!
Comments (4)
-
reporter -
repo owner Sorry...let me try again. On further inspection, you're correct that this is another instance of
#821. The Salesforce Tooling API that provides descriptions of system types isn't including all of the details about types from the newMetadata
namespace, in particular the field data types. I'll ping Salesforce about this and see if/when they're planning to address it. -
repo owner - changed status to resolved
Aidan, I confirmed that the issue is with Salesforce's Tooling API completions resource. It doesn't return type information for properties, and the types in the
Metadata
namespace are pretty much containers for properties vs. accessor methods for internal data which could include type information. Here's a sample of what you get back from thecompletions
resource for those properties:Unfortunately this is something that Salesforce is going to need to resolve because the scope of the issue is quite broad. I'll follow up with them and ask if/when they're going to take care of this.
-
repo owner I've just reached out to a few folks who should be able to provide thoughts on how/when this omission of important type information will be resolved. If/when I hear anything useful, I'll try to provide an update here.
- Log in to comment
May be related to https://bitbucket.org/RoseSilverSoftware/illuminatedcloud/issues/821/many-system-types-in-the-ost-lack-proper
But, I don't know enough about the internals to tell if it's the same issue or not. fullName doesn't appear in the OST for Metadata.CustomMetadataValue as far as I can tell, so maybe it's not the same.