• nduch
  • NEWBIE
  • 75 Points
  • Member since 2011

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 25
    Replies

Hi,

 

Can someone please tell me how i can limit the number of results returned.  ie. if more than 100 records are found than an error message showed be displayed to the user stating that you must narrow your search etc.

 

public class CaseController1 {

    public String getSearchText() {             
        return null;               
        }
    
    private List<Case> result = new List<Case>();   
    private String searchText;
    
    public CaseController1(){   }
    
   public List<Case> getResult() {return result;}

   public void setSearchText(String searchText)
        { this.searchText = searchText; }

        public void search() {
        String queryText = searchText + '%';                     
        result = [select Model_Number__c from Case Where Model_Number__c like :queryText];
}
}

 

 

 

  • December 16, 2011
  • Like
  • 0

Hi,

I cannot create a new Activity History record when using message.setSaveAsActivity(true);

 

This is my code:

 

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {recipient.Email};
        mail.setToAddresses(toAddresses);
        mail.setBccSender(true);
        String[] bccAddresses = new String[] {person.Email};
        mail.setBccAddresses(bccAddresses);
        mail.setSaveAsActivity(true);
        mail.setSubject(subject);
        mail.setPlainTextBody(templateBody);

       Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});

 

Am I doing something wrong?My controller is extending the custom controller.

 

Many thanks!

  • December 19, 2011
  • Like
  • 0

HI,

I have a problem determining the current user id.

 

I am using String userid = UserInfo.getUserId() , but this is returning null for some reason.

 

Any ideas why? Is it because I am in development mode, and not user mode?

 

Many thanks for help!

  • December 16, 2011
  • Like
  • 0

Hi,

I have a text field in Visualforce that display email template automatically to the user.

 

<apex:inputTextarea  value="{!templateBody}" />

 

The user then edits the text and clicks on a button. What I want to do is  - when the user clicks on the button I want to get the user input to Apex. How can I do that?

 

I suppose I have to use setter method for templateBody Apex variable, but I dont know how to reference the inputTextarea field.

 

Many thanks for help!

  • December 15, 2011
  • Like
  • 0

HI all,

for some reason my Visualforce button is not sending an email.

 

<apex:page standardController="Contact" extensions="SendEmailPageController" >

<apex:form>
        <apex:pageBlockButtons location="bottom">
                  <apex:commandButton action="{!send}"   value="Send Email" />
                  <apex:commandButton action="{!cancel}" value="Cancel" />
        </apex:pageBlockButtons>

</apex:form>

 

My Controller class:

 

public class SendEmailPageController {

 

public PageReference send() {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {'****@yahoo.com'};
        mail.setToAddresses(toAddresses);
        mail.setBccSender(false);
        mail.setSubject('Subject');
        mail.setPlainTextBody('Test Message Body');

 

        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
        for ( Messaging.SendEmailResult result : r ) {

           if ( !r[0].isSuccess () ) {
              
               System.debug ( result  );
           }

           else{

               ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, 'Email Sent Successfully' );
               ApexPages.addMessage(msg);
           }
        }

        return null;

}

 

Any ideas please?

 

Many thanks!!!

  • December 15, 2011
  • Like
  • 0

Hi,

I know that there has already been many discussions about this, but I still could not find a working solution. However, I got it to work, so I would like to share my solution with you.

 

To create a lookup field in Visualforce, you need <apex:inputField> wrapped in <apex:form>.

The value attribute in <apex:inputField> must reference a real Lookup field. For example, in Contacts there is a standard Lookup field called ReportsTo.

 

Here is my Visualforce code:

 

<apex:page standardController="Contact" extensions="SendEmailPageController">

            <apex:form>
                  <apex:inputField value="{!person.ReportsToId}"/>
            </apex:form>

 

Here is the Apex controller (I am overriding a standard controller for a Contact object):

 

public class SendEmailPageController {
    public Contact person {set;}

    public Contact getPerson()
    {
       return [select id, reportstoid from Contact limit 1];
    }

}

 

Hope it helps!

  • December 15, 2011
  • Like
  • 0

HI,

