• Jay Eckles
  • NEWBIE
  • 65 Points
  • Member since 2012

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

Hello to all,

 

I am working on a VisualForce page that would serve as a visitor log at a front desk or something such as that.

This is a learning experience of sorts, so the solution to my problem may very well be simple and I just have not caught it.

The error I recieve upon opening up my VisualForce page says "Attempt to de-reference a null object". Any other errors I have encountered thus far were fixable because the error page had a little more detail than this.

 

Here is my VF page:

<apex:page controller="VisitorLogController" sidebar="false">
    <apex:sectionHeader title="Visitor Log"/>
    
    <div style="text-align:center;">
    <apex:form id="visitorLogForm">
        <div style="float:left;width:25%;">
            Visitor Name: <apex:inputText value="{!visitorName}"/>
        </div>
        <div style="float:left;width:25%;">
            Company Name: <apex:inputText value="{!company}"/>
        </div>
        <div style="float:left;width:25%;">
            Title in Company: <apex:inputText value="{!title}"/>
        </div>
        <div style="float:right;width:25%;">
            <apex:commandButton action="{!checkIn}" value="Check In"/>            
        </div>
        
        <apex:pageBlock>
            <apex:pageBlockTable value="{!logEntriesCheckedIn}" var="log" id="logEntryTable" rendered="{!recordsObtained}">
                <apex:column value="{!log.Visitor_Name__c}"/>
                <apex:column value="{!log.Company__c}"/>
                <apex:column value="{!log.Title__c}"/>
                <apex:column headerValue="Check Out">
                    <apex:commandButton value="Check Out"/>
                    <apex:actionSupport event="onclick" action="{!checkOut}" rerender="true">
                        <apex:param name="logID" value="{!log.Name}"/>
                    </apex:actionSupport>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
    </div>
</apex:page>

 

This is my controller:

public class VisitorLogController {
    
    public String visitorName {get; set;}
    public String company {get; set;}
    public String title {get; set;}
    
    public Boolean recordsObtained {get; set;}
    
    public List<Visitor_Log_Entry__c> logEntries {get; set;}
    public List<Visitor_Log_Entry__c> logEntriesCheckedIn {get; set;}
    
    public VisitorLogController() {
        recordsObtained = false;
        logEntries = [Select Name, Visitor_Name__c, Title__c, Company__c, Contact__c, Checked_In__c, Time_In__c, Time_Out__c from Visitor_Log_Entry__c limit 1000];
        for (Visitor_Log_Entry__c l : logEntries)
        {
            if (l.Checked_In__c == true)
                logEntriesCheckedIn.add(l);
        }
        recordsObtained = true;
    }
    
    public PageReference checkIn()
    {
        Account account = new Account(Name=company);
        upsert account;
        
        Contact contact = new Contact(FirstName=visitorName.split(' ', 2)[0], LastName=visitorName.split(' ', 2)[0], Job_Position__c = title, Account = account);
        upsert contact;
        
        Visitor_Log_Entry__c newEntry = new Visitor_Log_Entry__c(Checked_In__c = true, Company__c = company, Contact__c = contact.id, Time_In__c = System.now(), Title__c = title, Visitor_Name__c = visitorName);
        insert newEntry;
        
        return null;
    }
    
    public PageReference checkOut()
    {
        String entryID = ApexPages.currentPage().getParameters().get('logID');
        Visitor_Log_Entry__c focusEntry = [Select Name, Checked_In__c, Time_Out__c from Visitor_Log_Entry__c where name = :entryID limit 1];
        
        focusEntry.Checked_In__c = false;
        
        Datetime nowLocal = System.now();
        
        focusEntry.Time_Out__c = nowLocal;
        
        update focusEntry;
        return null;
    }
}

 

A great many thanks to anyone that is willing to help lead me in the right direction. I would also appreciate any other pointers that can be given as well, I am not all that sure I have taken the best approach to some of the working of this page.

I have customized Cases.  We have two Case record types: Client Meeting and Prospect Meeting.  The standard Type field has six values: three are available for Client Meeting records and the other three are available for Prospect Meeting records.

 

I have overridden the New Case button to call a VF page that redirects the user (after the record type is created) to an Edit page for Client Meetings (Slide_List) or an Edit page for Prospect Meeitngs (Prospect_Slide_List).  Both of those VF pages include the Type field like this:

 

                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Type" /> <apex:inputField value="{!case.Type}" required="true" />
                </apex:pageBlockSectionItem>

 Unfortunately, on both the Client Meetings page and the Prospect Meetings page, I am seeing only the picklist values for Type that are defined for the Client Meetings record type.  

 

