• Guillaume Morin
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hi,
I'm trying to see if there's is a way to use a related list custom button and pass along the related list entry checked (only 1) to create a new case. Looking all over, I can't seem to locate any specific example on how to do this.

Right now I can easily create a new case passing AccountID and ContactID details but I would also need to pass one of the related list entries (checked one). Simple using related list ID doesn't work.

In a perfect world I would also be able to place the custom button right beside the "Edit"/"Delete" list button but I don't believe this is possible.

I'm currently using URLFOR to pass along the info. If you think JS is needed, it would be fine, unfortunately APEX is not possible.

Thank you very much for your ideas

Guillaume
Hi,

I am trying to see if there is a way to have Dynamic Email Alert Recipients configured in SFDC. I know about the Related Contact, Users, etc but none of these can actually do what i'm looking for.

Here's the situation.
Email Alert is triggered from a Case
If the Role of the User triggering the EA is A, then recipients needs to be A1-A2-A3-Z
If the Role of the User triggerins is B, then recipients needs to be B1-B2-B3-Z

Right now it seems the only way I can do this is to create 2 separate sets of WF and EA and then assign the recipients for each EA. Since the Email Template is the same and all the other factors on the WF are the same, I was wondering if there was any way I could have a formula (or similar) that would dynamically update the recipients based on the User Role. Such automatization would probably save me 75% of all my WF and EA.

PS: User Role and Recipients are not direct subordinates

Thanks

Bill
Hi Everyone, 

I'm having an issue with code coverage when I'm attempting to import a change set into production. For some reason no matter what I do, my coverage is always at 0% and gives me a fatal error even though my sandbox is showing 100 percent. Here is my code below! Any help would be appreciated. 


Public class AutoConvertLead
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(id currentlead: LeadIds){
                Database.LeadConvert Leadconvert = new Database.LeadConvert();
                Leadconvert.setLeadId(currentlead);
                Leadconvert.setOwnerId(Userinfo.getUserId());
                Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
                MassLeadconvert.add(Leadconvert);
        }
        List<ID> LeadAccounts      = new List<ID>();
        List<ID> LeadOpportunities = new List<ID>();
        if (!MassLeadconvert.isEmpty()) {
            for(Database.leadconvert acc : MassLeadConvert){
                Database.LeadConvertResult art = database.convertlead(acc); 
                LeadAccounts.add(art.getAccountId());
                LeadOpportunities.add(art.getOpportunityId());
        }
            List<Account> LeadAccountsupdate = [Select ID, name, npe01__One2OneContact__c,(Select FirstName, Lastname, AccountId, ID  from Contacts Limit 1) From Account Where ID in :LeadAccounts];
            System.debug(LeadAccountsupdate.size());
            for(Account acc: LeadAccountsupdate){
                System.debug(acc.contacts[0]);
                acc.name = acc.contacts[0].firstname + ' ' + acc.contacts[0].lastname + ' Household';
                acc.npe01__One2OneContact__c = acc.contacts[0].id;
                update acc;
            }
            List<Opportunity> LeadOpportunitiesupdate = [Select ID, Name, npsp__Primary_Contact__c, Pick_up__c, Type_of_Good__c, Closedate, account.npe01__One2OneContact__r.name From Opportunity Where ID in :LeadOpportunities];
            for(Opportunity opp: LeadOpportunitiesupdate){
                String[] multi = opp.Type_of_Good__c.split(';');
                String   rcc   = string.valueof(opp.CloseDate);
                opp.name = opp.account.npe01__One2OneContact__r.name + ' / ' + opp.Pick_up__c + ' / ' + multi + ' / ' + rcc; 
                opp.npsp__Primary_Contact__c =  opp.account.npe01__One2OneContact__c;
                update opp;  
    }
}
}
}
Here below is my test class



@isTest
public class AutoConvertLeadTest {

 static testMethod void validateAutoConvertLead() {
     Test.startTest();
     Lead testLead      = new lead();
     testLead.firstname = 'qasx';
     testLead.LastName  = 'Bucker';
     testLead.Company   =  'Not Applicable';
     testLead.LeadSource = 'Web';
     testLead.Pick_up_or_Drop_off__c = 'Pick Up';
     testLead.Type_of_Good__c = 'Meat';
     testLead.OwnerId   = Userinfo.getUserId();
     testLead.Status    = 'Convert Automation';
     insert testLead;

        test.stopTest();

 }
}

I'm using the online Visualforce documentation to try to learn how to render a visualforce component as a PDF attachment on a visualforce email.  But, when I try creating a component exactly like the one in the documentation I get an error.  Am I missing something or is there a mistake in the documentation??

 

Here's the code I can't get to work (gray box below).  When I copy and paste it into a new visualforce component, it won't save and gives me this error message: Error: Unknown property 'account'

 

Defining a Custom Component as an Attachment

By creating a custom component and using it on the Visualforce email form and to render the PDF for the email, users can see a preview of the content they are trying to send.

The following markup defines a custom component namedattachmentthat represents the attachment for the email:
<apex:component access="global">
  <h1>Account Details</h1>
  
  <apex:panelGrid columns="2">

      <apex:outputLabel for="Name" value="Name"/>
      <apex:outputText id="Name" value="{!account.Name}"/>
      
      <apex:outputLabel for="Owner" value="Account Owner"/>
      <apex:outputText id="Owner" value="{!account.Owner.Name}"/>
      
      <apex:outputLabel for="AnnualRevenue" value="Annual Revenue"/>
      <apex:outputText id="AnnualRevenue" value="{0,number,currency}">
          <apex:param value="{!account.AnnualRevenue}"/>
      </apex:outputText>
      
      <apex:outputLabel for="NumberOfEmployees" value="Employees"/>
      <apex:outputText id="NumberOfEmployees" value="{!account.NumberOfEmployees}"/>
      
  </apex:panelGrid>
</apex:component>
Replace yourattachmentPDFpage like this: