• dragonmagicl
  • NEWBIE
  • 55 Points
  • Member since 2008

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 18
    Replies

Hello - I am getting the following error when attempting to Save a record using a VisualForce Page (VisualForcExtension) and a Controller Extension (positionExtension):

 

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

                                                                                                                                                   

Class.positionExtension.Save: line 54, column 16 External entry point (line 54 column 16 is underlined in the following code fragment "return theController.save()")

 

The code from the positionExtension Apex Class:

public class positionExtension { public string positionTypeID {get; set;} public positionExtension(ApexPages.StandardController positionController) { this.position = (Position__c)positionController.getRecord(); } public List<selectOption> PositionTypeOptions {get { List<selectOption> positionTypes = new List<selectOption>(); for (Position_Type__c ptr : [select name from Position_Type__c pt where pt.Department__c = :position.Department__c order by Name ]) positionTypes.add(new selectOption(ptr.id, ptr.name)); if (position.Department__c != null) { positionTypes.add(new selectOption('other', 'Other')); } else { positionTypes.add(new selectOption('', 'Please select a department', true)); } return positionTypes; } private set;} public Position_Type__c newPositionType{ get{ if (newPositionType == null) { newPositionType = new Position_Type__c();} return newPositionType; } private set; } public void resetPositionType() { positionTypeID = null; } public PageReference Save() { if (positionTypeID == 'other') { try{ newPositionType.Department__c = position.Department__c; insert newPositionType; position.Position_Type__c = newPositionType.ID; } catch (DmlException e) { ApexPages.addMessages(e); } } else { position.Position_Type__c = positionTypeID; } return theController.save(); } private final Position__c position; private final ApexPages.StandardController theController; }

The markup from the Visualforce Page that calls the Apex Class:

 

<apex:page standardController="Position__c" extensions="positionExtension" > <apex:form > <apex:sectionHeader title="Add New Position"/> <apex:pageBlock mode="edit" id="thePageBlock"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlocksection title="Information"> <apex:inputField value="{!Position__c.Location__c}"/> <apex:inputField value="{!Position__c.Hiring_Manager__c}"/> <apex:inputField value="{!Position__c.Status__c}"/> <apex:inputField value="{!Position__c.Notification__c}"/> <apex:inputField value="{!Position__c.Start_Date__c}"/> </apex:pageBlocksection> <apex:actionRegion > <apex:pageblocksection columns="1" title="Department"> <apex:inputField value="{!Position__c.Department__c}"> <apex:actionSupport event="onchange" rerender="dependentPositionType" action="{!resetPositionType}" status="departmentStatus"/> <apex:actionStatus id="departmentStatus" startText="Fetching position types..."/> </apex:inputField> </apex:pageblockSection> </apex:actionRegion> <apex:pageblockSection id="dependentPositionType" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Position Type" for="pt"/> <apex:panelGrid columns="2"> <apex:actionRegion > <apex:outputText value="{!Position__c.Position_Type__c}" rendered="false"/> <apex:selectList id="pt" value="{!positionTypeID}" size="1" disabled="{!ISNULL(Position__c.Department__c)}"> <apex:selectOptions value="{!PositionTypeOptions}"/> <apex:actionSupport event="onchange" rerender="dependentPositionType" status="typeStatus"/> </apex:selectList> </apex:actionRegion> <apex:actionStatus id="typeStatus" startText="updating form..."> <apex:facet name="stop"> <apex:inputField value="{!newPositionType.Name}" rendered="{!positionTypeId == 'other'}" required="true"/> </apex:facet> </apex:actionStatus> </apex:panelGrid> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title="Position Details"> <apex:inputField value="{!Position__c.Job_Description__c}"/> <apex:inputField value="{!Position__c.Responsibilities__c}"/> <apex:inputField value="{!Position__c.Programming_Languages__c}"/> <apex:inputField value="{!Position__c.Educational_Requirements__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

I would appreciate any ideas for resolving this problem.  Please go easy on newbie learning VF and Apex.

 

Thanks,

SCR

  • July 23, 2009
  • Like
  • 0

Hi,

 

Just wondering is there any performance hit if I use Html tags instead of visualforce tags, when it can be done either way.

 

Thanks.

Hi.

 

I've created a small Java Aplication which can do an login in salesforce and which proviedes a list with all accounts. My question is how i can start this from salesforce? For example i have a button on the start page and if i touch it, my Java-Program should start.

 

Thank you

  • October 06, 2009
  • Like
  • 0

If you look at the Apex Language reference pdf, on page 278, you will see an example of how to invoke an action from within another action.  This sounds great in theory but doesn't work in practice.  All we get is a system error like this:

 

 

Salesforce System Error: 1598249974-2475 (-814351657) (-814351657) An unexpected error has occurred. Your solution provider has been notified. (ApexPages)  

 To save you time, here is the code:

 

Controller:

 

public with sharing class Page2Controller { private ApexPages.Action saveAction = new ApexPages.Action('{!onSave}'); public Page2Controller() { } public PageReference doSomething() { saveAction.invoke(); return null; } public void onSave() { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'why dont I work?')); } }

 

Page:

 

 

<apex:page controller="Page2Controller" sidebar="false" showHeader="false"> <apex:messages /> <apex:form > <apex:commandButton action="{!doSomething}" value="doSomething" /> </apex:form> </apex:page>

 

Any Ideas?  This seems so simple, I am not sure what is going on.

 

Thanks in advance for any help you can provide!

 

 

 

 

 

I have a custom button on a contact list view that's connected to a VF page. All I want to do on the VF page is run some DML to update the selected contacts, then go back to the list view, as long as at least one contact was selected. If no contacts were selected, I want to display an err message. When I run the page, whether or not I've selected any contacts, I get this err message: "Unknown method 'ContactBarcodeCreated.updateBarcodeCreated()'" Thanks for any help you can provide.

VF page tag:


Apex:
public class ContactBarcodeCreated {
public sObject[] objs { get; private set; }
public boolean hasSelection { get; private set; }


public pageReference updateBarcodeCreated(ApexPages.StandardSetController controller ){
objs = controller.getSelected();
hasSelection = !objs.isEmpty();
if (hasSelection) {

Contact[] cons = new contact[0];
for (sObject c : objs){
cons.add(new Contact(
id=c.id,
Barcode_Card_Created__c = true,
Barcode_Card_Created_Date__c = system.today()
));
}
update cons;

// go back
string url = ApexPages.currentPage().getParameters().get('retURL');
pageReference prevPage = new PageReference((url != null) ? url : '/006');
prevPage.setRedirect(true);
return prevPage;
}
else {
return null;
}

}


}
  • July 23, 2009
  • Like
  • 0

Hello - I am getting the following error when attempting to Save a record using a VisualForce Page (VisualForcExtension) and a Controller Extension (positionExtension):

 

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

                                                                                                                                                   

Class.positionExtension.Save: line 54, column 16 External entry point (line 54 column 16 is underlined in the following code fragment "return theController.save()")

 

The code from the positionExtension Apex Class:

public class positionExtension { public string positionTypeID {get; set;} public positionExtension(ApexPages.StandardController positionController) { this.position = (Position__c)positionController.getRecord(); } public List<selectOption> PositionTypeOptions {get { List<selectOption> positionTypes = new List<selectOption>(); for (Position_Type__c ptr : [select name from Position_Type__c pt where pt.Department__c = :position.Department__c order by Name ]) positionTypes.add(new selectOption(ptr.id, ptr.name)); if (position.Department__c != null) { positionTypes.add(new selectOption('other', 'Other')); } else { positionTypes.add(new selectOption('', 'Please select a department', true)); } return positionTypes; } private set;} public Position_Type__c newPositionType{ get{ if (newPositionType == null) { newPositionType = new Position_Type__c();} return newPositionType; } private set; } public void resetPositionType() { positionTypeID = null; } public PageReference Save() { if (positionTypeID == 'other') { try{ newPositionType.Department__c = position.Department__c; insert newPositionType; position.Position_Type__c = newPositionType.ID; } catch (DmlException e) { ApexPages.addMessages(e); } } else { position.Position_Type__c = positionTypeID; } return theController.save(); } private final Position__c position; private final ApexPages.StandardController theController; }

The markup from the Visualforce Page that calls the Apex Class:

 

<apex:page standardController="Position__c" extensions="positionExtension" > <apex:form > <apex:sectionHeader title="Add New Position"/> <apex:pageBlock mode="edit" id="thePageBlock"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlocksection title="Information"> <apex:inputField value="{!Position__c.Location__c}"/> <apex:inputField value="{!Position__c.Hiring_Manager__c}"/> <apex:inputField value="{!Position__c.Status__c}"/> <apex:inputField value="{!Position__c.Notification__c}"/> <apex:inputField value="{!Position__c.Start_Date__c}"/> </apex:pageBlocksection> <apex:actionRegion > <apex:pageblocksection columns="1" title="Department"> <apex:inputField value="{!Position__c.Department__c}"> <apex:actionSupport event="onchange" rerender="dependentPositionType" action="{!resetPositionType}" status="departmentStatus"/> <apex:actionStatus id="departmentStatus" startText="Fetching position types..."/> </apex:inputField> </apex:pageblockSection> </apex:actionRegion> <apex:pageblockSection id="dependentPositionType" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Position Type" for="pt"/> <apex:panelGrid columns="2"> <apex:actionRegion > <apex:outputText value="{!Position__c.Position_Type__c}" rendered="false"/> <apex:selectList id="pt" value="{!positionTypeID}" size="1" disabled="{!ISNULL(Position__c.Department__c)}"> <apex:selectOptions value="{!PositionTypeOptions}"/> <apex:actionSupport event="onchange" rerender="dependentPositionType" status="typeStatus"/> </apex:selectList> </apex:actionRegion> <apex:actionStatus id="typeStatus" startText="updating form..."> <apex:facet name="stop"> <apex:inputField value="{!newPositionType.Name}" rendered="{!positionTypeId == 'other'}" required="true"/> </apex:facet> </apex:actionStatus> </apex:panelGrid> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title="Position Details"> <apex:inputField value="{!Position__c.Job_Description__c}"/> <apex:inputField value="{!Position__c.Responsibilities__c}"/> <apex:inputField value="{!Position__c.Programming_Languages__c}"/> <apex:inputField value="{!Position__c.Educational_Requirements__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

I would appreciate any ideas for resolving this problem.  Please go easy on newbie learning VF and Apex.

 

Thanks,

SCR

  • July 23, 2009
  • Like
  • 0

Hi,

 

Just wondering is there any performance hit if I use Html tags instead of visualforce tags, when it can be done either way.

 

Thanks.

With some suggestions from SimonF on this board i was able to succesfully send a login() request and get a valid response.  That was on the production server.  Now I'm trying to do the same request to my sandbox and am getting a 'invalid login'. 

The only changes i made were the endpoint and the username (added .sandboxname). 

response:

      <soapenv:Fault>
         <faultcode>sf:INVALID_LOGIN</faultcode>
         <faultstring>INVALID_LOGIN: Invalid username, password, security token; or user locked out.</faultstring>
         <detail>
            <sf:LoginFault xsi:type="sf:LoginFault">
               <sf:exceptionCode>INVALID_LOGIN</sf:exceptionCode>
               <sf:exceptionMessage>Invalid username, password, security token; or user locked out.</sf:exceptionMessage>
            </sf:LoginFault>
         </detail>
      </soapenv:Fault>

  • June 12, 2009
  • Like
  • 0

I'm new to VF, coming from scontrols.  I have some custom objects related to Opportunities which can each have tasks related to them.  The salesguys want to see one list of tasks, no matter which of the custom objects or indeed the Opportunity itself they are related to.  I've been trying to write a list controller for tasks with no luck at all.  I know there is no standard controller for listing tasks but is there any reason why a custom controller would not work?  Does anyone have some template code I could use as I'm new to Apex as well and I can't get my code accepted by the IDE?

Apex Code is as follows (still needs the query to be filtered but am trying to get proof of concept first):

 

public class OppTasks { public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator([Select WhatId, Subject, Status, OwnerId, Id, Description, ActivityDate From Task])); } return setCon; } set; } public List<Task> getActivities() { return (List<Task>) setCon.getRecords(); } }

 Visualforce page:

 

