Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we create ApexClass natively? Any Example? #289

Open
mhamzas opened this issue Oct 17, 2022 · 1 comment
Open

Can we create ApexClass natively? Any Example? #289

mhamzas opened this issue Oct 17, 2022 · 1 comment

Comments

@mhamzas
Copy link

mhamzas commented Oct 17, 2022

Hi,

First, this repo is GREAT! I was wondering if we can create and deploy the apex class natively?
Couldn't find any example in this repo. Can anybody share the example if its possible?

@mhamzas
Copy link
Author

mhamzas commented Oct 17, 2022

I've tried creating a method

public static void createClass()
    {
        MetadataService.MetadataPort service = createService();
        MetadataService.ApexClass apexClass = new MetadataService.ApexClass();
        apexClass.apiVersion = 50;
        apexClass.fullName = 'test';
        //apexClass.label = 'TestHamza';
        apexClass.content = EncodingUtil.base64Encode(Blob.valueOf('public with sharing class TestHamza{}'));
        List<MetadataService.SaveResult> results =
            service.createMetadata(
                new MetadataService.Metadata[] { apexClass });
        handleSaveResults(results[0]);
    }

but it's giving the error

Line: 13432, Column: 1System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: '' is not a valid value for the enum 'ApexCodeUnitStatus' faultcode=soapenv:Client faultactor=
--

@mhamzas mhamzas changed the title Can we create ApexClass? Any Example? Can we create ApexClass natively? Any Example? Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant