• kumarcrm bingi
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 9
    Replies
Apex class Rest API

System.NullPointerException: Attempt to de-reference a null object

@RestResource(urlMapping='/Accounts/*/contacts')
global class AccountManager {
@HttpGet
global static Account getAccount() {
RestRequest request = RestContext.request;
String accId =                request.requestURI.substringBetween('Accounts/','/contacts');
/* Here the issue i am getting System.NullPointerException: Attempt to de-reference a null object */
 Account acc = [SELECT Id, Name, (SELECT Id, Name FROM Contacts) FROM Account WHERE Id = :accId];
return acc;

}


 
i am writing tirgger got issue attment to dereference null issue click save button i got the issue

ChangingFirstlttrUpper Trigger 
=======================
trigger ChangingFirstlttrUpper on Project__c (before insert,before update) {
ChanignToCaps.Change(trigger.new);
    if(trigger.isBefore ){
         if(trigger.IsInsert ||trigger.IsUpdate ){
          ChanignToCaps.Change(trigger.new);
         ChanignToCaps.Change(trigger.new);        }
        
    }
}

Handler class
------------------------
global class ChanignToCaps{
   global static void Change( Project__c [] Pro){
      for(Project__c  P :Pro){
         if(P.PoPupfield__c !=null || P.PoPupfield__c  != ' '){
           P.PoPupfield__c = formatToUpper(P.PoPupfield__c );
   }
   
}

Helper Class
----------------------
public class FirstlttrUpper{
public static String formatToUpper (String Str) {
String result = '';
for (String iter : Str.split('[ ]+')) {
   if (iter != null && iter != '') {
    if (iter.length() > 1) {
     result += iter.substring(0,1).toUpperCase() + iter.substring(1,iter.length()) + ' ';
    }
    else
     result += iter.substring(0,1).toUpperCase() + ' ';
   }
}
return result;
}
}

Error 

ERROR!
ChangingFirstlttrUpper: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Class.FirstlttrUpper.formatToUpper: line 4, column 1 Class.ChanignToCaps.Change: line 10, column 1 Trigger.ChangingFirstlttrUpper: line 2, column 1
apex class : done
rest api :- done
test calss :- done
still i am not enabel option  any one guide 
me pleaseUser-added imageThank you
 
TEST Class 

@isTest
private class MaintenanceRequestTest{
    @testSetup
    static void setup(){
        //Equipment SETUP
        List<Product2> lstOfEqpmnts = new List<Product2>();
        
        Product2 eqip = new Product2(Name = 'Test Equipment', 
                                     Maintenance_Cycle__c = 10,
                                     //Cost__c = 100,
                                     Current_Inventory__c = 10,
                                     Lifespan_Months__c = 10,
                                     Replacement_Part__c = true,
                                     Warehouse_SKU__c = 'abc');
        lstOfEqpmnts.add(eqip);
        INSERT lstOfEqpmnts;
    }
    
    @isTest
    static void testMaintenanceRequest(){
        List<Case> lstOfInsertMRs = new List<Case>();
        
        List<Case> lstOfUpdtMRs = new List<Case>();
        
        Id equipId = [SELECT Id FROM Product2 LIMIT 1].get(0).Id;
        
        Case newCase = new Case(Type = 'Routine Maintenance',Status = 'New', Origin = 'Phone');
        newCase.Equipment__c = equipId;
        lstOfInsertMRs.add(newCase);
      
       Case mrInsert = new Case(Type = 'Routine Maintenance2', Status = 'New', Origin = 'Phone');
       mrInsert.Equipment__c = equipId;
       lstOfInsertMRs.add(mrInsert);
        
        
        Test.startTest();
            INSERT lstOfInsertMRs;
            
            System.assertEquals(2, lstOfInsertMRs.size());
            
            for(Case mrUpdt : lstOfInsertMRs){
                mrUpdt.Status = 'Closed';
                lstOfUpdtMRs.add(mrUpdt);    
            }
            
            UPDATE lstOfUpdtMRs;
            
          System.assertEquals(2, lstOfUpdtMRs.size());
        Test.stopTest();
    }
}
This is my Class
-------------------
trigger trgStudentSchoolFields on Student_School_Fields__c (after insert, after update){
    String IntegrationUser = System.Label.IntegrationUser;
    map<string,string> mapContacts = new map<string,string>();
    list<Contact> listOfContact = new list<Contact>();
    list<Inquiry__c> inquiryList = new list<Inquiry__c>();
    list<Opportunity> oppList = new list<Opportunity>();
    String uid = userinfo.getUserId();
    String IntgUser;
    system.debug('USERID>>>' + uid);
    system.debug('IntegrationUser>>>' + IntegrationUser);
    list<Contact_Method__c> cmlist=new list<Contact_Method__c>();
    Set<string> stdscmid = New Set<string>();
    List<Error__c> errconlst = New List<Error__c>();
    List<Error__c> errlst = New List<Error__c>();  
   // if (!uid.contains(IntegrationUser))
   // {
    if(userinfo.getUserId() != '00555000003neB6'){
        list<Student_School_Fields__c> lstSchStud=new list<Student_School_Fields__c>();
        for(Student_School_Fields__c schstudobj:trigger.new)
        {
            stdscmid.add(schstudobj.id);
            lstSchStud.add(schstudobj);
            mapContacts.put(schstudobj.Contact__c, schstudobj.Student_Enrollment_Campus__c);
        }
        errconlst = [select ErrorCode__c, Error_Message__c, Error_Type__c, ObjectType__c, Status__c,
                     ContactRelated__c, OpportunityRelated__c, APIOperation__c
                     From Error__c 
                     Where Error_Type__c = 'Data' 
                     AND Status__c = 'Failed' 
                     AND ObjectType__c = 'StudentSchoolFields'
                     AND StudentSchoolFieldRelated__c IN :stdscmid];
        for (Error__c errobj:errconlst)
        {
            errobj.Status__c = 'Processed';
            errlst.add(errobj);
        }
        if (errlst.size() > 0)
            update errlst;
        
        if(mapContacts.size()>0 && !mapContacts.isEmpty()){
            for(Contact con : [SELECT Id, Student_Enrollment_Campus__c FROM Contact
                               where  id IN:mapContacts.keySet()]){
                                   string enrollment = mapContacts.get(con.id);
                                   System.debug('con'+con);
                                   System.debug('enrollment'+enrollment);
                                   if(enrollment != null){
                                       con.Student_Enrollment_Campus__c = enrollment; 
                                       listOfContact.add(con);
                                   }
                               }
            
            for(Inquiry__c inquiry : [SELECT Id, Student_Student_Enrollment_Campus__c, Contact__c FROM Inquiry__c
                                      where  Contact__c IN:mapContacts.keySet()]){
                                          System.debug('inquiry'+inquiry);
                                          string enrollment = mapContacts.get(inquiry.Contact__c);
                                          if(enrollment != null){
                                              inquiry.Student_Student_Enrollment_Campus__c = enrollment; 
                                              inquiryList.add(inquiry);
                                          }
                                      }
            for(Opportunity opp : [SELECT Id, ContactId , Student_Enrollment_Campus__c FROM Opportunity where
                                   ContactId  IN:mapContacts.keySet()]){
                                       System.debug('opp'+opp);
                                       string enrollment = mapContacts.get(opp.ContactId);
                                       if(enrollment != null){
                                           opp.Student_Enrollment_Campus__c = enrollment; 
                                           oppList.add(opp);
                                       }
                                   }
            if(listOfContact.size()>0 && !listOfContact.isEmpty()){
                TrgInquiryHandler.isStudentSchoolStopTriggerContact=true;
                update listOfContact;
            }
            if(inquiryList.size()>0 && !inquiryList.isEmpty()){
                update inquiryList;
            }
            if(oppList.size()>0 && !oppList.isEmpty()){
                TrgInquiryHandler.isStudentSchoolStopTriggerOpp=true;
                update oppList;
            }
        }
        string jsonstr=JSON.serialize(lstSchStud);
        
        if(Trigger.isAfter && Trigger.isInsert || Trigger.isAfter && Trigger.isUpdate )
        {   if(!System.isFuture() && !System.isBatch())
            studentSchoolFields.updateSchfldStudentsCVUe(jsonstr);
        }
   // }
        }
}


Test Class 
=============
@isTest
Public  class trgStudentSchoolFieldsTestClass {  
    public static testmethod void contactmethodtest(){
    
       set<string> conid=new set<string>();
        
        Contact con =new Contact();
        con.lastname = 'testmore';
        con.Subscribe_To_SMS_Service__c=true;
        con.Student_Enrollment_Campus__c = 'AUR';
        insert con;
        
        Inquiry__c  inq = new Inquiry__c();
        inq.Name = 'inasfewna===100years====createNewInq';
        inq.Student_Student_Enrollment_Campus__c = 'ONL';
        inq.Contact__c = con.id;
       // insert inq;

        
        Contact_Method__c cm=new Contact_Method__c();
        cm.Name='test';
        cm.Contact__c=con.Id;
        cm.Subscribe_To_SMS_Service__c=true;
        insert cm;
        conid.add(cm.id);
    }
    }
This test class is not Code Coverage in my Class were i am missing i am not understand can you please any one help me
EXCEPTION_THROWN [7]|System.QueryException: Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch

global class DuplicateEmailCheck implements Database.Batchable<sObject>, Database.Stateful
{
   
    global Database.querylocator start(Database.BatchableContext BC)
    {
        string qurey = 'select CmEventID__c from task GROUP BY CmEventID__c HAVING COUNT(CmEventID__c) > 1';
        //The below query returns all the emailId which has more than one entry
        return Database.getQueryLocator(qurey);
    }
global void execute(Database.BatchableContext BC, List<AggregateResult> scope){
    Set<String> arEmailId = new set<String>();
    //Below loop is to collect all the email ids from aggregateresult of start method to a set which will be used to filter records .
    for (AggregateResult ar : scope)
    {
           arEmailId.add((String)ar.get('CmEventID__c'));
    }
 List<task> fanList = [select CmEventID__c,id from task  where CmEventID__c in :arEmailId];
 delete fanList;
}    
global void finish(Database.BatchableContext BC)
{
}
}
public class CER_Reimbursement_SendemailController {
public String caseId {get;set;}
public list<CER_Expense_Reimbursement__c> CER_Expense_Reimbursement {get;set;}

Public CER_Reimbursement_SendemailController(){
caseId = ApexPages.currentPage().getParameters().get('Id');
system.debug('case id->'+caseId );
}

Public Pagereference sendEmailFunction(){
CER_Expense_Reimbursement__c[] getEmail = [SELECT Id, EER_EmployeeName__r.email FROM CER_Expense_Reimbursement__c WHERE id=:caseId];
if (getEmail.size() > 0){
    if(getEmail[0].EER_EmployeeName__r.email != null) {
String toaddress = getEmail[0].EER_EmployeeName__r.email;

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {toaddress};
String[] ccAddresses = new String[] {'sfdcsrini@gmail.com'}; 
mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);
mail.setReplyTo(toaddress);
mail.setSenderDisplayName('Name');
mail.setSubject('Testing email through apex');
mail.setBccSender(false);
mail.setUseSignature(true);
mail.setPlainTextBody('This is test email body. This mail is being sent from apex code');
//mail.setHtmlBody('<b> This is HTML body </b>' );

List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :caseId]){
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(a.Name);
efa.setBody(a.Body);
fileAttachments.add(efa);
//mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
}
mail.setFileAttachments(fileAttachments);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

}
}

PageReference reference = new PageReference('Url'+caseId);
reference.setRedirect(true);
return reference;
}
}
visual force 
<apex:page controller="CER_Reimbursement_SendemailController">
<apex:form >
<script type="text/javascript">
function init() {
sendEmail();
}
if(window.addEventListener)
window.addEventListener('load',init,true)
else
window.attachEvent('onload',init)
</script>

