• Support 3743
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 7
    Replies
I'm trying to deploy something like this: 

public class Send {
    
    public Send(){ 
    }

    public static Messaging.SingleEmailMessage createEmail(
                         String SenderName, Id TemplateId, Id ObjectId, Id WhatId) 
    {
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setTargetObjectId(ObjectId);
        email.setTemplateId(TemplateId);
        email.setWhatId(WhatId);
        email.setSenderDisplayName(SenderName);
        return email;
    }
    
    public static void MessageSent() {
        
        /* Create a list of email objects */
        Messaging.SingleEmailMessage [] emails = new Messaging.SingleEmailMessage[]{};
            
       /* Get a list of contacts */
        List<Contact> c = [SELECT Name, Id, AccountId
                           FROM Contact
                           WHERE Email != null AND Email != '' ];

        /* Find the size of all the contacts */
        Integer ContactSize = c.size();
        
        /* Locate the email template being used */
        EmailTemplate et = [SELECT id
                                    FROM EmailTemplate
                                    WHERE Name = 'CAF VF'];

/* Iterate through the list of contacts and send email to each */
        for (Integer i = 0; i < ContactSize; i++){
                
                Messaging.SingleEmailMessage temp = createEmail('Report', et.id, c[i].Id, c[i].AccountId);
                emails.add(temp);
            }
        
            try{
                Messaging.sendEmail(emails);
            } catch (Exception e) {
                System.debug('The following exception has occured: ' + e.getMessage());
            }         
    }
}

I get the following errors: 
 - System.NullPointerException: Attempt to de-reference a null object, Stack Trace: Class.MassUpdateSimpleControllerTest.testOpportunityInRelatedList: line 148, column 1
- System.AssertException: Assertion Failed, Stack Trace: Class.Milestone1_GettingStartedController.testGettingStartedProject: line 239, column 1
- System.NullPointerException: Attempt to de-reference a null object, Stack Trace: Class.Milestone1_GettingStartedController.getInitialSettingsWithoutSave: line 190, column 1 Class.Milestone1_GettingStartedController.testGetSettings: line 211, column 1

I have no idea how to fix this. Help me, please!
I have a Visual force page and I want the user to be able to go to that page on click of a button on the homepage. How can I add such a button to the homepage? Thanks!
I have a list of accounts and I want to display all the partners for one particular account in an email sent to that account. I'm using a Visual Force email template but I don't know how to fetch all the account-related partners in the email template. Can someone please help? Thank you!
I want to display all the account-related partners in a Visualforce email template:

relatedToType="Account"
<apex:repeat var="op" value=?>
...
I want value to be a list of all the partners related to the current account. I tried inserting a query: value="{!SELECT Name FROM Account WHERE Id IN (SELECT AccountToId FROM Partner WHERE AccountFromId = relatedTo.Id)}"

The code fails. Can someone help me with this?
I'm having trouble understanding the relationship between Partner and Opportunity. I want to access the data of the partner related to an opportunity. Opportunity has a field called PartnerAccount:
User-added image
However when I use this code: SELECT PartnerAccount.Name FROM Opportunity
There is an error: No such relation 'PartnerAccount' on entity 'Opportunity'

Can anyone tell me why? And how could I access the information in partner when I'm querying opportunity? Thanks!
 
This is what I want to do: 
SELECT Account.Name FROM Account WHERE Business_Type__c like '%Manufacturer/Supplier%'

However I'm getting this error: invalid operator on multipicklist field. Could you tell me what it means and how to fix it?
Hi, I created a custom lookup relationship so that I can access Opportunity when I'm querying Contact:
User-added image

What I want is something like this:

SELECT Email, Look_Opportunity__r.Stage FROM Contact WHERE Oppportunity.Stage != "Not Ready" AND Email != null

However, when I call this the query it returns null for Look_Opportunity: 
User-added image
What's wrong with my code? Many thanks for the help!
Hi, I want to select from Contacts all of the contacts that have opportunities. I used the code below but it's not working:

SELECT Name, (SELECT Name FROM Opportunities) FROM Contact WHERE AccountId in (SELECT AccountId FROM Opportunity)

