0

Tried with the below code, it's throwing an error.

    MetadataService.MetadataPort service = createService();
    MetadataService.Group_x  CreateGroup = new MetadataService.Group_x();
    CreateGroup.fullName = 'Test';
    CreateGroup.doesIncludeBosses = false;
    CreateGroup.name = 'Test';
    List < MetadataService.SaveResult > saveResultList = new list < MetadataService.SaveResult > ();
    saveResultList = service.createMetadata(new MetadataService.Metadata[] {CreateGroup});

Error: Line: 13404, Column: 1 System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Unable to determine type mapping for type {http://soap.sforce.com/2006/04/metadata}Group_x. Type is illegal here. faultcode=soapenv:Client faultactor=

2 Answers 2

1

In Apex, you can create a Group directly. There's no need to invoke the Metadata API here.

Group g = new Group(Name='Test',doesIncludeBosses=false);
insert g;

I'm not entirely sure why the FF metadata API isn't working here, but it's strictly not necessary for your use case.

0

Thanks, @sfdcox.

I got the Answer. There were issues in the metadata service apex class.

I changed the below code, it's working fine.

public class Group_x extends Metadata {
    public String type = 'Group_X';  // Changed to type = 'Group'
    public String fullName;
    private String[] fullName_type_info = new String[] 
       {'fullName',SOAP_M_URI,null,'0','1','false'};
    public Boolean doesIncludeBosses;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .