• user2017
  • 0 Points
  • Member since 2017

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 2
We have an 'Outcome' object with lookup to 'Volunteer hours' object and also to Contact Object. Created a Lookup field in the 'Outcome' object, that should auto populate based on a field value in Contact or Volunteer hours object and display on page layout in newly created records of 'Outcome' object. How is this done?



I have the following trigger:


I have a field on the dsfs__DocuSign_Status__c object called dsfs__Sender__c that is a text field.  I need it to be a lookup field from the User object though so I can use it for reporting.  I created another field called DocuSign_Sender__c that is a lookup to the User.  What I am trying to do with this trigger is query the User table and populate the lookup with User's id matching on the String in the dsfs__Sender__c field.  


I am getting this error and I'm not sure since I think my logic is pretty much correct:


Apex trigger populateContactfromUser caused an unexpected exception, contact your administrator: populateContactfromUser: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.populateContactfromUser: line 20, column 1



trigger populateDocuSignSenderfromUser on dsfs__DocuSign_Status__c (before insert , before update){
    Set<String> setConIds = new Set<String>();
    for(dsfs__DocuSign_Status__c obj : trigger.new){
        if(obj.dsfs__Sender__c != null)
     Map <String, User> mapCon = new Map <String, User>([Select Id from User where Name in: setConIds]);
     for(dsfs__DocuSign_Status__c obj : trigger.new){
        if(obj.dsfs__Sender__c != null){
            User c = mapCon.get(obj.dsfs__Sender__c);
            obj.DocuSign_Sender__c= c.Id;