• Jason McCarthy 2
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 4
    Replies
I am trying to write an enhancement that adds existing contacts to opportunities (record type: Job Opportunities. ) 

I keep getting this error. 
Visualforce ErrorHelp for this Page
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!addContact}' in component <apex:commandButton> in page addcontacttojobopportunity: Class.AddContacttoJobOpptController.addContact: line 30, column 1
Class.AddContacttoJobOpptController.addContact: line 30, column 1

VF Code: 
<apex:page controller="AddContacttoJobOpptController">
    <apex:form >
        <apex:pageBlock title="Search Existing Contact to Add">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Add Contact" action="{!addContact}"/>
                <apex:commandButton value="Go Back" action="{!goBack}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1">             
                <apex:inputField label="Search Contact" value="{!Opp.JobOpportunity_Lookup__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller Code: 
// Created by: Jason McCarthy
// Created for: Job Opportunities Project P#100007 
// Purpose: To add Current contacts to the Job Opportunity to Track candidates. 
// Created: September 29th, 2015


public with sharing class AddContacttoJobOpptController { 
    public Opportunity opp {get;set;}

    public Contact con {get;set;}
    public String selectedConId = '';

    public String selectedOppId = '';
  
    String selectedOpportunityID = null;

    public AddContacttoJobOpptController(){

   
   
        opp = new Opportunity();
    
 
        selectedOppId = Apexpages.currentPage().getParameters().get('aid');
            
        
    }
    public Pagereference addContact(){ 
        Set<String> conIdSet = new Set<String>();
        selectedConId = Con.Candidate__c ; .
        selectedOppId = Opp.JobOpportunity_Lookup__c ; 
       
        if(selectedConId != null && selectedConId != ''){
            for(Contact con : [select id from Contact where Candidate__c = :selectedOppId]){
                conIdSet.add(con.id);
            }
            if(conIdSet.contains(selectedConId)){
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact is already added to the Job Opportunity. Please select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            else{
                Contact con = new Contact(id=selectedConId);
                update con;
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact has been added to the Job Opportunity. Now you can select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            
        }
        else{
            apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Please select contact then click on Add Contact button.');
            apexpages.addmessage(msg);
            return null;
        }
        
    }
    public Pagereference goBack(){
        return new Pagereference('/'+selectedOppId);
    }

}

 
I am getting a System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!addContact}' in component <apex:commandButton> in page addcontacttojobopportunity: Class.AddContacttoJobOpptController.addContact: line 30, column 1


I am trying to figure out what this means and how to fix it. I want to be able to add multiple existing contacts to a job opportunity (Record type on Opportunities object)  

Heres the code: 
public with sharing class AddContacttoJobOpptController { 
    public Opportunity opp {get;set;}
    public Contact con {get;set;}
    public String selectedConId = '';
   
    public String selectedOppId = '';
  
    String selectedOpportunityID = null;
    
    public AddContacttoJobOpptController(){
 
   
   
        opp = new Opportunity();
    
    
        selectedOppId = Apexpages.currentPage().getParameters().get('aid');
            
        
    }
    public Pagereference addContact(){  
        Set<String> conIdSet = new Set<String>(); 
        selectedConId = Con.Candidate__c ; 
        selectedOppId = Opp.JobOpportunity_Lookup__c ; 
       
        if(selectedConId != null && selectedConId != ''){
            for(Contact con : [select id from Contact where Candidate__c = :selectedOppId]){
                conIdSet.add(con.id);
            }
            if(conIdSet.contains(selectedConId)){
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact is already added to the Job Opportunity. Please select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            else{
                Contact con = new Contact(id=selectedConId);
                update con;
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact has been added to the Job Opportunity. Now you can select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            
        }
        else{
            apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Please select contact then click on Add Contact button.');
            apexpages.addmessage(msg);
            return null;
        }
        
    }
    public Pagereference goBack(){
        return new Pagereference('/'+selectedOppId);
    }

}

 
Having trouble with selecting existing contacts to add to an opportunity in a seperate Related List labled "Candidates" . I can get the contacts and select them. It just doesnt add them to the opportunity. Im sure this is something simple that I am missing.

Here's the class

public with sharing class AddContacttoJobOpptController { 
    public Opportunity opp {get;set;}
    public Contact con {get;set;}
    public String selectedConId = '';
    public String selectedOppId = '';

    String selectedOpportunityID = null;

    public AddContacttoJobOpptController(){

   
   
        opp = new Opportunity();
           selectedOppId = Apexpages.currentPage().getParameters().get('aid');
            
        
    }
    public Pagereference addContact(){  
        Set<String> conIdSet = new Set<String>();
        selectedConId = Con.Candidate__c ; 
        selectedOppId = Opp.Id ; 
       
        if(selectedConId != null && selectedConId != ''){
            for(Contact con : [select id from Contact where Candidate__c = :selectedOppId]){
                conIdSet.add(con.id);
            }
            if(conIdSet.contains(selectedConId)){
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact is already added to the Job Opportunity. Please select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            else{
                Contact con = new Contact(id=selectedConId);
                update con;
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact has been added to the Job Opportunity. Now you can select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            
        }
        else{
            apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Please select contact then click on Add Contact button.');
            apexpages.addmessage(msg);
            return null;
        }
        
    }
    public Pagereference goBack(){
        return new Pagereference('/'+selectedOppId);
    }

}

and VisualForce Page: 
<apex:page controller="AddContacttoJobOpptController">
    <apex:form >
        <apex:pageBlock title="Search Existing Contact to Add">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Add Contact" action="{!addContact}"/>
                <apex:commandButton value="Go Back" action="{!goBack}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1">                
                <apex:inputField label="Search Contact" value="{!Opp.JobOpportunity_Lookup__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
I am trying to add  existing contacts to a related list on Opportunities  as "Job Candidates" through a VF page and kicked off by a custom button. I keep getting the compile Error: Invalid field initializer: con.Candidate_Opportunity__c at line 43 column 61.  I have created a field on the Contact object "Candidate_Opportunity__c" and named the variable. 

What am I missing? 

public with sharing class AddContacttoJobOpptController { 
    public Opportunity opp {get;set;}
    public Contact con {get;set;}
    public String selectedConId = '';
    public String selectedOppId = '';
    String selectedOpportunityID = con.Candidate_Opportunity__c;
    public AddContacttoJobOpptController(){
   
   
        opp = new Opportunity();
 
        selectedOppId = Apexpages.currentPage().getParameters().get('aid');
            
        
    }
    public Pagereference addContact(){
        Set<String> conIdSet = new Set<String>();
        selectedConId = opp.Candidate__c;
        selectedOppId = opportunity.Id;
        selectedOpportunityID = con.Candidate_Opportunity__c;
        if(selectedConId != null && selectedConId != ''){
            for(Contact con : [select id from Contact where OpportunityId = :selectedOppId]){
                conIdSet.add(con.id);
            }
            if(conIdSet.contains(selectedConId)){
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact is already added to strategic account plan. Please select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            else{
                Contact con = new Contact(id=selectedConId, con.Candidate_Opportunity__c = selectedOppId);
                update con;
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact has been added to strategic account plan. Now you can select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            
        }
        else{
            apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Please select contact then click on Add Contact button.');
            apexpages.addmessage(msg);
            return null;
        }
        
    }
    public Pagereference goBack(){
        return new Pagereference('/'+selectedOppId);
    }

}
I am trying to add  existing contacts to a related list on Opportunities  as "Job Candidates" through a VF page and kicked off by a custom button. I keep getting the compile Error  Error: Compile Error: Invalid field OpportunityId for SObject Contact at line 35 column 75 .  The functionailty is suppose to search contacts (which i should make for specific record type of "participant"  and "Participant Donor" just haven't gotten there yet. 

What am I missing? 

public with sharing class AddContacttoJobOpptController { 
    public Opportunity opp {get;set;}
      public String selectedConId = '';
    public String selectedOppId = '';
    public AddContacttoJobOpptController(){
        opp = new Opportunity();
        selectedOppId = Apexpages.currentPage().getParameters().get('aid');
            
        
    }
    public Pagereference addContact(){
        Set<String> conIdSet = new Set<String>();
        selectedConId = opp.Candidate__c;
        if(selectedConId != null && selectedConId != ''){
            for(Contact con : [select id from Contact where OpportunityId = :selectedOppId]){
                conIdSet.add(con.id);
            }
            if(conIdSet.contains(selectedConId)){
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact is already added to strategic account plan. Please select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            else{
                Contact con = new Contact(id=selectedConId, OpportunityId=selectedOppId);
                update con;
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact has been added to strategic account plan. Now you can select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            
        }
        else{
            apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Please select contact then click on Add Contact button.');
            apexpages.addmessage(msg);
            return null;
        }
        
    }
    public Pagereference goBack(){
        return new Pagereference('/'+selectedOppId);
    }

}
How can I limit a text formula field to 7 characters because I am doing an amount calculation in this, I had various data types and Text formula was the only one that it came out correctly in. Now I am having an issue where the field is producing 36 decimal places.
On the Salesforce Content Overview page, is there a way to get rid of the popular tags, recent activity and the Most active contributors page blocks. I wanted to know if I can avoid coding. 
I am trying to make a dollar value show from opportunties to a custom object. Conditions if a check boxc(Free Seat) returns true then null the dollar amount, if not then pull the value from  Opportunity__r.Effective_Billing__c. 

Opportunity__r.Effective_Billing__c is a Currency field. 
The field i am populating is Average_Billing_Rate__c is a text field.
Free_Seat__c is a Checkbox. 

Logic: populate the effective billing rate from the opportunity to the internship object. If the free seat checkbox is checked than average billing rate should read $0.00 

Also, I will need the $ and the decimals in the formula because this goes in to an accounting system. 

I am running in to IF problems when i add && 
I am running in to IF problems when i add ||
Extra problems with ,. &" $" & 
Extra problems with ,. &"  . """ &
Running in to problems all around basically. 
 
I have a Trigger & Handler that update records based on specific critieria being edited on the records. I want to use the enhanced list view to mass edit these records for my teams. The only issue is that the list view does not refresh after update. So the records are edited, the trigger fires and updates the records, but the users won't know the data is there until they manually refresh the list view, and i want to avoid a user re-entering data, or creating bad data, dupes etc. I want the list view to refresh on edit of any fields in the list view. What is the easiest avenue for making this happen? 

My first though is add the functionaility into the handler that would gather a list of the list views for the logged in user, and make a soql query for all fields on the views that would be If xxx__c is edited then refresh ListviewID. 

This guidance i need is: 
1. Can i add the functionailty that would tell the handler that ThisUser is viewing ThisListView with TheseFields. TheseFields onUpdate refresh ThisListView? 
2. Is there an easier way than blowing up my handler from 333 lines to god know how many lines. 
3. My assumption is there will be performance issues with the list view, should i put this functionaility to a VisualForce page?
4. With a VisualForce page, i will have to create all the functionailty for:
       - Listing the Views
       - Capturing the logged in user.
       - User Inputs specfic to the critieria that fires the previous trigger to update records.
       - Etc. Etc. Etc. 

I want to avoid making this a visualforce page for many reasons, and i feel that this can be achieved through a much simpler route. 



 
I am trying to write an enhancement that adds existing contacts to opportunities (record type: Job Opportunities. ) 

I keep getting this error. 
Visualforce ErrorHelp for this Page
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!addContact}' in component <apex:commandButton> in page addcontacttojobopportunity: Class.AddContacttoJobOpptController.addContact: line 30, column 1
Class.AddContacttoJobOpptController.addContact: line 30, column 1

VF Code: 
<apex:page controller="AddContacttoJobOpptController">
    <apex:form >
        <apex:pageBlock title="Search Existing Contact to Add">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Add Contact" action="{!addContact}"/>
                <apex:commandButton value="Go Back" action="{!goBack}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1">             
                <apex:inputField label="Search Contact" value="{!Opp.JobOpportunity_Lookup__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller Code: 
// Created by: Jason McCarthy
// Created for: Job Opportunities Project P#100007 
// Purpose: To add Current contacts to the Job Opportunity to Track candidates. 
// Created: September 29th, 2015


public with sharing class AddContacttoJobOpptController { 
    public Opportunity opp {get;set;}

    public Contact con {get;set;}
    public String selectedConId = '';

    public String selectedOppId = '';
  
    String selectedOpportunityID = null;

    public AddContacttoJobOpptController(){

   
   
        opp = new Opportunity();
    
 
        selectedOppId = Apexpages.currentPage().getParameters().get('aid');
            
        
    }
    public Pagereference addContact(){ 
        Set<String> conIdSet = new Set<String>();
        selectedConId = Con.Candidate__c ; .
        selectedOppId = Opp.JobOpportunity_Lookup__c ; 
       
        if(selectedConId != null && selectedConId != ''){
            for(Contact con : [select id from Contact where Candidate__c = :selectedOppId]){
                conIdSet.add(con.id);
            }
            if(conIdSet.contains(selectedConId)){
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact is already added to the Job Opportunity. Please select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            else{
                Contact con = new Contact(id=selectedConId);
                update con;
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact has been added to the Job Opportunity. Now you can select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            
        }
        else{
            apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Please select contact then click on Add Contact button.');
            apexpages.addmessage(msg);
            return null;
        }
        
    }
    public Pagereference goBack(){
        return new Pagereference('/'+selectedOppId);
    }

}

 
I am trying to add  existing contacts to a related list on Opportunities  as "Job Candidates" through a VF page and kicked off by a custom button. I keep getting the compile Error  Error: Compile Error: Invalid field OpportunityId for SObject Contact at line 35 column 75 .  The functionailty is suppose to search contacts (which i should make for specific record type of "participant"  and "Participant Donor" just haven't gotten there yet. 

What am I missing? 

public with sharing class AddContacttoJobOpptController { 
    public Opportunity opp {get;set;}
      public String selectedConId = '';
    public String selectedOppId = '';
    public AddContacttoJobOpptController(){
        opp = new Opportunity();
        selectedOppId = Apexpages.currentPage().getParameters().get('aid');
            
        
    }
    public Pagereference addContact(){
        Set<String> conIdSet = new Set<String>();
        selectedConId = opp.Candidate__c;
        if(selectedConId != null && selectedConId != ''){
            for(Contact con : [select id from Contact where OpportunityId = :selectedOppId]){
                conIdSet.add(con.id);
            }
            if(conIdSet.contains(selectedConId)){
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact is already added to strategic account plan. Please select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            else{
                Contact con = new Contact(id=selectedConId, OpportunityId=selectedOppId);
                update con;
                apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'The selected contact has been added to strategic account plan. Now you can select another contact to add.');
                apexpages.addmessage(msg);
                return null;
            }
            
        }
        else{
            apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Please select contact then click on Add Contact button.');
            apexpages.addmessage(msg);
            return null;
        }
        
    }
    public Pagereference goBack(){
        return new Pagereference('/'+selectedOppId);
    }

}
I am trying to make a dollar value show from opportunties to a custom object. Conditions if a check boxc(Free Seat) returns true then null the dollar amount, if not then pull the value from  Opportunity__r.Effective_Billing__c. 

Opportunity__r.Effective_Billing__c is a Currency field. 
The field i am populating is Average_Billing_Rate__c is a text field.
Free_Seat__c is a Checkbox. 

Logic: populate the effective billing rate from the opportunity to the internship object. If the free seat checkbox is checked than average billing rate should read $0.00 

Also, I will need the $ and the decimals in the formula because this goes in to an accounting system. 

I am running in to IF problems when i add && 
I am running in to IF problems when i add ||
Extra problems with ,. &" $" & 
Extra problems with ,. &"  . """ &
Running in to problems all around basically. 
 

I am able to change the contact owner as a admin but when I logs into customer portal as a portal admin, I am able to create a contact but unbale to change the owner of the contact to another portal user. It is taking the ownerid as account ownerid by default. When I click on te change button it's showing insufficient preveledge. But when I check the profile I see contact has read, write and edit access to contact object as a portal admin.

 

Any help or anybody faced such issue.