No values are set as default if that matters at all.

Relevant portions of Case.object:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
...
    <fields>
        <fullName>Type</fullName>
        <picklist>
            <picklistValues>
                <fullName>Account Review - At SAM</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Account Review - At Client</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Account Review - Conference Call</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Prospect Meeting - At SAM</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Prospect Meeting - At Client</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Prospect Meeting - Conference Call</fullName>
                <default>false</default>
            </picklistValues>
            <sorted>false</sorted>
        </picklist>
        <type>Picklist</type>
    </fields>
...
    <recordTypes>
        <fullName>Client_Meeting</fullName>
        <active>true</active>
        <businessProcess>Client Meeting Request</businessProcess>
        <label>Client Meeting</label>
        <picklistValues>
...
            <picklist>Type</picklist>
            <values>
                <fullName>Account Review - At Client</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Account Review - At SAM</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Account Review - Conference Call</fullName>
                <default>false</default>
            </values>
        </picklistValues>
    </recordTypes>
    <recordTypes>
        <fullName>Prospect_Meeting</fullName>
        <active>true</active>
        <businessProcess>Prospect Meeting Request</businessProcess>
        <label>Prospect Meeting</label>
        <picklistValues>
...
            <picklist>Type</picklist>
            <values>
                <fullName>Prospect Meeting - At Client</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Prospect Meeting - At SAM</fullName>
                <default>false</default>
            </values>
            <values>
                <fullName>Prospect Meeting - Conference Call</fullName>
                <default>false</default>
            </values>
        </picklistValues>
    </recordTypes>

 

Enterprise Edition, Winter 13.  I have a simple VF page:

 

<apex:page standardController="Account">
Hello, world.
</apex:page>

 I have tried to embed this VF page into my one and only Account page layout.  When I go to the page layout (that is go to view a particular Account record in SFDC), there is just a big blank white space where the VF page should be rendering.

 