I know how to select through Account, but I want to know how to do it this way. Thank you!
Hi everyone, I'm a complete newbie to Apex and I'm recently writing an email template that sends out all of the opportunities related to a specific account name. However I don't fully understand what <apex:repeat> does.

In <apex:repeat var="op" value="{!relatedTo.Name}">, what does "var" refer to and what does "value" refer to? Does this create a loop that iterates through all of the records in relatedTo that have Name equal to value? 

Please help me with this! Thank you so much!
 
I'm trying to deploy something like this: 

public class Send {
    
    public Send(){ 
    }

    public static Messaging.SingleEmailMessage createEmail(
                         String SenderName, Id TemplateId, Id ObjectId, Id WhatId) 
    {
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setTargetObjectId(ObjectId);
        email.setTemplateId(TemplateId);
        email.setWhatId(WhatId);
        email.setSenderDisplayName(SenderName);
        return email;
    }
    
    public static void MessageSent() {
        
        /* Create a list of email objects */
        Messaging.SingleEmailMessage [] emails = new Messaging.SingleEmailMessage[]{};
            
       /* Get a list of contacts */
        List<Contact> c = [SELECT Name, Id, AccountId
                           FROM Contact
                           WHERE Email != null AND Email != '' ];

        /* Find the size of all the contacts */
        Integer ContactSize = c.size();
        
        /* Locate the email template being used */
        EmailTemplate et = [SELECT id
                                    FROM EmailTemplate
                                    WHERE Name = 'CAF VF'];

/* Iterate through the list of contacts and send email to each */
        for (Integer i = 0; i < ContactSize; i++){
                
                Messaging.SingleEmailMessage temp = createEmail('Report', et.id, c[i].Id, c[i].AccountId);
                emails.add(temp);
            }
        
            try{
                Messaging.sendEmail(emails);
            } catch (Exception e) {
                System.debug('The following exception has occured: ' + e.getMessage());
            }         
    }
}

I get the following errors: 
 - System.NullPointerException: Attempt to de-reference a null object, Stack Trace: Class.MassUpdateSimpleControllerTest.testOpportunityInRelatedList: line 148, column 1
- System.AssertException: Assertion Failed, Stack Trace: Class.Milestone1_GettingStartedController.testGettingStartedProject: line 239, column 1
- System.NullPointerException: Attempt to de-reference a null object, Stack Trace: Class.Milestone1_GettingStartedController.getInitialSettingsWithoutSave: line 190, column 1 Class.Milestone1_GettingStartedController.testGetSettings: line 211, column 1

I have no idea how to fix this. Help me, please!
I'm having trouble understanding the relationship between Partner and Opportunity. I want to access the data of the partner related to an opportunity. Opportunity has a field called PartnerAccount:
User-added image
However when I use this code: SELECT PartnerAccount.Name FROM Opportunity
There is an error: No such relation 'PartnerAccount' on entity 'Opportunity'

Can anyone tell me why? And how could I access the information in partner when I'm querying opportunity? Thanks!
 
Hi, I created a custom lookup relationship so that I can access Opportunity when I'm querying Contact:
User-added image

What I want is something like this:

SELECT Email, Look_Opportunity__r.Stage FROM Contact WHERE Oppportunity.Stage != "Not Ready" AND Email != null

However, when I call this the query it returns null for Look_Opportunity: 
User-added image
What's wrong with my code? Many thanks for the help!
Hi, I want to select from Contacts all of the contacts that have opportunities. I used the code below but it's not working:

SELECT Name, (SELECT Name FROM Opportunities) FROM Contact WHERE AccountId in (SELECT AccountId FROM Opportunity)

I know how to select through Account, but I want to know how to do it this way. Thank you!
Hi everyone, I'm a complete newbie to Apex and I'm recently writing an email template that sends out all of the opportunities related to a specific account name. However I don't fully understand what <apex:repeat> does.

In <apex:repeat var="op" value="{!relatedTo.Name}">, what does "var" refer to and what does "value" refer to? Does this create a loop that iterates through all of the records in relatedTo that have Name equal to value? 

Please help me with this! Thank you so much!