• hiteshwar marni
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 30
    Questions
  • 9
    Replies
@RestResource(urlMapping='/mhc/*')

global  class CaseManager {

 

    @HttpGet

    global static void getCaseById() {

      

        // grab the caseId from the end of the URL
        String jsonResponse = '';
       RestRequest request = RestContext.request;
        RestResponse res = RestContext.response;
        string caseId= request.params.get('caseId');
          
            
        try{
        if(caseId!=null  ){
            
       Case result =  [SELECT CaseNumber,Subject,Status,Origin,Priority

                        FROM Case

                        WHERE Id = :caseId];
                     
             res.responseBody = Blob.valueOf(JSON.serialize(result));
            res.statusCode = 200;
            }
             else{
                
            throw new caserestexception(400,'aaaa');
            }
            }
           
            
        catch(caserestexception ex)
        {
             caserestexception aa;
             res.statusCode = 400;
            jsonResponse = '{"response": {"status": "Failure", "message": "' + ex + '"}}';
            res.responseBody = blob.valueOf(jsonResponse);
            return;
        }
                 
            
            
             
            
               


    }
    
}

I want to get my own error but i'm getting salesforce standard error.how to override standard error

 
{"Message":"Number of Post office(s) found: 21","Status":"Success","PostOffice":[{"Name":"Baroda House","Description":"","BranchType":"Sub Post Office","DeliveryStatus":"Non-Delivery","Taluk":"New Delhi","Circle":"New Delhi","District":"Central Delhi","Division":"New Delhi Central","Region":"Delhi","State":"Delhi","Country":"India"}]}

The above is my json string.
I have written the following code deserialize it

global class wrapper{
global class parserr
    {
       global string Message{get;set;}
       global string Status{get;set;} 
       global list<postoffice>po{get;set;}
    }
    global class postoffice
    {
        global string name{get;set;}
        global string Description{get;set;}
        global string BranchType{get;set;}
        global string DeliveryStatus{get;set;}
        global string Taluk{get;set;}
        global string Circle{get;set;}
        global string District{get;set;}
        global string Division{get;set;}
        global string Region{get;set;}
        global string state{get;set;}
        global string country{get;set;}
    }
}

 p= (wrapper.paresrr)JSON.deserialize(JSONresponse, wrapper.parserr.class);
I'm getting the values of Message and status correctly. But list<postoffice> po is getting as null although values are coming into response.And also I want the values in postoffice class also.
Thanks
I'm querying some fields in knowledgearticle version , but I need to qeury another field from articletype__kav also.how to do it?
As there is no relation between knowledgeArticleversion and articletype__kav.


Thanks
I'm trying to create feedpollchoice record in test class but it's throwing exception as fields not writable although i have pernission.pls help on this thanks
I'm writing below batch apex to transfer the accounts of particualr user to another user
bu it's throwing error as " EXCEPTION_THROWN [7]|System.QueryException: unexpected token: 'Eo3Z' ".
Thanks

global class accountownerhangebatch implements database.batchable<sobject>{
        
    global database.querylocator start(database.batchablecontext bc){
   string query = 'select Name,Ownerid from account where ownerid = 00528000001Eo3Z' ;
    return database.getquerylocator(query);
    }
    
    global void execute (database.batchablecontext bc, list<Account> scope){
    id oid = 'SELECT Id,name FROM User WHERE name = marni user1';
        for(account a : scope){
        
        a.Ownerid= oid;
        system.debug('---->'+a.Ownerid);
              
        }
          update scope;

    }
    
    global void finish(database.batchablecontext bc){
    
    }

}
I am not able to get a clarity on the Database.query() , Database.getQueryLocator and Database.QueryLocator.I have gone through many documents but no use.Could any one help me on this.
Thanks
I have scheduled my certification exam on 8-August-2016.But in the middle of the exam it has been suspended automatically without any prior information.I have raised a case,but they didn't respond till date.Could any one suggest me how to proceed further.

Should I again book the slot by paying total amount,or will they reschedule it with amount with which I have booked slot before.

Thanks
Hiteshwar