If I try to access the VF page directly (https://[instance].salesforce.com/apex/test_page), it renders no problem, giving me my "Hello, world." greeting.  

 

I've poked around in security settings, I've tried embedding it in other object page layouts (i.e., Contacts where it doesn't work and Cases where it does work), I've tried wrapping my "Hello, world." in an apex:outputPanel.  I've tried creating a generic extension class that doesn't do anything but lets me specify the extensions attribute to the apex:page component.  I've checked the security on the page and granted access to all profiles.  I've confirmed this behavior is the same in sandbox and production.  I'm not hitting any limits.  I've checked record types.

 

At this point I'm at a loss.  Help!

#!/usr/bin/perl
use WWW::Salesforce::Simple ;

my $sforce = WWW::Salesforce::Simple->new( username => 'user@domain.com',
                                           password => 'pas$w@rd!' );
print "Connection result: $sforce\n" ;

 I'm unable to get the basic code above to work.  When I run it, either on Linux or on Windows, I get the following message:

Incorrect parameter at /path/to/perl5/lib/perl5/SOAP/Lite.pm line 1993

I'm using EPIC to debug.  The failure is occuring at line 482 of Salesforce.pm:

 

 

    $self->{'sf_sid'}       = $r->valueof('//loginResponse/result/sessionId');

 My debugger shows that there is a value for //loginResponse/result/sessionId.  The valueof function is calling the match method which is calling the _traverse method.  _traverse is recursive, but line 1993 of Lite.pm prevents the recursion tree from gong more than 10 levels deep, which is where my code dies out.

 

I can't, however, quite follow the logic of the _traverse function. Is there a bug there?

 

I am setting up a series of Data Synchronization Tasks in Informatica Cloud that copy data from Salesforce objects into SQL Server tables.  The most time-consuming part of this exercise is creating the tables in SQL Server.  Is there any way to ideally automatically build T-SQL DDL or second best to get the names and types of all fields for each object in Salesforce?
 
I have tried using the XML files for objects that is accessible via the Force.com IDE, but those XML files seem only to contain the custom fields and they are in a terrible format for this purpose anyway.  The data is also available via salesforce.schema in the Force.com IDE, but only in an "explorable" format, not in any structured downloadable format.
 
Is there an API that Force.com IDE is using that I can leverage to get the metadata I'm looking for?  Am I coming at this from the wrong angle entirely?

Hi

 

I have to increase the coverage for below class:

public with sharing class ContactPortalUserController
{
    List<User>luser  = new List<User>();
    List<contact>selectedCon = new List<contact>();
    ID profileID = [select id from profile where name = 'High Volume Customer Portal'].id;
    private ApexPages.StandardSetController standardController;
   // ApexPages.Message myMsg = new ApexPages.Message('info', summary);
    public ContactPortalUserController(ApexPages.StandardSetController standardController)
    {
        this.standardController = standardController;
          }

     public PageReference selectedContact(){
     List<Contact>selectedContact = (List<Contact>) standardController.getSelected();
    system.debug('****1***'+selectedContact );
     selectedCon = [select id , name , firstname, email ,EmailEncoding__c,LanguageLocaleKey__c,TimeZoneSidKey__c,LocaleSidKey__c, lastname from contact where id in:selectedContact];
     system.debug('***21***'+selectedCon );
     for(contact con:selectedCon)
     {
      User us = new User();
      us.alias  =   con.Firstname.substring(0,3) +'cus';
      us.email  =  con.email;
      us.emailencodingkey= con.EmailEncoding__c;
      us.lastname = con.lastname;
      us.languagelocalekey = con.LanguageLocaleKey__c;
      us.localesidkey =con.LocaleSidKey__c;
      us.profileid = profileID;
      us.contactId = con.id;
       us.timezonesidkey = con.TimeZoneSidKey__c;
       us.username =  con.email +'cus';
       luser.add(us);
     
     }
    
    try{
     
     insert luser;
     ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.Info, 'Users have been inserted successfully.');
    ApexPages.addmessage(myMsg);
     
     // myMsg = ;
                  //ApexPages.addMessage(myMsg);   
     
     }
     catch(exception e)
     {
       e.getmessage();
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error Occured while inserting users,' + e.getmessage());
                  ApexPages.addMessage(myMsg);   
     }
   
     return null;
     }

    
}

 

Highlighted lines are not getting covered.

 

Test class:

 

public class  ContactPortalUserControllerTest{

    public static testMethod void testContactPortalUserController() {
      Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
      User u = new User(Alias = 'standt', Email='standarduser@testorg.com',
      EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
      LocaleSidKey='en_US', ProfileId = p.Id,
      TimeZoneSidKey='America/Los_Angeles', UserName='standarduser1112@testorg.com');


      System.runAs(u) {
    ID profileID = [select id from profile where name = 'High Volume Customer Portal'].id;

    List<contact> lcontact = new List<contact>();
    Contact con = new contact();
    con.lastname = 'test';
    con.email = 'Test@accenture.com';
    con.LanguageLocaleKey__c =  'en_US';
    con.LocaleSidKey__c = 'en_US';
    con.EmailEncoding__c = 'UTF-8';
    con.TimeZoneSidKey__c = 'America/Los_Angeles';
    insert con;
     Contact con1 = new contact();
    con1.lastname = 'test1';
    con1.email = 'Test@accenture.com';
    con1.LanguageLocaleKey__c =  'en_US';
    con1.LocaleSidKey__c = 'en_US';
    con1.EmailEncoding__c = 'UTF-8';
    con1.TimeZoneSidKey__c = 'America/Los_Angeles';
    insert con1;

    lcontact.add(con);
    lcontact.add(con1);

       PageReference pageRef = Page.ContactPortalUser;
        Test.setCurrentPage(pageRef);
          system.debug('*****1****' +  lcontact);     
     ApexPages.StandardSetController sc = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Id,Name FROM contact where id =:lcontact]));
ContactPortalUserController controller = new  ContactPortalUserController(sc);
  controller.selectedContact();
System.assert
      (ApexPages.getMessages().size() == 1);
      }
                    }
}

Hello to all,

 

I am working on a VisualForce page that would serve as a visitor log at a front desk or something such as that.

This is a learning experience of sorts, so the solution to my problem may very well be simple and I just have not caught it.

The error I recieve upon opening up my VisualForce page says "Attempt to de-reference a null object". Any other errors I have encountered thus far were fixable because the error page had a little more detail than this.

 

Here is my VF page:

<apex:page controller="VisitorLogController" sidebar="false">
    <apex:sectionHeader title="Visitor Log"/>
    
    <div style="text-align:center;">
    <apex:form id="visitorLogForm">
        <div style="float:left;width:25%;">
            Visitor Name: <apex:inputText value="{!visitorName}"/>
        </div>
        <div style="float:left;width:25%;">
            Company Name: <apex:inputText value="{!company}"/>
        </div>
        <div style="float:left;width:25%;">
            Title in Company: <apex:inputText value="{!title}"/>
        </div>
        <div style="float:right;width:25%;">
            <apex:commandButton action="{!checkIn}" value="Check In"/>            
        </div>
        
        <apex:pageBlock>
            <apex:pageBlockTable value="{!logEntriesCheckedIn}" var="log" id="logEntryTable" rendered="{!recordsObtained}">
                <apex:column value="{!log.Visitor_Name__c}"/>
                <apex:column value="{!log.Company__c}"/>
                <apex:column value="{!log.Title__c}"/>
                <apex:column headerValue="Check Out">
                    <apex:commandButton value="Check Out"/>
                    <apex:actionSupport event="onclick" action="{!checkOut}" rerender="true">
                        <apex:param name="logID" value="{!log.Name}"/>
                    </apex:actionSupport>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
    </div>
</apex:page>

 

This is my controller:

public class VisitorLogController {
    
    public String visitorName {get; set;}
    public String company {get; set;}
    public String title {get; set;}
    
    public Boolean recordsObtained {get; set;}
    
    public List<Visitor_Log_Entry__c> logEntries {get; set;}
    public List<Visitor_Log_Entry__c> logEntriesCheckedIn {get; set;}
    
    public VisitorLogController() {
        recordsObtained = false;
        logEntries = [Select Name, Visitor_Name__c, Title__c, Company__c, Contact__c, Checked_In__c, Time_In__c, Time_Out__c from Visitor_Log_Entry__c limit 1000];
        for (Visitor_Log_Entry__c l : logEntries)
        {
            if (l.Checked_In__c == true)
                logEntriesCheckedIn.add(l);
        }
        recordsObtained = true;
    }
    
    public PageReference checkIn()
    {
        Account account = new Account(Name=company);
        upsert account;
        
        Contact contact = new Contact(FirstName=visitorName.split(' ', 2)[0], LastName=visitorName.split(' ', 2)[0], Job_Position__c = title, Account = account);
        upsert contact;
        
        Visitor_Log_Entry__c newEntry = new Visitor_Log_Entry__c(Checked_In__c = true, Company__c = company, Contact__c = contact.id, Time_In__c = System.now(), Title__c = title, Visitor_Name__c = visitorName);
        insert newEntry;
        
        return null;
    }
    
    public PageReference checkOut()
    {
        String entryID = ApexPages.currentPage().getParameters().get('logID');
        Visitor_Log_Entry__c focusEntry = [Select Name, Checked_In__c, Time_Out__c from Visitor_Log_Entry__c where name = :entryID limit 1];
        
        focusEntry.Checked_In__c = false;
        
        Datetime nowLocal = System.now();
        
        focusEntry.Time_Out__c = nowLocal;
        
        update focusEntry;
        return null;
    }
}

 

A great many thanks to anyone that is willing to help lead me in the right direction. I would also appreciate any other pointers that can be given as well, I am not all that sure I have taken the best approach to some of the working of this page.

Hi All,

I don't know anything about php. But I have a set of php files and I have to run them with in Salesforce. Is that do-able? Can I just reference a php file in a visualforce page like how I reference a HTML in IFrame? Any idea is appreciated.

 

Thanks,

Sorna

  • January 22, 2013
  • Like
  • 0

Hello - I'm trying to dynamically center apex:OutputPanel text that I'm laying on top of a background image for a Visualforce2PDF Email Template. The majority of the Visualforce gets rendered as a PDF attachment. I'm able to get the image to stretch to its full size, but I'm (so far) unable to get the text centered.

 

I would appreciate any help in figuring this out.

 

Thanks,

SRyan

 

My VF Email template code:

 