<apex:actionFunction name="sendEmail" action="{!sendEmailFunction}">
</apex:actionFunction>
</apex:form>
</apex:page>
User-added image
 
public class AccountGroup {
    
    @AuraEnabled
    public static string doWebCallTest(Id pv_ObjectId){
        //return utility_wrapper.parse(HW_WebCall_OROServices.prepareWebCall('similarUsers', new list<String>(), pv_ObjectId));
        string respons = HW_WebCall_OROServices.prepareWebCall('similarUsers', new list<String>(), pv_ObjectId);
        Map<String,String> customerIds = new Map<String,String>();
        system.debug('respons'+respons);         
        fromJSON deserializedJsonString = (fromJSON) System.JSON.deserialize(respons, fromJSON.class);
        system.debug('deserializedJsonString*************'+deserializedJsonString);        
        System.debug('gv_ResponseBody********************' + deserializedJsonString.gv_ResponseBody);
This varaiable to assined to wrapper class that wrapper to bined the ui part but i am not get the result were i am strucking
     /*****  fromJSON1 similarusers = (fromJSON1) System.JSON.deserialize(deserializedJsonString.gv_ResponseBody, fromJSON1.class); *********/
        system.debug('similarusers+++++++++++++++++'+similarusers);
        Set<String> mySet = new Set<String>();
        Map<String,List<String>> myMapresponse = new Map<String,List<String>>();
        for(cls_similar_users s :similarusers.similar_users){
            mySet.add(s.id);
            myMapresponse.put(s.id,s.reasons);
        }
        system.debug('mySet'+mySet);
        system.debug('myMapresponse'+myMapresponse);
        Map<Set<String>,Map<String,List<String>>> sndMap = new Map<Set<String>,Map<String,List<String>>>();
          Map<String,String> accMap = new Map<String,String>();
      //  list<account> aa = [select id, name,Auxmoney_ID__c from account where Auxmoney_ID__c in :mySet];
      list<account> aa =  [SELECT Id, Name, Street__c, Number__c,auxmoney_ID__c, Postal_Code__c, City__c, PersonEmail, TOLABEL(Kundenstatus__c), AK_faehig__c, TOLABEL(Berufsgruppe__c),
                                      (SELECT Id, auxmoney_ID__c, Wunschbetrag__c, TOLABEL(Restkreditversicherung__c), TOLABEL(Vertriebskanal__c), Monatliche_Rate__c, Laufzeit__c, Effektivzins__c, TOLABEL(QS_Fall__c), TOLABEL(auxmoney_Score__c), StageName, Erstellt_am__c
                                       FROM Opportunities ORDER BY Erstellt_am__c DESC)
                                      FROM Account
                                     WHERE auxmoney_ID__c in :mySet];
        for(Account a : aa){
            
            accMap.put(a.auxmoney_ID__c,a.Name);
            system.debug('accMap'+accMap);
        
            // accMap.put(a.Name,a.Auxmoney_ID__c);
        }
        Map<List<String>,List<List<String>>> mymaps = new  Map<List<String>,List<List<String>>>();
        Map<Set<String>,List<List<String>>> myMapf = new Map<Set<String>,List<List<String>>>();
      //  Map<Set<String>,List<String>> mymapss = new  Map<Set<String>,List<String>>();
        Map<Set<Set<String>>,Map<List<String>,List<List<String>>>> mymapss = new Map<Set<Set<String>>,Map<List<String>,List<List<String>>>>();

        system.debug(myMapresponse.keySet());
         system.debug(accMap.keySet());
        for(String s :accMap.keySet()){
            system.debug(myMapresponse.containsKey(s));
            if(myMapresponse.containsKey(s)){
                
                system.debug('inside loop'+s);
                
                myMapf.put(accMap.keySet(),myMapresponse.values());
                mymaps.put(accMap.values(),myMapresponse.values());
                mymapss.put(myMapf.keySet(),mymaps);                    
                
            }
            
            
            
        }
        system.debug('mymapss'+mymapss);
         system.debug('mymaps'+mymaps);
        system.debug('myMapf'+myMapf);
          system.debug('sndMap'+sndMap);
        
       
  
        similarusers.lstAccs=aa;
        system.debug('accountslist'+aa); 
        respons=JSON.serialize(similarusers);
        System.debug('Return respons**************'+respons);
        System.debug('Return respons.similar_users**************'+respons);
        
         string resmap = JSON.serialize(mymapss);
        
         System.debug('resmap++++++++++++++'+resmap);
        
       
        return respons;
    }
    public class fromJSON{
        public String gv_ResponseBody;    
        public String gv_Message;    //
        public boolean gv_IsWebCallSuccess;
        public boolean gv_IsWebCallExceute;
        public boolean gv_IsLoggingSuccess;
        public String gv_HTTPStatus;    //OK
        public Integer gv_HTTPCode;    //200
        public boolean gv_HasError;
        //public cls_similar_users[] similar_users;
        public list<account> lstAccs;   
    }
    public class fromJSON1{
        public cls_similar_users[] similar_users;
        public list<account> lstAccs;   
    }
    class cls_similar_users {
        public String id;    //2030733
        public list<string> reasons;
    }
    public class both{
        public Map<Set<Set<String>>,Map<List<String>,List<List<String>>>> responsemap;
        public fromJson1[] bothval;
    
