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
Varsha D 9Varsha D 9 

declarations can only have one scope i got this issue in apex class when i declare it as global can someone assist me with this

Best Answer chosen by Varsha D 9
AbhinavAbhinav (Salesforce Developers) 
you are using both global public use global.

If it helps mark it as best answer.

Thanks!

All Answers

AbhinavAbhinav (Salesforce Developers) 
Please add code snippet as  well to your question.

Thanks!
Varsha D 9Varsha D 9
@RestResource(urlMapping='/UserLogin/*')

global public class Rest_UserLogin  {
    @HttpGet
    global static List<User_Login__c> getLogins(){
        List<User_Login__c> userlogins = [SELECT Id,CreateDate,    Session_Length__c,Contact__r.Email From User_Login__c ];
        return userlogins;
    }
    @HttpPost
    global static void createNewLoginRecord(string systemName,string userEmail,Integer sessionLength){
        Contact c=null;
        try{
            c=[SELECT Id,Email FROM Contact WHERE Email =: userEmail].get(0);
                User_Login__c userLogin = new User_Login__c ();
                userLogin.System_Name__c=systemName;
                userLogin.Contact__c=c.Id;
                userLogin.Session_Length__c= sessionLength;
                insert  userLogin;
            RestContext.response.responseBody = Blob.valueOf('Success:Record created with id' +userLogin.id);
                
        }
        catch(Exception e){
            RestContext.response.responseBody = Blob.valueOf('Error: ' + e.getMessage());
        }
    }
    


}  
 
i m getting Error on the 2 line
AbhinavAbhinav (Salesforce Developers) 
you are using both global public use global.

If it helps mark it as best answer.

Thanks!
This was selected as the best answer
Varsha D 9Varsha D 9
Thankyou Abhinav