<messaging:emailTemplate subject="Your Completed ACME Fire Proteciton Products Training Certificate:{!relatedTo.Course__c}" recipientType="Contact" relatedToType="Enrollment__c">
  <messaging:plainTextEmailBody >
        Dear {!recipient.name},
           
        Congratulations for successfully completing the ACME Fire Protection {!relatedTo.Course__c} course. Please see your Certificate of Completion attached to this message.

        Regards,
        John Doe
        ACME Fire Protection Products
        Director, Technical Services and Training
  </messaging:plainTextEmailBody>
  <messaging:attachment renderAs="PDF" filename="{!relatedTo.Name}">
  <html>
    <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/11.1/connection.js"></script>
    <script language="javascript">
        function init() {
                sforce.connection.sessionId = '{!$Api.Session_ID}';
                }
     </script>
  <style>
    @page {
    /* Landscape orientation */
    size:landscape;
    margin:0.25in;
    }
    body {
    background-size:976px 689px;
    }

    #BackgroundImage {
        width: 976px;
        height: 689px;
        border-style: none;
        background-image: url('{!URLFOR($Resource.TycoFPTrainingCertbackgroundimage)}');
        }
    
    #Text {
        text-align: center;
        }
        
    .stretch {
        width:100%;
        height:100%;
        }
    .largeBoldFont { font-weight:bold; font-size:24px; }
    .normalFont { font-weight:normal; font-size:12px; }
    .mediumBoldFont { font-weight:bold; font-size:18px; }
    .normalBoldFont { font-weight:bold; font-size:12px; }

  </style>    

  <body onload="init();">
  
  <div id="BackgroundImage">
    <div id="Text">
      <apex:outputPanel >
        <apex:panelGroup >
          <p><apex:outputText value="We Hereby confirm that" styleclass="normalFont"/></p>
          <p><apex:outputText value="{!relatedTo.Contact__r.FirstName}" styleclass="largeBoldFont"/> <apex:outputText value=" "/> <apex:outputText value="{!relatedTo.Contact__r.LastName}" styleclass="largeBoldFont"/></p>
          <p><apex:outputText value="has completed the training program" styleclass="normalFont"/></p>
          <p><apex:outputText value="{!relatedTo.Course__c}" styleclass="largeBoldFont"/> <apex:outputText value=" - " styleclass="largeFont"/> <apex:outputText value="{!relatedTo.Class_Number__c}" styleclass="largeBoldFont"/></p>
          <p><apex:outputText value="on this day " styleclass="normalFont"/><apex:outputText value="{!Day(relatedTo.Date_Certified__c)}" styleclass="normalBoldFont"/><apex:outputText value=" of this month " styleclass="normalFont"/><apex:outputText value="{!Month(relatedTo.Date_Certified__c)}" styleclass="normalBoldFont"/><apex:outputText value=" of this year " styleclass="normalFont"/><apex:outputText value="{!Year(relatedTo.Date_Certified__c)}" styleclass="normalBoldFont"/> <apex:outputText value=" and has been awarded a total of " styleclass="normalFont"/><apex:outputText value="{!relatedTo.Hours__c}" styleclass="normalBoldFont"/><apex:outputText value=" Contact Hour(s)." styleclass="normalFont"/></p>
          <p><apex:outputText value="This is an authorization to " styleclass="normalFont"/> <apex:outputText value="{!relatedTo.Certificate_Activity__c}" styleclass="normalBoldFont"/><apex:outputText value=" for " styleclass="normalFont"/><apex:outputText value="{!relatedTo.Course__c}" styleclass="normalBoldFont"/><br/>
          <apex:outputText value="as a Distributor of " styleclass="normalFont"/><apex:outputText value="{!relatedTo.Class__r.Course__r.Brand__c}" styleclass="normalBoldFont"/><apex:outputText value=" - Contract NO. " styleclass="normalFont"/> <apex:outputText value="{!relatedTo.TFPP_Contract__r.Name}" styleclass="normalBoldFont"/><br/>
          <apex:outputText value="This authorization expires three years from the date of training described above." styleclass="normalFont"/></p>
        </apex:panelGroup>
      </apex:outputPanel>
    </div>
  </div>
  </body>
  </html>
  </messaging:attachment>
</messaging:emailTemplate>

 

 

  • January 22, 2013
  • Like
  • 0

Hi,

 

Following is my code for sening email from a button on a custom object Safari__c. 

Safari__c is defined as the standard controller for the page. At the end of the code, if the mail sent is successful, I want to be able to update certain fields (Email_Flag__c and Email_Date__c) on the Safari__c object. I am defining a new Safari__c in the constructor, but I am not able to access these fields. 

How can this be done?? 

Any kind of help is greatly appreciated.

 

Thanks in advance.

 

public with sharing class SendEmailPage {

public String contactEmail1 {get; set;}
public String contactEmail2 {get; set;}
public String contactEmail3 {get; set;}
public Id AccId {get; set;}

public SendEmailPage(ApexPages.StandardController controller) {
try{

Safari__c test=new Safari__c();
test=[Select Account__c,Email_Flag__c,Email_Date__c From Safari__c Where id=:ApexPages.currentPage().getParameters().get('id')];
AccId=test.Account__c;}

catch(Exception e){
}

}
//Our collection of the class/wrapper objects attachmentwrapper
public List<attachmentwrapper> attachmentList = new List<attachmentwrapper>();

List<Attachment> selectedAttachments = new List<Attachment>();

//This method uses a simple SOQL query to return a List of Attachments
public List<attachmentwrapper> getAttachments()
{
attachmentList.clear();
for (Attachment a : [select Name from Attachment where ParentId = :ApexPages.currentPage().getParameters().get('id')])
attachmentList.add(new attachmentwrapper(a));
return attachmentList;
}
//We create a new list of Attachments that will be populated only with Attachments if they are selected
public void getselectedAttachments()
{
selectedAttachments.clear();
//We will cycle through our list of attachmentwrapper and will check to see if the selected property is set to true, if it is we add the Attachment to the selectedAttachment list
for(attachmentwrapper attwrapper : attachmentList)
{
if(attwrapper.selected == true)
{
selectedAttachments.add(attwrapper.att);
}
}
for(Attachment att: selectedAttachments) {
system.debug(att);
}
}

// This is our wrapper/container class
public class attachmentwrapper
{
public Attachment att{get; set;}
public Boolean selected {get; set;}
//This is the contructor method. When we create a new attachmentwrapper object we pass a Attachment that is set to the att property.
//We also set the selected value to false
public attachmentwrapper(Attachment a)
{
att = a;
selected = false;
}
}

public String response { get; set; }
public String body { get; set; }
public String subject { get; set; }

private final Safari__c safari;
// Create a constructor that populates the Proposal object
public Safari__c getSafari() {
return safari;
}

public PageReference sendEmail() {
// Define the email
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = ContactEmail1.split(',',0);
mail.setToAddresses(toAddresses);
mail.setTargetObjectId(UserInfo.getUserId());
//mail.setTargetObjectId('003G0000017OONf');


system.debug('List of To Contacts: '+ contactEmail1);
mail.setReplyTo('noreply@yourcompany.com');
mail.setSenderDisplayName('Your Company Name');
mail.setSubject('Your Subject Here');
mail.setPlainTextBody(body);
mail.setWhatId(ApexPages.currentPage().getParameters().get('id'));
if(ContactEmail2 !=NULL && ContactEmail2.trim() != '')
{
String[] ccaddress=ContactEmail2.split(',', 0);
mail.setCcAddresses(ccaddress);
system.debug('my cc addresses here');

}

if(ContactEmail3 !=NULL && ContactEmail3.trim() != '')
{
String[] bccaddress=ContactEmail3.split(',', 0);
mail.setBccAddresses(bccaddress);
system.debug('my cc addresses here');
}
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
getselectedAttachments();
for(Integer j = 0; j < selectedAttachments.size(); j++)
{
// Add to attachment file list
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(selectedAttachments.get(j).Name);
string sname=selectedAttachments.get(j).Name;
Attachment a =[select Attachment.Name, Attachment.Body from Attachment where Attachment.Name =: sname ];
efa.setBody(a.body);
fileAttachments.add(efa);
efa=null;
}
mail.setFileAttachments(fileAttachments);
mail.setSaveAsActivity(true);
try{
Messaging.SendEmailResult[] resultMail = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
if(resultMail[0].isSuccess())
response = 'ok sent!';
else{
response = resultMail[0].getErrors().get(0).getMessage();
}
Id id= ApexPages.currentPage().getParameters().get('id');
PageReference newPage = new PageReference('/'+id);
newPage.setRedirect(true);
return newPage;
}catch(System.EmailException ex){
response = ex.getMessage();
}
return null;
}

public pagereference cancel()
{
Id id= ApexPages.currentPage().getParameters().get('id');
PageReference newPage = new PageReference('/'+id);
newPage.setRedirect(true);
return newPage;
}

}

I am trying to get basic profile info from Linkedin API in APEX, i got authorization token and secret token but not able to retrieve basic profile using the token. please find below the code :

 

public void getLinkedinData(){
    List<TestLinkedin__c> tok = [select unAuth_Key__c,unAuth_Token__c from TestLinkedin__c where name='AuthKey' limit 1];  
    oauth_token = tok[0].unAuth_Token__c;
    oauth_token_secret = tok[0].unAuth_Key__c;        

    unAuthorisedToken =  tok[0].unAuth_Token__c;
    unAuthorisedKey = tok[0].unAuth_Key__c;  

    nonceValue  = generateNonce(); 
    timeStamp = generateTimeStamp();     

    string TripItAccessDataUri='https://api.linkedin.com/v1/people/~/format/json';

    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setMethod('GET');
    req.setEndpoint(TripItAccessDataUri);
    final String oAUth_BASE_signature = SignatureBaseStringForAccessData(TripItAccessDataUri,unAuthorisedToken,unAuthorisedKey,nonceValue,timeStamp); 
    String signature = SignatureForAccessData(oAUth_BASE_signature ,consumerKey_Secret+'&'+unAuthorisedKey);
    req.setHeader('Authorization','OAuth realm=\"https://api.linkedin.com/\",oauth_consumer_key=\"'+oauth_consumer_key+'\",oauth_token=\"'+unAuthorisedToken+'\",oauth_nonce=\"'+nonceValue+'\",oauth_token_secret=\"'+unAuthorisedKey+'\",oauth_signature_method=\"'+oauth_signature_method+'\",oauth_timestamp=\"'+timeStamp +'\",oauth_version=\"'+oauth_version+'\",oauth_signature=\"'+signature+'\"');  
    reqstr =oAUth_BASE_signature ;
    HttpResponse res = h.send(req);
    resData =  res.getBody();
    system.debug('&&&&&&&&&&&&&&&& Respose' + resData );
}   

public String generateNonce(){
    String nonce;
    String finalNonce ;  
    nonce = String.valueOf(Math.abs(Math.random())); 
    finalNonce = nonce.substring(nonce.indexOf('.')+1,nonce.length());
    System.debug('+++++++++Nonce '+ finalNonce );
    return finalNonce ;
} 
public long generateTimeStamp(){
    long millis = (long) System.currentTimeMillis() ;
    long sysTime = (long) millis / 1000;
    System.debug('+++++++++++++TimeStamp'+ sysTime );
    return sysTime ;
}

public String SignatureBaseStringForAccessData(String TripItAccessDataUri,String unAuthorisedToken,String unAuthorisedKey,String  nonceValue ,Long timeStamp) {
    String httpmethod = 'GET';
    String oAUTH_PARA='oauth_consumer_key='+oauth_consumer_key+'&oauth_nonce='+nonceValue +'&oauth_signature_method='+oauth_signature_method+'&oauth_timestamp='+timeStamp+'&oauth_token='+unAuthorisedToken+'&oauth_token_secret='+unAuthorisedKey+'&oauth_version='+oauth_version+'';
    String BASE_STRING = httpmethod+'&'+EncodingUtil.urlEncode(TripItAccessDataUri,'UTF-8')+'&'+EncodingUtil.urlEncode(oAUTH_PARA,'UTF-8');
    return BASE_STRING;
}

//Signature Generator for Data
public String SignatureForAccessData(String Signature_Base_Value,String Key){
    Blob mac = Crypto.generateMac('HmacSHA1',Blob.valueOf(Signature_Base_Value),Blob.valueOf(Key));
    String macUrl = EncodingUtil.urlEncode(EncodingUtil.base64Encode(mac),'UTF-8');
    System.debug('++++++++Final Signature Is '+macUrl );   
    return macUrl;
}

Response body:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<error>
    <status>401</status>
    <timestamp>1354429511382</timestamp>
    <request-id>GDGNWB2M1V</request-id>
    <error-code>0</error-code>
    <message>[unauthorized].OAU:tylg6udljqe0|e7820b33-6acc-4752-b014-f54d505cf‌8a0|*01|*01:1354376252:vufYE2Zeg9Dg/R1YXO21cRlfmPA=</message>
</error>

Anyone know how to get Charting to use math instead of concatenation?  The Chartclass is concatenating decimal variables instead of adding them.

 

I'm trying to create a stacked bar graph of 5 different products.  DeveloperConsole output shows the queried values are correct.

 

But when I try to SUM to values to create the Y Axis, it ends up like this: (see highlight)

 

from DeveloperConsole:

 

VCur: 3433.23

lmonth:    1222.32

lqtr:   454.34

lsales:  887.34

lprod: 232.23

vTotal:  3433.231222.32454.34887.34232.23

 

(this is a defined as a Decimal variable - how is this possible)?

 

I also tried casting each value - but no luck.

 

 