        //public String id;
       // public String name;
       // public String reasons;
        
        
    }
 
    public class wrapperuser{    
        //public list<httpwrapperuser> wrapperuser{get;set;}
        public list<httpwrapperuser> similarusers{get;set;}
    }
    public class httpwrapperuser{
        public string id {get;set;} 
        public string reasons{get;set;}
        public string MatchAddress{get;set;}
        public string MatchLastnameStreetCity{get;set;}
        public string MatchNameBirthday{get;set;}
        public string MatchPhoneNumber{get;set;}
        
    }
}
Hi,
 I am writting trigger in I have Stakeholder object that is the related list to Opportunity and Contact. On Contact detail page, we have NPS ID field on the Contact detail page that is look up to the Voice of NPS object (Customer Object). The following code will get the NPS ID field value from the Contact detail page in the Stackholders page which we can able to clickable.
Create NPS Id 1 field on the stackholders object which is the look up to the Voice of NPS object (Customer Object)

This is my trigger

trigger updateNpsid on shareholder__c (before insert,before update) {
List<id> ConList = new List<id>();
 for(shareholder__c sh:Trigger.New){
ConList.add(sh.Contact_Name__c);
 }
 List<Contact> lc = [Select NPS_Id__c,NPSlookup__c From Contact Where id IN : ConList];
 for(shareholder__c sh:Trigger.New){
 sh.NPS_Id1__c = lc.NPS_Id__c;
 }
}

