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
SFDC kidsSFDC kids 

Class not saving

Hi Team

I am not able to save below code:
@RestResource(urlMapping='/CreateCustomer/*')
global with sharing class CreateCustomerRestAPI {

    @HttpPost
    global static string doPost(){
        RestRequest  req     = RestContext.request;   
         String jsonInput  = req.requestBody.toString();


        AccountWrapper d = (AccountWrapper)JSON.deserialize(jsonInput, AccountWrapper.class);

    return null;

}   

    public class AccountWrapper{
    public String name; //AccountTest
    public cls_contact contact;
    public class cls_contact {
        public String firstName; 
        public String secondName;
    }
  }

}

Please suggest

 
Best Answer chosen by SFDC kids
mukesh guptamukesh gupta
Hi,

Salesforce only support only one level of class, You can only have inner classes one level deep

Eample
 
public class myOuterClass {
   // Additional myOuterClass code here
   class myInnerClass {
     // myInnerClass code here
   }
}

if you want to get more then one level then you need to create a another class.


if you need any assistanse, Please let me know!!


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

 

All Answers

mukesh guptamukesh gupta
Hi,

Salesforce only support only one level of class, You can only have inner classes one level deep

Eample
 
public class myOuterClass {
   // Additional myOuterClass code here
   class myInnerClass {
     // myInnerClass code here
   }
}

if you want to get more then one level then you need to create a another class.


if you need any assistanse, Please let me know!!


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

 
This was selected as the best answer
SFDC kidsSFDC kids
Hi Mukesh
.
Thanks for quick support, i need some supprt in LWC, i am stuck in myt project can you please provide a help

Regards