Here is the code:
 Decimal VCur;
        Decimal lmonth;
        Decimal lqtr;
        Decimal lsales;
        Decimal lprod;
     
        
        List<AggregateResult> qCur = [Select Sum(salesAmt__c) Sum from CTest__c where... ];
        List<AggregateResult> qmonth = [Select sum(salesAmt__c) Sum from CTest__c where ... ];
        List<AggregateResult> qqtr = [Select sum(salesAmt__c) Sum from CTest__c where ...];
        List<AggregateResult> qsales = [Select sum(salesAmt__c) Sum from CTest__c where ...];                
        List<AggregateResult> qprod = [Select sum(SalesAmt__c) Sum from CTest__c where...];                
       
        for (AggregateResult ar : Cur) {
            vCur = (Decimal)ar.get('Sum');
        }
                System.Debug('VCUR = ' + vCur);

        for (AggregateResult ar : qmonth) {
            lmonth = (Decimal)ar.get('Sum');
        }
                System.Debug('lmonth = ' + lmonth);

        for (AggregateResult ar : qqtr) {
            lqtr = (Decimal)ar.get('Sum');
        }
                System.Debug('lqtr = ' + lqtr);

        for (AggregateResult ar : qqtr) {
            lsales = (Decimal)ar.get('Sum');
        }
                System.Debug('lsales = ' + lsales);

        for (AggregateResult ar : qprod) {
            lprod = (Decimal)ar.get('Sum');
        }
                System.Debug('lprod = ' + lprod);

        Decimal vTotal = vCur + lmonth + lqtr + lsales + lprod;
        System.Debug('vTotal = ' + vCur + lmonth + lqtr + lsales + lprod);         

Enterprise Edition, Winter 13.  I have a simple VF page:

 

<apex:page standardController="Account">
Hello, world.
</apex:page>

 I have tried to embed this VF page into my one and only Account page layout.  When I go to the page layout (that is go to view a particular Account record in SFDC), there is just a big blank white space where the VF page should be rendering.

 

If I try to access the VF page directly (https://[instance].salesforce.com/apex/test_page), it renders no problem, giving me my "Hello, world." greeting.  

 

I've poked around in security settings, I've tried embedding it in other object page layouts (i.e., Contacts where it doesn't work and Cases where it does work), I've tried wrapping my "Hello, world." in an apex:outputPanel.  I've tried creating a generic extension class that doesn't do anything but lets me specify the extensions attribute to the apex:page component.  I've checked the security on the page and granted access to all profiles.  I've confirmed this behavior is the same in sandbox and production.  I'm not hitting any limits.  I've checked record types.

 

At this point I'm at a loss.  Help!


hi i write one query for getting the minmum and maxmium date .
what i write its excuting correct and giving the result like this format

Date First Photo Taken: Sun Nov 11 09:18:00 GMT 2012
Date LastPhoto Taken: Thu Nov 15 09:59:00 GMT 2012


but i want the result date should be like this : 16/8/2011

how can i change my result to this format can any one tel me how can we show date in this format.
thanks advance.


List<AggregateResult> shootlst= [select  min(Date_Photo_Taken__c) minm,max(Date_Photo_Taken__c) maxm from ShMgmt__c];
        for(AggregateResult ar:shootlst)
        {
        // query for shooting :Date First Photo Taken
        
        phot=date.valueOf(ar.get('minm'));
        system.debug('vp retail'+phot);
        }
// query for shooting :Date LastPhoto Taken
        
        phottakn=date.valueOf(ar.get('maxm'));      
        system.debug('vp retail'+phottakn);
        }






any one help me.

#!/usr/bin/perl
use WWW::Salesforce::Simple ;

my $sforce = WWW::Salesforce::Simple->new( username => 'user@domain.com',
                                           password => 'pas$w@rd!' );
print "Connection result: $sforce\n" ;

 I'm unable to get the basic code above to work.  When I run it, either on Linux or on Windows, I get the following message:

Incorrect parameter at /path/to/perl5/lib/perl5/SOAP/Lite.pm line 1993

I'm using EPIC to debug.  The failure is occuring at line 482 of Salesforce.pm:

 

 

    $self->{'sf_sid'}       = $r->valueof('//loginResponse/result/sessionId');

 My debugger shows that there is a value for //loginResponse/result/sessionId.  The valueof function is calling the match method which is calling the _traverse method.  _traverse is recursive, but line 1993 of Lite.pm prevents the recursion tree from gong more than 10 levels deep, which is where my code dies out.

 

I can't, however, quite follow the logic of the _traverse function. Is there a bug there?