Error is Variable does not exist: NPS_Id__c
Alredy i am create the field in contact 
User-added image
I do not understand which list variable assigned the values were I am missing it's my code
global class SAPRequest{

WebService static void SendApprovalRequest(string id) {


// create the new approval request to submit
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval. Please approve.');
 req.setObjectId(id);
 req.setNextApproverIds(Id[]);
// submit the approval request for processing
Approval.ProcessResult result = Approval.Process(req);


// display if the reqeust was successful
System.debug('Submitted for approval successfully: '+result.isSuccess());
}
}
Error is showing Error: Compile Error: Missing ')' at '[' at line 10 column 27
 
This is my Class
-------------------
trigger trgStudentSchoolFields on Student_School_Fields__c (after insert, after update){
    String IntegrationUser = System.Label.IntegrationUser;
    map<string,string> mapContacts = new map<string,string>();
    list<Contact> listOfContact = new list<Contact>();
    list<Inquiry__c> inquiryList = new list<Inquiry__c>();
    list<Opportunity> oppList = new list<Opportunity>();
    String uid = userinfo.getUserId();
    String IntgUser;
    system.debug('USERID>>>' + uid);
    system.debug('IntegrationUser>>>' + IntegrationUser);
    list<Contact_Method__c> cmlist=new list<Contact_Method__c>();
    Set<string> stdscmid = New Set<string>();
    List<Error__c> errconlst = New List<Error__c>();
    List<Error__c> errlst = New List<Error__c>();  
   // if (!uid.contains(IntegrationUser))
   // {
    if(userinfo.getUserId() != '00555000003neB6'){
        list<Student_School_Fields__c> lstSchStud=new list<Student_School_Fields__c>();
        for(Student_School_Fields__c schstudobj:trigger.new)
        {
            stdscmid.add(schstudobj.id);
            lstSchStud.add(schstudobj);
            mapContacts.put(schstudobj.Contact__c, schstudobj.Student_Enrollment_Campus__c);
        }
        errconlst = [select ErrorCode__c, Error_Message__c, Error_Type__c, ObjectType__c, Status__c,
                     ContactRelated__c, OpportunityRelated__c, APIOperation__c
                     From Error__c 
                     Where Error_Type__c = 'Data' 
                     AND Status__c = 'Failed' 
                     AND ObjectType__c = 'StudentSchoolFields'
                     AND StudentSchoolFieldRelated__c IN :stdscmid];
        for (Error__c errobj:errconlst)
        {
            errobj.Status__c = 'Processed';
            errlst.add(errobj);
        }
        if (errlst.size() > 0)
            update errlst;
        
        if(mapContacts.size()>0 && !mapContacts.isEmpty()){
            for(Contact con : [SELECT Id, Student_Enrollment_Campus__c FROM Contact
                               where  id IN:mapContacts.keySet()]){
                                   string enrollment = mapContacts.get(con.id);
                                   System.debug('con'+con);
                                   System.debug('enrollment'+enrollment);
                                   if(enrollment != null){
                                       con.Student_Enrollment_Campus__c = enrollment; 
                                       listOfContact.add(con);
                                   }
                               }
            
            for(Inquiry__c inquiry : [SELECT Id, Student_Student_Enrollment_Campus__c, Contact__c FROM Inquiry__c
                                      where  Contact__c IN:mapContacts.keySet()]){
                                          System.debug('inquiry'+inquiry);
                                          string enrollment = mapContacts.get(inquiry.Contact__c);
                                          if(enrollment != null){
                                              inquiry.Student_Student_Enrollment_Campus__c = enrollment; 
                                              inquiryList.add(inquiry);
                                          }
                                      }
            for(Opportunity opp : [SELECT Id, ContactId , Student_Enrollment_Campus__c FROM Opportunity where
                                   ContactId  IN:mapContacts.keySet()]){
                                       System.debug('opp'+opp);
                                       string enrollment = mapContacts.get(opp.ContactId);
                                       if(enrollment != null){
                                           opp.Student_Enrollment_Campus__c = enrollment; 
                                           oppList.add(opp);
                                       }
                                   }
            if(listOfContact.size()>0 && !listOfContact.isEmpty()){
                TrgInquiryHandler.isStudentSchoolStopTriggerContact=true;
                update listOfContact;
            }
            if(inquiryList.size()>0 && !inquiryList.isEmpty()){
                update inquiryList;
            }
            if(oppList.size()>0 && !oppList.isEmpty()){
                TrgInquiryHandler.isStudentSchoolStopTriggerOpp=true;
                update oppList;
            }
        }
        string jsonstr=JSON.serialize(lstSchStud);
        
        if(Trigger.isAfter && Trigger.isInsert || Trigger.isAfter && Trigger.isUpdate )
        {   if(!System.isFuture() && !System.isBatch())
            studentSchoolFields.updateSchfldStudentsCVUe(jsonstr);
        }
   // }
        }
}


