Skip to main content
ManojKumar Muthu (Appviewx) a posé une question dans #Apex

Hi,

I am trying to list all case created to particular account here the parameter is the AccountId, below the apex code,

@RestResource(urlMapping='/CaseAccountid/*')

global with sharing class CaseAccountid{

@HttpGet

    global static List<Case> getCaseById() {

       RestRequest req = RestContext.request;

        RestResponse res = RestContext.response;

        String emailAddress = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);

          List<case> result =  [Select id, subject, status, Version__c, type, priority, AccountId, OwnerId, CSM_ID__c, ContactEmail from Case where AccountId = :ID];

        return result;

    }

}

I get Error: Compile Error: Variable does not exist: AccountId at line 9 column 170

Can someone help me on this asap.

Thanks in advance.

 
5 réponses
  1. 6 juil. 2018, 10:40
    I tried below code, I am able to save. You also try and see. Changes are in bold.

    @RestResource(urlMapping='/CaseAccountid/*')

    global with sharing class CaseAccountid{

    @HttpGet

        global static List<Case> getCaseById() {

           RestRequest req = RestContext.request;

            RestResponse res = RestContext.response;

            String ID= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);

              List<case> result =  [Select id, subject, AccountId, OwnerId, ContactEmail from Case where AccountId = :ID];

            return result;

        }

    }

    Please mark it best if it helps you. Thanks in advance.

    Regards,

    Pawan Kumar
0/9000