function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Srinivas YSrinivas Y 

COMPILE ERROR: Invalid type: MetadataService.SaveResult

Getting Compile Error::  COMPILE ERROR: Invalid type: MetadataService.SaveResult 
when trying to use MetadataService as below::

MetadataService.MetadataPort service = new MetadataService.MetadataPort();


Not sure how to overcome this problem, FYI:: Our org is using API Version: 34. 

 
Neetu_BansalNeetu_Bansal
Hi Srinivas,

You need to import all the classes from the metadata sample to get this working. 
Check this for all the classes in metadata sample and add them to your org
https://github.com/financialforcedev/apex-mdapi/tree/master/apex-mdapi/src/classes

and this is for the MetadataServiceExample class
https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceExamples.cls

Also, do you have the latest version of the MetadataService.cls class from this repo in your org? You must use the one from this repository and not the default generated one from Salesforce.

If you still not able to resolve, paste your class code. If it helps, mark it as best answer.

Thanks,
Neetu
Rashmi TyagiRashmi Tyagi
Hi Srinivas, It could be the possibility someone has created apex class with MetadataService name,so this class need to be deleted and error will be resolved.

Thanks,
Rashmi