Test Class 
=============
@isTest
Public  class trgStudentSchoolFieldsTestClass {  
    public static testmethod void contactmethodtest(){
    
       set<string> conid=new set<string>();
        
        Contact con =new Contact();
        con.lastname = 'testmore';
        con.Subscribe_To_SMS_Service__c=true;
        con.Student_Enrollment_Campus__c = 'AUR';
        insert con;
        
        Inquiry__c  inq = new Inquiry__c();
        inq.Name = 'inasfewna===100years====createNewInq';
        inq.Student_Student_Enrollment_Campus__c = 'ONL';
        inq.Contact__c = con.id;
       // insert inq;

        
        Contact_Method__c cm=new Contact_Method__c();
        cm.Name='test';
        cm.Contact__c=con.Id;
        cm.Subscribe_To_SMS_Service__c=true;
        insert cm;
        conid.add(cm.id);
    }
    }
This test class is not Code Coverage in my Class were i am missing i am not understand can you please any one help me
Apex class Rest API

System.NullPointerException: Attempt to de-reference a null object

@RestResource(urlMapping='/Accounts/*/contacts')
global class AccountManager {
@HttpGet
global static Account getAccount() {
RestRequest request = RestContext.request;
String accId =                request.requestURI.substringBetween('Accounts/','/contacts');
/* Here the issue i am getting System.NullPointerException: Attempt to de-reference a null object */
 Account acc = [SELECT Id, Name, (SELECT Id, Name FROM Contacts) FROM Account WHERE Id = :accId];
return acc;

}


 
apex class : done
rest api :- done
test calss :- done
still i am not enabel option  any one guide 
me pleaseUser-added imageThank you
 
Hi,
 I am writting trigger in I have Stakeholder object that is the related list to Opportunity and Contact. On Contact detail page, we have NPS ID field on the Contact detail page that is look up to the Voice of NPS object (Customer Object). The following code will get the NPS ID field value from the Contact detail page in the Stackholders page which we can able to clickable.
Create NPS Id 1 field on the stackholders object which is the look up to the Voice of NPS object (Customer Object)

This is my trigger

trigger updateNpsid on shareholder__c (before insert,before update) {
List<id> ConList = new List<id>();
 for(shareholder__c sh:Trigger.New){
ConList.add(sh.Contact_Name__c);
 }
 List<Contact> lc = [Select NPS_Id__c,NPSlookup__c From Contact Where id IN : ConList];
 for(shareholder__c sh:Trigger.New){
 sh.NPS_Id1__c = lc.NPS_Id__c;
 }
}

Error is Variable does not exist: NPS_Id__c
Alredy i am create the field in contact 
User-added image
I do not understand which list variable assigned the values were I am missing it's my code
global class SAPRequest{

WebService static void SendApprovalRequest(string id) {


// create the new approval request to submit
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval. Please approve.');
 req.setObjectId(id);
 req.setNextApproverIds(Id[]);
// submit the approval request for processing
Approval.ProcessResult result = Approval.Process(req);


// display if the reqeust was successful
System.debug('Submitted for approval successfully: '+result.isSuccess());
}
}
Error is showing Error: Compile Error: Missing ')' at '[' at line 10 column 27