<apex:page controller="OppTasks"> <apex:form > <apex:pageblock id="thePage"> <apex:pageblocktable value="{!activity}" var="t" > <apex:column value="{!t.Subject}"/> <apex:column value="{!t.WhatId}"/> <apex:column value="{!t.Status}"/> <apex:column value="{!t.ActivityDate}"/> </apex:pageblocktable> </apex:pageblock> </apex:form> </apex:page>

 I have tried a variety of values  including {!tasks}, I get the error "Unknown property OppTasks.activity".

 

Can anyone help a newbie?  Many thanks - Erica

 

 

 

 

  • February 25, 2009
  • Like
  • 0
I am trying to connect to gmail imap servers using emailtocase.

The setup goes OK but I am getting an error which looks like the
process is refused connection to the gmail server. I have had the
config files checked by salesforce.com tech support and they said they
were OK.

Has anyone tried this process, or a similar one before? Does it work?

Has anyone any ideas why I might not be able to connect.

Here is a clip from the error log I get when running the process.

2008-04-02 08:48:14,369 7162 [main] INFO
com.sforce.mail.EmailService  - Scheduling poll process against
imap.googlemail.com
2008-04-02 08:48:14,369 7162 [main] INFO
com.sforce.mail.EmailService  -    Port    : default
2008-04-02 08:48:14,369 7162 [main] INFO
com.sforce.mail.EmailService  -    UserID  : [email address]
2008-04-02 08:48:14,369 7162 [main] INFO
com.sforce.mail.EmailService  -    Password:
2008-04-02 08:48:14,369 7162 [main] INFO
com.sforce.mail.EmailService  -    Interval: 10 minute(s)
2008-04-02 08:48:14,369 7162 [main] INFO
com.sforce.mail.EmailService  -    InBox   : Inbox
2008-04-02 08:48:14,369 7162 [main] INFO
com.sforce.mail.EmailService  -    ReadBox : Sent Mail
2008-04-02 08:48:14,370 7163 [main] INFO
com.sforce.mail.EmailService  -    ErrorBox: Drafts
2008-04-02 08:48:14,370 7163 [main] INFO  com.sforce.SalesforceAgent
- Service imap.googlemail.com:0:[email address]:Inbox
successfully registered
2008-04-02 08:48:14,370 7163 [main] INFO  com.sforce.SalesforceAgent
- com.sforce.mail.EmailService  loaded as a timer service.
2008-04-02 08:49:29,268 82061 [Timer-0] ERROR
com.sforce.mail.GenericClient  - Unable to connect to mail service.
Service: imap.googlemail.com
User: [email address]

Message: Operation timed out;
  nested exception is:
        java.net.ConnectException: Operation timed out

End of LOG

The email address has been changed to protect privacy
  • April 30, 2008
  • Like
  • 0
How do I move from sandbox to live?  The Help documentation is lacking in detail
  • April 21, 2008
  • Like
  • 0
Hi All,
 
Currently we are working on uploading Opportunities data to SalesForce.com.
 
We completed our development and it was working very much fine before. But now when we tried uploading the same we are getting strange error (negative response) from salesforce as "Client Missing entity type information. sObject requires a separate 'type' field be sent.".
 
Really i did not understand whats the problem is? Could any one help me out in solving this problem?
 
Thanks in advance.
 
Regards,
Prasad Babu.