• Shivani Bankar
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
hello,
I want to create wizard such a that, I'm having two object with master detail relationship
on first VF page master object's data is inserted and when we Click on save button Detail object VF page should open with Master Object's name already inserted on it 
hello,
I'm having attempt to de-reference null object error with following code

public class StringChecking{
    
    public String name1{get; set;}
    public List<contact> list2;
    Contact contact1;
    public Contact getContact(){
        if(contact1!=null){
        contact1=[select id,Name,Country__c from Contact where Name=:name1];
    }
        return contact1;
    }
    
    public pagereference ContactList(){
       return null;
    }
    public List<Contact> getList(){
        try{
            if(contact1!=null && contact1.Country__c=='India'){
                list2.add(contact1);                
            }
            
            else if(contact1!=null && contact1.Country__c=='US'){
                 list2.add(contact1);
            }
            
            else{
                 list2.add(contact1);
            }
        }
        catch(DmlException e)
        {
            System.debug('An unexpected error has occurred: ' + e.getMessage());
        }
        return list2;
    }
    
    public pagereference edit(){
        pagereference pg=new Pagereference('https://ap5.salesforce.com/'+contact1.Id);
        return pg;
    }
    
}


please help me to solve this
hello,
i want to check contact name which is inserted is string or not using apex
hello,
I'm having attempt to de-reference null object error with following code

public class StringChecking{
    
    public String name1{get; set;}
    public List<contact> list2;
    Contact contact1;
    public Contact getContact(){
        if(contact1!=null){
        contact1=[select id,Name,Country__c from Contact where Name=:name1];
    }
        return contact1;
    }
    
    public pagereference ContactList(){
       return null;
    }
    public List<Contact> getList(){
        try{
            if(contact1!=null && contact1.Country__c=='India'){
                list2.add(contact1);                
            }
            
            else if(contact1!=null && contact1.Country__c=='US'){
                 list2.add(contact1);
            }
            
            else{
                 list2.add(contact1);
            }
        }
        catch(DmlException e)
        {
            System.debug('An unexpected error has occurred: ' + e.getMessage());
        }
        return list2;
    }
    
    public pagereference edit(){
        pagereference pg=new Pagereference('https://ap5.salesforce.com/'+contact1.Id);
        return pg;
    }
    
}


please help me to solve this
hello,
i want to check contact name which is inserted is string or not using apex
Hi,

I'm getting null point exception error : attempt to de-reference object which is null at below line.

Utils.getQuoteIdsForSupportItems(newLst,oldLst);

/*test class
  QuoteLineItem qli1 = new QuoteLineItem();
  qli1.QuoteId = q.Id;
  qli1.PricebookEntryId =Pbentry.Id;
  qli1.Discount=91;         
  qli1.Quantity=8;
  qli1.Product2Id = p.Id;
  qli1.UnitPrice=98;
  qli1.Description =p.Description;  
//  insert qli1;

  QuoteLineItem qli2 = new QuoteLineItem();
  qli2.QuoteId = q.Id;
  qli2.PricebookEntryId =Pbentry.Id;
  qli2.Discount=92;         
  qli2.Quantity=1;
  qli2.Product2Id = p.Id;
  qli2.UnitPrice=94;
  qli2.Description =p.Description;  
//  insert qli2;
 
  QuoteLineItem qli3 = new QuoteLineItem();
  qli3.QuoteId = q.Id;
  qli3.PricebookEntryId =Pbentry.Id;
  qli3.Discount=92;         
  qli3.Quantity=1;
  qli3.Product2Id = p.Id;
  qli3.UnitPrice=94;
  qli3.Description =p.Description;  
//  insert qli3;

  List<QuoteLineItem> oldLst = new List<QuoteLineItem>();
  oldLst.add(qli1);
  oldLst.add(qli2);
  oldLst.add(qli3);
  insert oldLst;
 
  QuoteLineItem qli4 = new QuoteLineItem();
  qli4.QuoteId = q.Id;
  qli4.PricebookEntryId =Pbentry.Id;
  qli4.Discount=41;         
  qli4.Quantity=7;
  qli4.Product2Id = p.Id;
  qli4.UnitPrice=99;
  qli4.Description =p.Description;  
//  insert qli4;

  QuoteLineItem qli5 = new QuoteLineItem();
  qli5.QuoteId = q.Id;
  qli5.PricebookEntryId =Pbentry.Id;
  qli5.Discount=23;         
  qli5.Quantity=10;
  qli5.Product2Id = p.Id;
  qli5.UnitPrice=81;
  qli5.Description =p.Description;  
//  insert qli5;

  QuoteLineItem qli6 = new QuoteLineItem();
  qli6.QuoteId = q.Id;
  qli6.PricebookEntryId =Pbentry.Id;
  qli6.Discount=24;
  qli6.Quantity=11;
  qli6.Product2Id = p.Id;
  qli6.UnitPrice=82;
  qli6.Description =p.Description;  
//  insert qli6;

  List<QuoteLineItem> newLst = new List<QuoteLineItem>();
  newLst.add(qli4);
  newLst.add(qli5);
  newLst.add(qli6);
  insert newLst;

Utils.getQuoteIdsForSupportItems(newLst,oldLst);

/*method to test..
  public static Set<Id> getQuoteIdsForSupportItems(List<QuoteLineItem> newList, List<QuoteLineItem> oldList) {
    Set<Id> prodIds = new Set<Id>();
    if(trigger.isInsert || trigger.isUpdate) {
      for(QuoteLineItem qli : newList) {
        prodIds.add(qli.Product2Id);
      }
    } else {
      for(QuoteLineItem qli : oldList) {
        prodIds.add(qli.Product2Id);
      }
    }
    
    Map<Id, Product2> prodMap = new Map<Id, Product2>([select Requires_Support_Fees__c
                        from Product2
                        where id in:prodIds
                        and Requires_Support_Fees__c = true]);
    Set<Id> quoteIds = new Set<Id>();
    if(trigger.isInsert || trigger.isUpdate) {
      for(QuoteLineItem qli : newList) {
        if(prodMap.containsKey(qli.Product2Id)) {
          quoteIds.add(qli.QuoteId);
        }
      }
    } else {
      for(QuoteLineItem qli : oldList) {
        if(prodMap.containsKey(qli.Product2Id)) {
          quoteIds.add(qli.QuoteId);
        }
      }
    }
    system.debug('quoteIds:'+quoteIds);
    return quoteIds;
  }


Please advice..

Arun