I have created a Visualforce page and a new button that should open this Visualforce page.

However, when creating the button I chose Content Source= Visualforce page, but Content field is blank and I cannot enter text into it. Therefore I cannot save the button.

 

It looks like a bug. Or am I doing something wrong? See attached screenshot.

 

 

  • December 14, 2011
  • Like
  • 0

Hi,
I would like to achieve the following functionality:
1. Go to Contacts tab and view a contact
2. In the Activity History section click on the 'Send Email' button
3. Required result: The system displays automatically the right template based on the user and contact's country.
At the moment, the system displays a blank email and the user has to click on 'Choose Email Template' button to manually select the right email template.

The required functionality can be also seen in this video (in the 35th second):
http://www.youtube.com/watch?v=dsjgOVpDiFU&noredirect=1

My problem is that I have no access to the Activity History buttons and code, therefore I cannot do any changes. Any advice how to progress? Many thanks!

  • December 08, 2011
  • Like
  • 0

Hi,

I cannot create a new Activity History record when using message.setSaveAsActivity(true);

 

This is my code:

 

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {recipient.Email};
        mail.setToAddresses(toAddresses);
        mail.setBccSender(true);
        String[] bccAddresses = new String[] {person.Email};
        mail.setBccAddresses(bccAddresses);
        mail.setSaveAsActivity(true);
        mail.setSubject(subject);
        mail.setPlainTextBody(templateBody);

       Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});

 

Am I doing something wrong?My controller is extending the custom controller.

 

Many thanks!

  • December 19, 2011
  • Like
  • 0

HI,

I have a problem determining the current user id.

 

I am using String userid = UserInfo.getUserId() , but this is returning null for some reason.

 

Any ideas why? Is it because I am in development mode, and not user mode?

 

Many thanks for help!

  • December 16, 2011
  • Like
  • 0

Hi,

 

Can someone please tell me how i can limit the number of results returned.  ie. if more than 100 records are found than an error message showed be displayed to the user stating that you must narrow your search etc.

 

public class CaseController1 {

    public String getSearchText() {             
        return null;               
        }
    
    private List<Case> result = new List<Case>();   
    private String searchText;
    
    public CaseController1(){   }
    
   public List<Case> getResult() {return result;}

   public void setSearchText(String searchText)
        { this.searchText = searchText; }

        public void search() {
        String queryText = searchText + '%';                     
        result = [select Model_Number__c from Case Where Model_Number__c like :queryText];
}
}

 

 

 

  • December 16, 2011
  • Like
  • 0

Hi,

I have a text field in Visualforce that display email template automatically to the user.

 

<apex:inputTextarea  value="{!templateBody}" />

 

The user then edits the text and clicks on a button. What I want to do is  - when the user clicks on the button I want to get the user input to Apex. How can I do that?

 

I suppose I have to use setter method for templateBody Apex variable, but I dont know how to reference the inputTextarea field.

 

Many thanks for help!

  • December 15, 2011
  • Like
  • 0

HI all,

for some reason my Visualforce button is not sending an email.

 

<apex:page standardController="Contact" extensions="SendEmailPageController" >

<apex:form>
        <apex:pageBlockButtons location="bottom">
                  <apex:commandButton action="{!send}"   value="Send Email" />
                  <apex:commandButton action="{!cancel}" value="Cancel" />
        </apex:pageBlockButtons>

</apex:form>

 

My Controller class:

 

public class SendEmailPageController {

 

public PageReference send() {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {'****@yahoo.com'};
        mail.setToAddresses(toAddresses);
        mail.setBccSender(false);
        mail.setSubject('Subject');
        mail.setPlainTextBody('Test Message Body');

 

        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
        for ( Messaging.SendEmailResult result : r ) {

           if ( !r[0].isSuccess () ) {
              
               System.debug ( result  );
           }

           else{

               ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, 'Email Sent Successfully' );
               ApexPages.addMessage(msg);
           }
        }

        return null;

}

 

Any ideas please?

 

Many thanks!!!

  • December 15, 2011
  • Like
  • 0

how to insert a activity history, in when i send a mail?