• uHaveOptions
  • NEWBIE
  • 215 Points
  • Member since 2015
  • CEO

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 61
    Questions
  • 110
    Replies
Hii Friends how can i acheive the bellow scenario
   I have a visual force page contact list in that i have to insert two dashboards in a block in the upper portion how can i achieve this please help 


 
<apex:pageBlockSectionItem HelpText="{!$ObjectType.Account.fields.Phone.inlineHelpText}">
      <apex:outputLabel value="{!me.Phone}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;     font-size: 12px;"/>
      <!--<apex:outputText value="{!me.Phone}" style="width:85%;" />-->      
</apex:pageBlockSectionItem>


How can I remove these lines in Visualforce?
User-added image

I currently am building a visualforce page aligning everything and one of the request is to remove the lines for every visualforce field.  Either using outputField or outputLabel.

Also, since I am in the aligning and lining subject.  How can I make my multi select picklist field all align in one format?

User-added image


any help will be great.

thank you

Help on passing test class.  I just need 5 lines more.  it's at 67%  The class is long I only added what's red and not passing.
 
public void send() {
        try {
            DM_Public_Page_URL__c siteCS = DM_Public_Page_URL__c.getValues('Default');
            String siteURL = siteCS.Site_URL__c;
            String logo = siteCS.Logo__c;
            
            List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
            EmailTemplate emailT = [select Subject, HtmlValue from EmailTemplate where DeveloperName = 'Contact_Form' limit 1];
            
            for(Contact primaryContact : primaryContactList) {
                String body = emailT.HtmlValue.replace('{account_form}', siteURL + '/apex/AccountFormPage?id=' + accountId);
                body = body.replace('{primary_contact_name}', primaryContact.FirstName);
                body = body.replace('{account_name}', accountName);
               body = body.replace('{account_logo}', '<img src="'+siteURL + Logo+'"alt="Logo" height="225px" width="74px"');
                
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setToAddresses(new String[]{primaryContact.Email});
                mail.setSubject(emailT.Subject);
                mail.setHtmlBody(body);
                mails.add(mail);
            }
            
            List<Messaging.SendEmailResult> results = Messaging.sendEmail(mails);
            if(results[0].isSuccess()) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Contact email successfully sent'));
            } else {
                System.debug('------------------- errors: ' + results[0].getErrors());
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while sending the contact update email: ' + results[0].getErrors()));
            }
        } catch(Exception e) {
            System.debug('------------------- ERROR: ' + e.getStackTraceString());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while sending the contact update email: ' + e.getStackTraceString()));
            
        }
    }
    
    public PageReference cancel() {
        PageReference pref = new PageReference('/' + accountId);
        return pref;
    }
}


This is my test class

@isTest
private class AccountFormControllerTest {

    private static testMethod void test() {
        Account lender = new Account();
        lender.Name = 'Test Account';
        insert lender;
        System.debug('created account');
        
        Contact c = new contact();
        c.FirstName = 'JOhn';
        c.LastName = 'Doe';
        c.email='test@test.com';
        c.primary_contact__c = True;
        insert c;
        System.debug('created account');
                
        ApexPages.currentPage().getParameters().put('id', lender.Id);
        AccountFormController controller = new AccountFormController();
        controller.accountUpdate.Equity_Debt__c = 'Debt';
        controller.save();
        
        string options = controller.getOptions();
    }
    
    private static testMethod void test2() {
        Contact ca = new Contact();
            ca.FirstName = 'John';
            ca.LastName = 'Doe';
            ca.email='test@test.com';
            ca.Primary_Contact__c = true;
    
        ApexPages.currentPage().getParameters().put('id', 'some id');
        AccountFormController controller = new AccountFormController();
        controller.save();
        
        AccountFormController controller2 = new AccountFormController();
        controller2.save();
        
        ApexPages.currentPage().getParameters().put('id', '');
        AccountFormController controller3 = new AccountFormController();
        controller3.save();
        
        try{
        Insert ca;
        }
        catch(Exception ee){
        }   
    }
    
}
This is whats not passing...
 
String body = emailT.HtmlValue.replace('{account_form}', siteURL + '/apex/AccountFormPage?id=' + accountId);
                body = body.replace('{primary_contact_name}', primaryContact.FirstName);
                body = body.replace('{account_name}', accountName);
               body = body.replace('{account_logo}', '<img src="'+siteURL + Logo+'"alt="Logo" height="225px" width="74px"');
                
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setToAddresses(new String[]{primaryContact.Email});
                mail.setSubject(emailT.Subject);
                mail.setHtmlBody(body);
                mails.add(mail);
            }

 

I'm 68% to pass my trigger and close to getting 75% .  i just need a few more lines to pass. can anyone guide me for this to pass?

Here is the trigger
 

Trigger PrimaryContact on Contact (Before Insert, Before Update, 
                                   After Insert, After Update, After Delete, After UnDelete) {
    
     List<Id> actIds = New List<Id>();
     List<Contact> comingCons = New List<Contact>();
     List<Id> conIds = New List<Id>();
     
     If(Trigger.IsBefore && (Trigger.IsInsert || Trigger.IsUpdate))
     {
         For(Contact Con : Trigger.New)
         {
             If(Con.Primary_Contact__c == TRUE)
             {
                actIds.add(Con.AccountId);
                conIds.add(Con.Id);
                comingCons.add(Con);
             }
             
         }
     }
     
     List<Account> allRelatedAccounts = [Select Id, (Select Id, Primary_Contact__c 
                                                     FROM Contacts WHERE Primary_Contact__c = TRUE AND Id !=: conIds)
                                                        FROM Account WHERE Id =: actIds];
     
     
     For(Contact EveryCon : comingCons)
     {
         For(Account EveryAccount : allRelatedAccounts){
             If(EveryCon.AccountId == EveryAccount.Id && EveryAccount.Contacts.size() > 0){
                 EveryCon.addError('There is already a primary contact for this account');
             }
         }
     }                                  
                                       
     
                                   
    List<Id> accountIds = New List<Id>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUnDelete){
        For(Contact Con : Trigger.New){
            If(Con.AccountId != NULL){
                accountIds.add(Con.AccountId);
            }
        }
    }
    If(Trigger.IsDelete){
        For(Contact Con : Trigger.Old){
            If(Con.AccountId != NULL){
                accountIds.add(Con.AccountId);
            }
        }
    }
    
    List<Account> actFinalListToUpdte = New List<Account>();
    
    
    For(Account act : [Select ID, Contact2__c,
                            (Select Id, FirstName, LastName,
                                    Primary_Contact__c FROM Contacts WHERE Primary_Contact__c = TRUE LIMIT 1)
                                FROM Account WHERE Id =: accountIds])
    {
        If(act.Contacts.size() > 0)
        {
            act.Contact2__c = act.Contacts[0].Id;
            actFinalListToUpdte.add(act);
        }
            
    }
    
    try{
        If(!actFinalListToUpdte.isEmpty()){
            update actFinalListToUpdte;
        }
    }Catch(Exception e){
        system.debug('Thrown Exception for PrimaryContact is: ' + e.getMessage());
    }
}
 

This are the line not passing
 

For(Contact EveryCon : comingCons)
     {
         For(Account EveryAccount : allRelatedAccounts){
             If(EveryCon.AccountId == EveryAccount.Id && EveryAccount.Contacts.size() > 0){
                 EveryCon.addError('There is already a primary contact for this account');
             }
         }
     }     


    If(Trigger.IsDelete){
        For(Contact Con : Trigger.Old){
            If(Con.AccountId != NULL){
                accountIds.add(Con.AccountId);
            }
        }
    }

    For(Account act : [Select ID, Contact2__c,
                            (Select Id, FirstName, LastName,
                                    Primary_Contact__c FROM Contacts WHERE Primary_Contact__c = TRUE LIMIT 1)
                                FROM Account WHERE Id =: accountIds])
    {
        If(act.Contacts.size() > 0)
        {
            act.Contact2__c = act.Contacts[0].Id;
            actFinalListToUpdte.add(act);
        }
            
    }
 

This is the test class and its 68%
 

@isTest
public class PrimaryContactTest {
    
    static testMethod void createAccount(){
        
    Account a = new Account();
        a.Name = 'test Co.';
        insert a;
        System.debug('created account');
           
    Contact c = new Contact();
        c.FirstName = 'John';
        c.LastName = 'Doe';
        c.Primary_Contact__c = True;
        Insert c;
        System.debug('Insert primary contact');
        
    Contact ca = new Contact();
        ca.FirstName = 'John';
        ca.LastName = 'Doe';
        ca.Primary_Contact__c = False;
        Insert ca;
        System.debug('Insert primary contact');
        
        
    Update a;    
}
}
I have this button that will acces a public void send.  It will send an email which is great.  however, I would it to date stamp letter_date__c field in the account object everytime I send an email or press the send button.  It should constantly overwrite the field. Any ideas?
 
public void send() {
        try {
            DM_Public_Page_URL__c siteCS = DM_Public_Page_URL__c.getValues('Default');
            String siteURL = siteCS.Site_URL__c;
 
            List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
            EmailTemplate emailT = [select Subject, HtmlValue from EmailTemplate whereDeveloperName = 'Millenial_Form' limit 1];
             
            for(Contact primaryContact : primaryContactList) {
                String body = emailT.HtmlValue.replace('{account_form}', siteURL + '/apex/AgeMillenial?id=' + accountId);
                body = body.replace('{primary_contact_name}', primaryContact.FirstName);
                body = body.replace('{account_name}', accountName);
                 
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setToAddresses(new String[]{primaryContact.Email});
                mail.setSubject(emailT.Subject);
                mail.setHtmlBody(body);
                mails.add(mail);
            }
             
            List<Messaging.SendEmailResult> results = Messaging.sendEmail(mails);
            if(results[0].isSuccess()) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Mail Sent'));
            } else {
                System.debug('------------------- errors: ' + results[0].getErrors());
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Mail Issue.  There's no email: ' + results[0].getErrors()));
            }
        } catch(Exception e) {
            System.debug('------------------- ERROR: ' + e.getStackTraceString());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Mail Issue.  There's no email: ' + e.getStackTraceString()));
             
        }
 }


Thanks
Using this Apex Trigger, how can I add or show the primary contact in the Account object.  I know it can be shown using the contact related list but I would like it to show on the detail page instead as a lookup so users can just click on the contact link instead of looking for the primary contact in the related list.

Here's the code 
trigger PrimaryContact on Contact (before insert, before update) {
  
   set<id> getid = new set<id>();
    string contactId;
    List<Contact> conList = new List<Contact>();
  
    // Trigger Functionality
    if(Trigger.isInsert || Trigger.isUpdate) {
      
        for(Contact cont: Trigger.New) {
          
            if(cont.Primary_Contact__c == true) {
              
                getid.add(cont.AccountId);
                contactId = cont.id;
            }
        }
    }
  
    // Fetching the other Contact which has primary contact checked
    List<contact> cList = [select id, Primary_Contact__c from contact where accountid IN: getid AND Primary_Contact__c = true];
  
    // Unchecking the already checked primary contact
    if(cList.size() > 0) {
      
        for(Contact newClst: cList) {
          
            if(newClst.id != contactId) {
              
                newClst.Primary_Contact__c = false;
                conList .add(newClst);
            }
        }
    } 
    update conList; 
  }
Thanks in advance
 

So I've been tinkering on this and wondering if you guys can guide me.  All my fields update on but the Account information portion doesn't.  Like the name and number.  The goal is simple update the phone then the account updates.  Any clue?

Here is my VF.

<apex:page controller="AccountFormController" sidebar="false" showHeader="true" id="pg">
         
     <apex:pageBlock mode="maindetail">
       
         <apex:form id="form" styleClass="form-horizontal">
             <div class="panel panel-default">
                <apex:pageBlockSection columns="1">
                <div class="panel-heading"><h4>Company Information</h4> 
             </div>
         </apex:pageBlockSection>


     <apex:pageBlockSection columns="2">
               
         <apex:pageBlockSectionItem HelpText="{!$ObjectType.Account.fields.Name.inlineHelpText}" >
             <apex:outputLabel value="Name" for="{!lender.Name}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
             <apex:inputField value="{!lender.Name}" style="width:85%;" />   
         </apex:pageBlockSectionItem>     
                          
         <apex:pageBlockSectionItem HelpText="{!$ObjectType.Account.fields.Phone.inlineHelpText}">
             <apex:outputLabel value="Phone" for="{!lender.Phone}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;     font-size: 14px;"/>
             <apex:inputField value="{!lender.Phone}" style="width:85%;" />      
         </apex:pageBlockSectionItem> 

     
     </apex:pageBlockSection>
     
     </div>

         </apex:pageBlockSection>
                
            <apex:pageBlockSection columns="1">    
                
                    <apex:pageBlockSectionItem HelpText="{!$ObjectType.Account_Update__c.fields.Primary_Focus__c.inlineHelpText}">
                        <apex:outputLabel value="Primary Focus" for="{!accountUpdate.Primary_Focus__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
                        <apex:inputField value="{!accountUpdate.Primary_Focus__c}" style="width:100%;"/>   
                    </apex:pageBlockSectionItem>


                </apex:pageBlockSection>

                

                <apex:commandButton value="Update" action="{!save}" styleClass="btn pull-right" />

            </apex:form>


        
        <div class="modal fade" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-body">
                        <h3>Processing...</h3><br/>
                        <div class="progress">
                            <div class="progress-bar progress-bar-striped active" role="progressbar"
                            aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:100%">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--
        <div>{!Options}</div>-->
    </apex:pageBlock>

    </body>
                           <!-- </apex:pageBlock>-->
</div>
</apex:page>



Here is my APEX

 

public class AccountFormController {
    
    public Account lender {get; set;}
    public Account_Update__c accountUpdate {get; set;}
    
    private String accountId;
    
    public AccountFormController() {
        accountId = ApexPages.currentPage().getParameters().get('id');
        
        if(String.isBlank(accountId)) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not find account id in the parameter.'));
            return;
        }
        
        accountUpdate = new Account_Update__c();
        getAccount();
    }

    public PageReference save() {   //***************************NOTE: Save Code works.  it's just too long************************  

   }
}       

************ This is where I'm lost******************

private void getAccount() {
        try {
            lender = [
                select
                    Id,
                    Name,
                    Phone,
                    Primary_Focus__c,

                from Account
                where Id = :accountId
            ];
        
            if(lender == null) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not find the account with the given id.'));
                return;
            }
            
             accountUpdate.Phone__c = lender.Phone;
             accountUpdate.Primary_Focus__c = lender.Primary_Focus__c;

            
            
            
        } catch(Exception e) {
            System.debug('------------- ERROR: ' + e.getStackTraceString());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was a problem while getting the account information.' + e.getStackTraceString()));
            return;
        }
    }

The update should update the ACcount object. Also tried using Phone__c but says field doesn't exist.  If I update the Primary focus it updates just fine.  Thanks in advance
I'm trying to align my Input picklist fields and making all the box the same size.  I'm blanking out. Wondering what I am missing.  I already tried floater, align right... no luck.  Any guidance is appreciated.  Also, I find it weird that my VFpage only shows 3 lines of data in Primary focus vs lending footprint.  Where the visible llines I inputed was 10... weird.
 
<apex:pageBlockSection columns="2">    
                
    <apex:pageBlockSectionItem HelpText="!$ObjectType.Account_Update__c.fields.Primary_Focus__c.inlineHelpText}">
        <apex:outputLabel value="Primary Focus" for="{!accountUpdate.Primary_Focus__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
        <apex:inputField value="{!accountUpdate.Primary_Focus__c}" styleClass="col-md-8" style="width:85%;"/>   
    </apex:pageBlockSectionItem>
                    
    <apex:pageBlockSectionItem HelpText="!$ObjectType.Account_Update__c.fields.Lending_Footprint__c.inlineHelpText}">
        <apex:outputLabel value="Lending Footprint" for="{!accountUpdate.Lending_Footprint__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
        <apex:inputField value="{!accountUpdate.Lending_Footprint__c}" styleClass="col-md-8" style="width:100%;"/>   
    </apex:pageBlockSectionItem>
                    
    <apex:pageBlockSectionItem HelpText="!$ObjectType.Account_Update__c.fields.Min_Project_Deal_Size_txt__c.inlineHelpText}">
        <apex:outputLabel value="Min Loan Size" for="{!accountUpdate.Min_Project_Deal_Size_txt__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
        <apex:inputField value="{!accountUpdate.Min_Project_Deal_Size_txt__c}" styleClass="col-md-8" style="width:100%;"/>   
    </apex:pageBlockSectionItem>
                    
    <apex:pageBlockSectionItem HelpText="{!$ObjectType.Account_Update__c.fields.Max_Project_Deal_Size_txt__c.inlineHelpText}">
        <apex:outputLabel value="Max Loan Size" for="{!accountUpdate.Max_Project_Deal_Size_txt__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;  font-size: 14px;"/>
        <apex:inputField value="{!accountUpdate.Max_Project_Deal_Size_txt__c}" styleClass="col-md-8" style="width:100%;"/>   
    </apex:pageBlockSectionItem>
                    
    <apex:pageBlockSectionItem HelpText="{!$ObjectType.Account_Update__c.fields.Loan_Term__c.inlineHelpText}">
        <apex:outputLabel value="Loan Term" for="{!accountUpdate.Loan_Term__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
        <apex:inputField value="{!accountUpdate.Loan_Term__c}" styleClass="col-md-6" style="width:100%;"/>   
    </apex:pageBlockSectionItem>
User-added image
 

My redirect button is not working.  Not sure why or where I'm missing the code.  Can anyone help?  The goal is when it updates I want it to go to a webpage.

This is my button

<apex:commandButton value="Update" action="{!save}" styleClass="btn pull-right" onclick="$j('#pleaseWaitDialog').modal('show')" oncomplete="$j('#pleaseWaitDialog').modal('hide')"/>
<div class="modal fade" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-body">
                        <h3>Processing...</h3><br/>
                        <div class="progress">
                            <div class="progress-bar progress-bar-striped active" role="progressbar"
                            aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:100%">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
 

 


This is my APEX
public void save() {
        try {
            if(accountUpdate.Account__c == null) {
                accountUpdate.Account__c = accountId;
            }
            upsert accountUpdate;
            PageReference reRend = new PageReference('GOOGLE.COM');
        reRend.setRedirect(true);
        } catch(Exception e) {
            System.debug('------------- ERROR: ' + e.getStackTraceString());
            System.debug('------------- ERROR: ' + e.getMessage());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was a problem while saving the account information.'));
            return;
        }
    }


Thanks
When I uploaded an APEX & Test Class at 94% completed it failed the validation in the inbound change set and gave me 3 apex test failures.  They're mainly test classes and completely irrelevant to what I need to upload. Does mean I have to update those classes?.  
Got this APEX and need to 2 more line to pass.  Kinda blanking out.  Can you help what should I pass?
 
public Account lender {get; set;}
    public Account_Update__c accountUpdate {get; set;}
    
    private String accountId;
    
    public AccountFormController() {
        accountId = ApexPages.currentPage().getParameters().get('id');
        
        if(String.isBlank(accountId)) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not find account id in the parameter.'));
            return;
        }
        
        accountUpdate = new Account_Update__c();
        getAccount();
    }
    
    public void save() {
        try {
            if(accountUpdate.Account__c == null) {
                accountUpdate.Account__c = accountId;
            }
            upsert accountUpdate;
            PageReference pr = new PageReference('http://www.barringtoncapcorp.com');
            pr.setRedirect(true);
        } catch(Exception e) {
            System.debug('------------- ERROR: ' + e.getStackTraceString());
            System.debug('------------- ERROR: ' + e.getMessage());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was a problem while saving the account information.'));
            return;
        }
    }
    
    private void getAccount() {
        try {
            lender = [
                select
                    Id,
                    Name,

                from Account
                where Id = :accountId
            ];
        
            if(lender == null) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not find the account with the given id.'));
                return;
            }
                      
            
        } catch(Exception e) {
            System.debug('------------- ERROR: ' + e.getStackTraceString());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was a problem while getting the account information.' + e.getStackTraceString()));
            return;
        }
    }
    
    public String getOptions()
{
//  List<SelectOption> options = new List<SelectOption>();
String listOptions='DEFAULT+';
   Schema.DescribeFieldResult fieldResult =
        Account.Primary_Focus__c.getDescribe();
   List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

   for( Schema.PicklistEntry f : ple)
   {/*
      if(f.isDefaultValue()){
        String selectedCountry = f.getValue();break;
      */
      listOptions+=f;
      
     // }
   }       
   return listOptions;
}
}


TEst Class
@isTest
private class AccountFormControllerTest {

    private static testMethod void test() {
        Account lender = new Account();
        lender.Name = 'Test Account';
        insert lender;
        
        ApexPages.currentPage().getParameters().put('id', lender.Id);
        AccountFormController controller = new AccountFormController();
        controller.accountUpdate.Equity_Debt__c = 'Debt';
        controller.save();
    }
    
    private static testMethod void test2() {
        ApexPages.currentPage().getParameters().put('id', 'some id');
        AccountFormController controller = new AccountFormController();
        controller.save();
        
        AccountFormController controller2 = new AccountFormController();
        controller2.save();
        
        ApexPages.currentPage().getParameters().put('id', '');
        AccountFormController controller3 = new AccountFormController();
          
    }
    
    private static testMethod void test3() {
        ApexPages.currentPage().getParameters().put('id', 'some id');
        AccountFormController controller = new AccountFormController();
        controller.save();
        
        AccountFormController controller2 = new AccountFormController();
        controller2.save();
        
        ApexPages.currentPage().getParameters().put('id', '');
        AccountFormController controller3 = new AccountFormController();
          
    }
    
}

I'm currently getting an error when I try to pass     public String getOptions()  or  String listOptions='DEFAULT+';
 
Hello All,

Can you guys help me solve a problem or suggest any ideas?

Scenario:

-John Doe (contact)
-5 different users can access the contact
-Database has 5 different multi picklist field in Contact for each user so they can assign them based on group.
-Example: Adams Group, Janes Group, Mikes Group, Tonys Group, Master Group...  in contact layout
-Each group has different multipicklist information

Question 1;How can I combine all the groups into 1 field?
Fact: there's about 25 groups.  it will be hard to do it in formula

 
So I have Contacts and have Ownership Related List with columns like Prop Type.  I would like to get the list in the realted list and store them as a picklist in Contact in Prop_Type__c (picklist).  

Scenario:
Contact John Doe
Has Ownership Related List with Prop Type 1, 2, 3 & 7

Ideal scenario:
Contact John doe detail page shows 1,2,3 & 7 in Prop_Type__c (picklist)

So when I do a view list I can sort them out easily.

What will be the easiest solution for this?  I'm assuming it has to be a trigger?

thanks in advance
 
Hello

So I have a Rich Text Field (Web_Text__c) and the goal is to paste HTML codes in there, save, press a view button and it displays it as HTML.  The purpose is for the user to view how their HTML Email will look like.   Also, I have 5 fields that will attach in the HTML code so all they have to do is to edit those fields to make changes.

Any way you guys can help me on this?  Is there a path to follow? 

Kindly advise

Thanks in advance
I've been having some problems with replacing a Standard controller view with a Visualforce page following this: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_tabs.htm

The problem is, it's breaking a lot of my apex classes. For example, anything that uses:
 
ApexPages.currentPage().getParameters().get('id')

Which will throw this error:
Id value is not valid for the Property__c standard controller
Is there another way to get record ids using visualforce pages? We use these frequently

Here is one example of a code that is breaking:

   
public class ControllerCreateProposalView {
        public Id lId;
        public String convertedId;
    
        public ControllerCreateProposalView(ApexPages.StandardController stdController){
            lId = ApexPages.CurrentPage().getParameters().get('id');
            System.Debug('#######leadId:' + lId);
        }
    
    
        public PageReference convert(){
    
            
            Property__c l = [SELECT Id, name, Primary_Contact__c, Primary_Contact__r.id,Store_Number__c, Last_Sale_Date__c, Square_Footage__c, Last_Sale_Price__c, Anchor_GLA__c, CAP_Rate__c, Year_Built__c, Lot__c, Year_Renovated__c, Occupancy__c, Zoning__c, External_ID_APN__c, Number_of_Buildings__c, Number_of_Retail_Units__c, Loan_Balance__c, Maturity_Date__c, Interest_Rate__c, Term__c, Original_Lease_Term__c, Options__c, Term_Remaining_on_Lease__c, Gross_Leasable_Area__c, Type_of_Ownership__c, Parking__c, Parking_Ratio__c, Lease_Type__c, Date_Reported__c, Loan_Amount__c, Loan_Type_bcc__c, LTV__c, Lender__c, Lender_Type__c, Amortization__c, Recourse__c, Current_Interest_Rate__c, Payment__c, Prepayment__c, Proposal_date__c FROM Property__c WHERE Id=:lId LIMIT 1];
            Proposal__c c=new Proposal__c(Name=l.Name, Property__c=l.Id, Client__c=l.Primary_Contact__c, Square_Footage__c=l.Square_Footage__c, CAP_Rate__c=l.CAP_Rate__c, Lot__c=l.Lot__c, Loan_Balance__c=l.Loan_Balance__c, Maturity_Date__c=l.Maturity_Date__c, Term__c=l.Term__c, Original_Lease_Term__c=l.Original_Lease_Term__c, Options__c=l.Options__c, Term_Remaining_on_Lease__c=l.Term_Remaining_on_Lease__c, Anchor_GLA__c=l.Anchor_GLA__c, Occupancy__c=l.Occupancy__c, Number_of_Buildings__c=l.Number_of_Buildings__c, Number_of_Retail_Units__c=l.Number_of_Retail_Units__c, Gross_Leasable_Area__c=l.Gross_Leasable_Area__c, Type_of_Ownership__c=l.Type_of_Ownership__c, Parking__c=l.Parking__c,Parking_Ratio__c=l.Parking_Ratio__c, Year_Built__c=l.Year_Built__c, Lease_Type__c=l.Lease_Type__c, Date_Reported__c=l.Date_Reported__c, Loan_Amount__c=l.Loan_Amount__c, Loan_Type__c=l.Loan_Type_bcc__c, LTV__c=l.LTV__c, Lender__c=l.Lender__c, Interest_Rate__c=l.Interest_Rate__c, Lender_Type__c=l.Lender_Type__c, Amortization__c=l.Amortization__c, Recourse__c=l.Recourse__c, Current_Interest_Rate__c=l.Current_Interest_Rate__c, Payment__c=l.Payment__c, Prepayment__c=l.Prepayment__c);
            insert c;
           l.Sales_Status__c = 'Proposal';
           l.Proposal_Date__c=Date.today();
           update l;
            convertedId = c.Id;
            String cID=l.Primary_Contact__r.id;
            System.Debug('<>PROPOSAL<> :' + l );
            System.Debug('<>CEYEDEE<><>cID<><>CEYEDEE<> :' + cID );
     
            
                  //update contact stage
            List<Contact> contacts=[SELECT Id, Sales_Status__c FROM Contact WHERE id=:cID];
    System.Debug('<>LIST<><>contacts<><>LIST<> :' + contacts );
            if(contacts.size()>0){
            for(Contact i: contacts)
            {
    if(i.Sales_Status__c=='Unconfirmed'||i.Sales_Status__c==NULL){
            i.Sales_Status__c='Proposal';
            update i;
            }
            
    }
    }
            
            
            
            
    
            String sServerName = ApexPages.currentPage().getHeaders().get('Host');
            sServerName = 'https://'+sServerName+'/';
            System.Debug('#######sServerName :' + sServerName );
            String editName='/e?retURL=%2F'+convertedId;
            PageReference retPage = new PageReference(sServerName + convertedId+editName);
            System.Debug('#######retPage :' + retPage );
            retPage.setRedirect(true);
    
    
            return retPage;
        }
        public PageReference back(){
                String sServerName = ApexPages.currentPage().getHeaders().get('Host');
            sServerName = 'https://'+sServerName+'/';
            System.Debug('#######sServerName :' + sServerName );
            PageReference retPage = new PageReference(sServerName + lId);
            System.Debug('#######retPage :' + retPage );
            retPage.setRedirect(true);
            
            return retPage;
        }      
    }

Are there any alternatives to
ApexPages.currentPage().getParameters().get('id')
I have this script but doesnt seem to work.  The purpose is to be able to click on the link and open in a NEW tab or load in the same page but NOT inside the iframe.

I am not looking for an "Outputlink" solution. Can anyone help?
 
<apex:page standardController="Proposal__c" showHeader="false" sidebar="false" extensions="ProposalExtensionController">
<script>
  document.getElementById('{!Proposal__c.Broker_Relationship__c}').target = "_blank";
</script>

<apex:tabPanel switchType="server" selectedTab="Proposal__c" id="AccountTabPanel"
    tabClass="activeTab" inactiveTabClass="inactiveTab" styleClass="openInPopup">
    <apex:tab label="Proposal Information" name="name1" id="Proposal">
 <apex:form>
 <apex:pageBlock>
 <apex:pageBlockSection>
 <apex:inlineEditSupport event="ondblClick"/>
    <apex:pageBlockSectionItem >
    <apex:outputLabel value="Broker Relationship" for="Proposal__c.Broker_Relationship__c" style="font-weight:bold" />
    <apex:outputField value="{!Proposal__c.Broker_Relationship__c}" id="Broker_Relationship__c"/>
    </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
    </apex:tab>
    </apex:tabpanel>
</apex:page>


currently, its loading inside the iframe.  thanks
 


I have a visualforce page that is a lookup field value.  Works great and blends with the visualforce page.  

VF Field:
User-added image

VF Code:

<apex:pageBlockSectionItem>
<apex:outputLabel value="Relationship" for="Proposal__c.Relationship__c" style="font-weight:bold"/>
<apex:outputField value="{!Proposal__c.Relationship__c}" id="Proposal"/>
</apex:pageBlockSectionItem>


The problem I'm having is when I click on the link it opens inside that iFrame.  How can I solve the issue without using a Outputlink? And let it load a new page or a new tab.  I can use an output link because I need ti be able to modify that field data.

Error:
User-added image

Thanks you guys


My previous request worked using commandbutton save in a custom object.  And it's working just fine.  But using that command in a Standard object doesnt work.  Instead, it reloads the record inside the iFrame and does not save the data.  Is there a difference on them?  How can i fix this?

VISUALFORCE PAGE

<apex:pageBlockButtons >
        <apex:commandButton action="{!Save}" value="Save"/>
        </apex:pageBlockButtons>
 
<apex:page standardController="Contact" showHeader="false" sidebar="false" extensions="ContactExtensionController">
    <!-- Define Tab panel .css styles -->
    <style>
    .activeTab {background-color: #081f3f; color:white; background-image:none}
    .inactiveTab { background-color: lightgrey; color:black; background-image:none}
    </style>
    

    <!-- Create Tab panel -->
   
    <apex:tabPanel switchType="client" selectedTab="Contact" id="ContacttabPanel"
        tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="Contact Information" name="name" id="Contact">
        <apex:form > 
        <apex:pageBlock >
        <apex:pageblocksection > 

          
    <apex:outputText style="font-size:20px;text-align:left;color:{!IF(Contact.Sales_Status__c = 'Proposal'||Contact.Sales_Status__c='Listing'||Contact.Sales_Status__c='Escrow'||Contact.Sales_Status__c='Sales Comp', 'red', '#081f3f')};" value="{0} | {1}"> 
<apex:param value="{!Contact.Name}"/>
<apex:param value="{!Contact.Sales_Status__c}" />
</apex:outputText>
</apex:pageblocksection>

        <apex:pageBlockButtons >
        <apex:commandLink value="Save" action="{!save}" target="_parent" styleClass="btn" style="text-decoration:none;padding:4px;"></apex:commandlink>
        </apex:pageBlockButtons> 

           <apex:pageBlockSection columns="2">
                <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                <apex:pageBlockSectionItem >
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                </apex:pageBlockSectionItem>

                 
                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Company Name" for="Contact.Account" style="font-weight:bold"/>
        <a href="/{!Contact.Account}" target="_blank">{!Contact.Account.name}</a>
                </apex:pageBlockSectionItem>
                
         

                                                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Parent Company" for="Contact.Parent_Company__c" style="font-weight:bold"/>
                    <apex:outputField value="{!Contact.Parent_Company__c}" id="Contact"/>  
                </apex:pageBlockSectionItem>
             
              

                
                                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Confirmed Owner" for="Contact.Confirmed_Owner__c" style="font-weight:bold"/>
                    <apex:outputField value="{!Contact.Confirmed_Owner__c}" id="Contact"/>  
                </apex:pageBlockSectionItem>
  </apex:pageBlock>
  </div>
   </apex:page>
   </apex:tab>     
    </apex:tabPanel>
   
</apex:page>

CONTROLLER
 
public class ContactExtensionController{
    Contact Contact;
  //  public String currentUser = UserInfo.getUserId();
    
    public ContactExtensionController(ApexPages.StandardController controller)
    {
        Contact = (Contact)controller.getRecord();
    }
    
    public PageReference save()
    {
        update Contact;
        return null;
    }
}




Shout  out to Mahesh D for helping me out earlier.

I have this Save Button code.

<apex:pageBlockButtons >
        <apex:commandLink value="Save" action="{!save}" id="savebutton" styleClass="btn" style="text-decoration:none;padding:4px;"></apex:commandlink>
        </apex:pageBlockButtons>

I have a lot of issues and bugs on "Saving" data in my visualforce page.  And was wondering if you guys can shed some light on how to fix it.  It's been bugging me and becoming a show stopper in my development.

Problems when pressing "Save"
Problem 1 - If I enter data in a text field and press "Save", it reloads but doesnt save the data.  But when I enter data in a text field AND click out and save... it saves it.  I cant have that.  I'm getting complaints on that.  Especially when they keep entering data then just presses save and it doesnt save the last data get really annoying.  

Problem 2 - when putting Target="_self" it saves it inside that iFrame.  If I do Target="_parent" it saves it but just showing the VF Page and I lose my headers, search, etc...  I just want to press save and stay in the SAME tab.  Instead, it reloads in the first tab and you get more mad when you click on the tab you want and the data doesnt save.

I just want to save the data and refresh in the same tab.  Thats all I need.  Please help 

I have this APEX Class but it's not passing.  Can you tell me why?

public class PQ_Update {
    public static void PQ_Update(List<ProdQueue__c> pq){ 
         List<Listing__c> ls= new list<Listing__c>();
        for(ProdQueue__c i : pq){
            ls.add(i.Listing__r);
            for (Listing__c l : ls){
                l.Production_Status__c=i.Status__c;
                l.OM_Approve__c=i.OM_Approve__c;
                l.Producer__c=i.Producer__c;
                update l;
            }
        }
        
    }
}



APEX @test

@isTest
public class PQ_UpdateTEST {
    public static testMethod void PQ_Update(){
        Listing__c l=new Listing__c();
        insert l;
        ProdQueue__c pq=new ProdQueue__c(Listing__c=l.id,Status__c='On-Market',OM_Approve__c='Yes',Producer__c='Brian');
    insert pq;
  
    }
}
Help on a formula to get the web url of a lookup value.

Example:
Contact Lookup = John Doe
URL Field= https://na16.salesforce.com/003FSV234233AAW

How can I achieve this?

Thanks

 
Hello All,

Can you guys help me solve a problem or suggest any ideas?

Scenario:

-John Doe (contact)
-5 different users can access the contact
-Database has 5 different multi picklist field in Contact for each user so they can assign them based on group.
-Example: Adams Group, Janes Group, Mikes Group, Tonys Group, Master Group...  in contact layout
-Each group has different multipicklist information

Question 1;How can I combine all the groups into 1 field?
Fact: there's about 25 groups.  it will be hard to do it in formula

 
My goal is to separate the section of the record and separate them by tabs.  I understand that you have to use <apex:inputfield> for each field if you want them to show in your tab and also I need them to be editable using inlineEdit="true" I dont understand why I'm getting unsupported attribute relatedlist.  I have to remove Relatedlist & InlineEdit for it to function but when I look at the preview its just a box...

Thoughts?

Thanks in advance and Happy Holidays



<apex:page standardController="Property__c" showHeader="true" sidebar="false">
    <!-- Define Tab panel .css styles -->
    <style>
    .activeTab {background-color: #081f3f; color:white; background-image:none}
    .inactiveTab { background-color: lightgrey; color:black; background-image:none}
    </style>

    <!-- Create Tab panel -->
    <apex:tabPanel switchType="client" selectedTab="Property__c" id="AccountTabPanel"
        tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="Property Information" name="name1" id="tabOne">content for tab one</apex:tab>
        <apex:form>
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
            <apex:inputField value="{!Property__c.Name}" relatedList="false" inlineEdit="true"/>
            <apex:inputField value="{!Property__c.Address}" relatedList="false" inlineEdit="true"/>
            <apex:inputField value="{!Property__c.City}" relatedList="false" inlineEdit="true"/> 
       </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
              
        <apex:tab label="Building Information" name="name2" id="tabTwo">content for tab two</apex:tab>
        <apex:tab label="Financial Information" name="name3" id="tabThree">content for tab two</apex:tab>
        <apex:tab label="Loan Information" name="name4" id="tabFour">content for tab two</apex:tab>
    </apex:tabPanel>
</apex:page>


So again, the goal is to have fields in each tabs and have the capability to edit.

Thanks
 
Help on passing test class.  I just need 5 lines more.  it's at 67%  The class is long I only added what's red and not passing.
 
public void send() {
        try {
            DM_Public_Page_URL__c siteCS = DM_Public_Page_URL__c.getValues('Default');
            String siteURL = siteCS.Site_URL__c;
            String logo = siteCS.Logo__c;
            
            List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
            EmailTemplate emailT = [select Subject, HtmlValue from EmailTemplate where DeveloperName = 'Contact_Form' limit 1];
            
            for(Contact primaryContact : primaryContactList) {
                String body = emailT.HtmlValue.replace('{account_form}', siteURL + '/apex/AccountFormPage?id=' + accountId);
                body = body.replace('{primary_contact_name}', primaryContact.FirstName);
                body = body.replace('{account_name}', accountName);
               body = body.replace('{account_logo}', '<img src="'+siteURL + Logo+'"alt="Logo" height="225px" width="74px"');
                
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setToAddresses(new String[]{primaryContact.Email});
                mail.setSubject(emailT.Subject);
                mail.setHtmlBody(body);
                mails.add(mail);
            }
            
            List<Messaging.SendEmailResult> results = Messaging.sendEmail(mails);
            if(results[0].isSuccess()) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Contact email successfully sent'));
            } else {
                System.debug('------------------- errors: ' + results[0].getErrors());
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while sending the contact update email: ' + results[0].getErrors()));
            }
        } catch(Exception e) {
            System.debug('------------------- ERROR: ' + e.getStackTraceString());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while sending the contact update email: ' + e.getStackTraceString()));
            
        }
    }
    
    public PageReference cancel() {
        PageReference pref = new PageReference('/' + accountId);
        return pref;
    }
}


This is my test class

@isTest
private class AccountFormControllerTest {

    private static testMethod void test() {
        Account lender = new Account();
        lender.Name = 'Test Account';
        insert lender;
        System.debug('created account');
        
        Contact c = new contact();
        c.FirstName = 'JOhn';
        c.LastName = 'Doe';
        c.email='test@test.com';
        c.primary_contact__c = True;
        insert c;
        System.debug('created account');
                
        ApexPages.currentPage().getParameters().put('id', lender.Id);
        AccountFormController controller = new AccountFormController();
        controller.accountUpdate.Equity_Debt__c = 'Debt';
        controller.save();
        
        string options = controller.getOptions();
    }
    
    private static testMethod void test2() {
        Contact ca = new Contact();
            ca.FirstName = 'John';
            ca.LastName = 'Doe';
            ca.email='test@test.com';
            ca.Primary_Contact__c = true;
    
        ApexPages.currentPage().getParameters().put('id', 'some id');
        AccountFormController controller = new AccountFormController();
        controller.save();
        
        AccountFormController controller2 = new AccountFormController();
        controller2.save();
        
        ApexPages.currentPage().getParameters().put('id', '');
        AccountFormController controller3 = new AccountFormController();
        controller3.save();
        
        try{
        Insert ca;
        }
        catch(Exception ee){
        }   
    }
    
}
This is whats not passing...
 
String body = emailT.HtmlValue.replace('{account_form}', siteURL + '/apex/AccountFormPage?id=' + accountId);
                body = body.replace('{primary_contact_name}', primaryContact.FirstName);
                body = body.replace('{account_name}', accountName);
               body = body.replace('{account_logo}', '<img src="'+siteURL + Logo+'"alt="Logo" height="225px" width="74px"');
                
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setToAddresses(new String[]{primaryContact.Email});
                mail.setSubject(emailT.Subject);
                mail.setHtmlBody(body);
                mails.add(mail);
            }

 

I'm 68% to pass my trigger and close to getting 75% .  i just need a few more lines to pass. can anyone guide me for this to pass?

Here is the trigger
 

Trigger PrimaryContact on Contact (Before Insert, Before Update, 
                                   After Insert, After Update, After Delete, After UnDelete) {
    
     List<Id> actIds = New List<Id>();
     List<Contact> comingCons = New List<Contact>();
     List<Id> conIds = New List<Id>();
     
     If(Trigger.IsBefore && (Trigger.IsInsert || Trigger.IsUpdate))
     {
         For(Contact Con : Trigger.New)
         {
             If(Con.Primary_Contact__c == TRUE)
             {
                actIds.add(Con.AccountId);
                conIds.add(Con.Id);
                comingCons.add(Con);
             }
             
         }
     }
     
     List<Account> allRelatedAccounts = [Select Id, (Select Id, Primary_Contact__c 
                                                     FROM Contacts WHERE Primary_Contact__c = TRUE AND Id !=: conIds)
                                                        FROM Account WHERE Id =: actIds];
     
     
     For(Contact EveryCon : comingCons)
     {
         For(Account EveryAccount : allRelatedAccounts){
             If(EveryCon.AccountId == EveryAccount.Id && EveryAccount.Contacts.size() > 0){
                 EveryCon.addError('There is already a primary contact for this account');
             }
         }
     }                                  
                                       
     
                                   
    List<Id> accountIds = New List<Id>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUnDelete){
        For(Contact Con : Trigger.New){
            If(Con.AccountId != NULL){
                accountIds.add(Con.AccountId);
            }
        }
    }
    If(Trigger.IsDelete){
        For(Contact Con : Trigger.Old){
            If(Con.AccountId != NULL){
                accountIds.add(Con.AccountId);
            }
        }
    }
    
    List<Account> actFinalListToUpdte = New List<Account>();
    
    
    For(Account act : [Select ID, Contact2__c,
                            (Select Id, FirstName, LastName,
                                    Primary_Contact__c FROM Contacts WHERE Primary_Contact__c = TRUE LIMIT 1)
                                FROM Account WHERE Id =: accountIds])
    {
        If(act.Contacts.size() > 0)
        {
            act.Contact2__c = act.Contacts[0].Id;
            actFinalListToUpdte.add(act);
        }
            
    }
    
    try{
        If(!actFinalListToUpdte.isEmpty()){
            update actFinalListToUpdte;
        }
    }Catch(Exception e){
        system.debug('Thrown Exception for PrimaryContact is: ' + e.getMessage());
    }
}
 

This are the line not passing
 

For(Contact EveryCon : comingCons)
     {
         For(Account EveryAccount : allRelatedAccounts){
             If(EveryCon.AccountId == EveryAccount.Id && EveryAccount.Contacts.size() > 0){
                 EveryCon.addError('There is already a primary contact for this account');
             }
         }
     }     


    If(Trigger.IsDelete){
        For(Contact Con : Trigger.Old){
            If(Con.AccountId != NULL){
                accountIds.add(Con.AccountId);
            }
        }
    }

    For(Account act : [Select ID, Contact2__c,
                            (Select Id, FirstName, LastName,
                                    Primary_Contact__c FROM Contacts WHERE Primary_Contact__c = TRUE LIMIT 1)
                                FROM Account WHERE Id =: accountIds])
    {
        If(act.Contacts.size() > 0)
        {
            act.Contact2__c = act.Contacts[0].Id;
            actFinalListToUpdte.add(act);
        }
            
    }
 

This is the test class and its 68%
 

@isTest
public class PrimaryContactTest {
    
    static testMethod void createAccount(){
        
    Account a = new Account();
        a.Name = 'test Co.';
        insert a;
        System.debug('created account');
           
    Contact c = new Contact();
        c.FirstName = 'John';
        c.LastName = 'Doe';
        c.Primary_Contact__c = True;
        Insert c;
        System.debug('Insert primary contact');
        
    Contact ca = new Contact();
        ca.FirstName = 'John';
        ca.LastName = 'Doe';
        ca.Primary_Contact__c = False;
        Insert ca;
        System.debug('Insert primary contact');
        
        
    Update a;    
}
}
I have this button that will acces a public void send.  It will send an email which is great.  however, I would it to date stamp letter_date__c field in the account object everytime I send an email or press the send button.  It should constantly overwrite the field. Any ideas?
 
public void send() {
        try {
            DM_Public_Page_URL__c siteCS = DM_Public_Page_URL__c.getValues('Default');
            String siteURL = siteCS.Site_URL__c;
 
            List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
            EmailTemplate emailT = [select Subject, HtmlValue from EmailTemplate whereDeveloperName = 'Millenial_Form' limit 1];
             
            for(Contact primaryContact : primaryContactList) {
                String body = emailT.HtmlValue.replace('{account_form}', siteURL + '/apex/AgeMillenial?id=' + accountId);
                body = body.replace('{primary_contact_name}', primaryContact.FirstName);
                body = body.replace('{account_name}', accountName);
                 
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setToAddresses(new String[]{primaryContact.Email});
                mail.setSubject(emailT.Subject);
                mail.setHtmlBody(body);
                mails.add(mail);
            }
             
            List<Messaging.SendEmailResult> results = Messaging.sendEmail(mails);
            if(results[0].isSuccess()) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Mail Sent'));
            } else {
                System.debug('------------------- errors: ' + results[0].getErrors());
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Mail Issue.  There's no email: ' + results[0].getErrors()));
            }
        } catch(Exception e) {
            System.debug('------------------- ERROR: ' + e.getStackTraceString());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Mail Issue.  There's no email: ' + e.getStackTraceString()));
             
        }
 }


Thanks
Using this Apex Trigger, how can I add or show the primary contact in the Account object.  I know it can be shown using the contact related list but I would like it to show on the detail page instead as a lookup so users can just click on the contact link instead of looking for the primary contact in the related list.

Here's the code 
trigger PrimaryContact on Contact (before insert, before update) {
  
   set<id> getid = new set<id>();
    string contactId;
    List<Contact> conList = new List<Contact>();
  
    // Trigger Functionality
    if(Trigger.isInsert || Trigger.isUpdate) {
      
        for(Contact cont: Trigger.New) {
          
            if(cont.Primary_Contact__c == true) {
              
                getid.add(cont.AccountId);
                contactId = cont.id;
            }
        }
    }
  
    // Fetching the other Contact which has primary contact checked
    List<contact> cList = [select id, Primary_Contact__c from contact where accountid IN: getid AND Primary_Contact__c = true];
  
    // Unchecking the already checked primary contact
    if(cList.size() > 0) {
      
        for(Contact newClst: cList) {
          
            if(newClst.id != contactId) {
              
                newClst.Primary_Contact__c = false;
                conList .add(newClst);
            }
        }
    } 
    update conList; 
  }
Thanks in advance
 

So I've been tinkering on this and wondering if you guys can guide me.  All my fields update on but the Account information portion doesn't.  Like the name and number.  The goal is simple update the phone then the account updates.  Any clue?

Here is my VF.

<apex:page controller="AccountFormController" sidebar="false" showHeader="true" id="pg">
         
     <apex:pageBlock mode="maindetail">
       
         <apex:form id="form" styleClass="form-horizontal">
             <div class="panel panel-default">
                <apex:pageBlockSection columns="1">
                <div class="panel-heading"><h4>Company Information</h4> 
             </div>
         </apex:pageBlockSection>


     <apex:pageBlockSection columns="2">
               
         <apex:pageBlockSectionItem HelpText="{!$ObjectType.Account.fields.Name.inlineHelpText}" >
             <apex:outputLabel value="Name" for="{!lender.Name}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
             <apex:inputField value="{!lender.Name}" style="width:85%;" />   
         </apex:pageBlockSectionItem>     
                          
         <apex:pageBlockSectionItem HelpText="{!$ObjectType.Account.fields.Phone.inlineHelpText}">
             <apex:outputLabel value="Phone" for="{!lender.Phone}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;     font-size: 14px;"/>
             <apex:inputField value="{!lender.Phone}" style="width:85%;" />      
         </apex:pageBlockSectionItem> 

     
     </apex:pageBlockSection>
     
     </div>

         </apex:pageBlockSection>
                
            <apex:pageBlockSection columns="1">    
                
                    <apex:pageBlockSectionItem HelpText="{!$ObjectType.Account_Update__c.fields.Primary_Focus__c.inlineHelpText}">
                        <apex:outputLabel value="Primary Focus" for="{!accountUpdate.Primary_Focus__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
                        <apex:inputField value="{!accountUpdate.Primary_Focus__c}" style="width:100%;"/>   
                    </apex:pageBlockSectionItem>


                </apex:pageBlockSection>

                

                <apex:commandButton value="Update" action="{!save}" styleClass="btn pull-right" />

            </apex:form>


        
        <div class="modal fade" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-body">
                        <h3>Processing...</h3><br/>
                        <div class="progress">
                            <div class="progress-bar progress-bar-striped active" role="progressbar"
                            aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:100%">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--
        <div>{!Options}</div>-->
    </apex:pageBlock>

    </body>
                           <!-- </apex:pageBlock>-->
</div>
</apex:page>



Here is my APEX

 

public class AccountFormController {
    
    public Account lender {get; set;}
    public Account_Update__c accountUpdate {get; set;}
    
    private String accountId;
    
    public AccountFormController() {
        accountId = ApexPages.currentPage().getParameters().get('id');
        
        if(String.isBlank(accountId)) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not find account id in the parameter.'));
            return;
        }
        
        accountUpdate = new Account_Update__c();
        getAccount();
    }

    public PageReference save() {   //***************************NOTE: Save Code works.  it's just too long************************  

   }
}       

************ This is where I'm lost******************

private void getAccount() {
        try {
            lender = [
                select
                    Id,
                    Name,
                    Phone,
                    Primary_Focus__c,

                from Account
                where Id = :accountId
            ];
        
            if(lender == null) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not find the account with the given id.'));
                return;
            }
            
             accountUpdate.Phone__c = lender.Phone;
             accountUpdate.Primary_Focus__c = lender.Primary_Focus__c;

            
            
            
        } catch(Exception e) {
            System.debug('------------- ERROR: ' + e.getStackTraceString());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was a problem while getting the account information.' + e.getStackTraceString()));
            return;
        }
    }

The update should update the ACcount object. Also tried using Phone__c but says field doesn't exist.  If I update the Primary focus it updates just fine.  Thanks in advance
I'm trying to align my Input picklist fields and making all the box the same size.  I'm blanking out. Wondering what I am missing.  I already tried floater, align right... no luck.  Any guidance is appreciated.  Also, I find it weird that my VFpage only shows 3 lines of data in Primary focus vs lending footprint.  Where the visible llines I inputed was 10... weird.
 
<apex:pageBlockSection columns="2">    
                
    <apex:pageBlockSectionItem HelpText="!$ObjectType.Account_Update__c.fields.Primary_Focus__c.inlineHelpText}">
        <apex:outputLabel value="Primary Focus" for="{!accountUpdate.Primary_Focus__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
        <apex:inputField value="{!accountUpdate.Primary_Focus__c}" styleClass="col-md-8" style="width:85%;"/>   
    </apex:pageBlockSectionItem>
                    
    <apex:pageBlockSectionItem HelpText="!$ObjectType.Account_Update__c.fields.Lending_Footprint__c.inlineHelpText}">
        <apex:outputLabel value="Lending Footprint" for="{!accountUpdate.Lending_Footprint__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
        <apex:inputField value="{!accountUpdate.Lending_Footprint__c}" styleClass="col-md-8" style="width:100%;"/>   
    </apex:pageBlockSectionItem>
                    
    <apex:pageBlockSectionItem HelpText="!$ObjectType.Account_Update__c.fields.Min_Project_Deal_Size_txt__c.inlineHelpText}">
        <apex:outputLabel value="Min Loan Size" for="{!accountUpdate.Min_Project_Deal_Size_txt__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
        <apex:inputField value="{!accountUpdate.Min_Project_Deal_Size_txt__c}" styleClass="col-md-8" style="width:100%;"/>   
    </apex:pageBlockSectionItem>
                    
    <apex:pageBlockSectionItem HelpText="{!$ObjectType.Account_Update__c.fields.Max_Project_Deal_Size_txt__c.inlineHelpText}">
        <apex:outputLabel value="Max Loan Size" for="{!accountUpdate.Max_Project_Deal_Size_txt__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;  font-size: 14px;"/>
        <apex:inputField value="{!accountUpdate.Max_Project_Deal_Size_txt__c}" styleClass="col-md-8" style="width:100%;"/>   
    </apex:pageBlockSectionItem>
                    
    <apex:pageBlockSectionItem HelpText="{!$ObjectType.Account_Update__c.fields.Loan_Term__c.inlineHelpText}">
        <apex:outputLabel value="Loan Term" for="{!accountUpdate.Loan_Term__c}" style="font-weight:bold;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px;"/>
        <apex:inputField value="{!accountUpdate.Loan_Term__c}" styleClass="col-md-6" style="width:100%;"/>   
    </apex:pageBlockSectionItem>
User-added image
 
Hello,

We tried to use Avaya CTI, but we are facing an issue : users cannot log on the softphone fields are grey and they can't fill the log in fieds see screenshot.
User-added image
Do you have an idea how we can solve this issue?

Thanks in advance.
  • February 06, 2018
  • Like
  • 0
I downloaded Salesorce on my android phone. My production credentials work. However, when I try to log in my selecting "Change Server" and picking Sandbox from the menu, I get Incorrect Password error when I enter my Production credentials.I am completely new to Salesforce. Can someone please help?

Thanks!

My redirect button is not working.  Not sure why or where I'm missing the code.  Can anyone help?  The goal is when it updates I want it to go to a webpage.

This is my button

<apex:commandButton value="Update" action="{!save}" styleClass="btn pull-right" onclick="$j('#pleaseWaitDialog').modal('show')" oncomplete="$j('#pleaseWaitDialog').modal('hide')"/>
<div class="modal fade" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-body">
                        <h3>Processing...</h3><br/>
                        <div class="progress">
                            <div class="progress-bar progress-bar-striped active" role="progressbar"
                            aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:100%">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
 

 


This is my APEX
public void save() {
        try {
            if(accountUpdate.Account__c == null) {
                accountUpdate.Account__c = accountId;
            }
            upsert accountUpdate;
            PageReference reRend = new PageReference('GOOGLE.COM');
        reRend.setRedirect(true);
        } catch(Exception e) {
            System.debug('------------- ERROR: ' + e.getStackTraceString());
            System.debug('------------- ERROR: ' + e.getMessage());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was a problem while saving the account information.'));
            return;
        }
    }


Thanks
When I uploaded an APEX & Test Class at 94% completed it failed the validation in the inbound change set and gave me 3 apex test failures.  They're mainly test classes and completely irrelevant to what I need to upload. Does mean I have to update those classes?.  
Got this APEX and need to 2 more line to pass.  Kinda blanking out.  Can you help what should I pass?
 
public Account lender {get; set;}
    public Account_Update__c accountUpdate {get; set;}
    
    private String accountId;
    
    public AccountFormController() {
        accountId = ApexPages.currentPage().getParameters().get('id');
        
        if(String.isBlank(accountId)) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not find account id in the parameter.'));
            return;
        }
        
        accountUpdate = new Account_Update__c();
        getAccount();
    }
    
    public void save() {
        try {
            if(accountUpdate.Account__c == null) {
                accountUpdate.Account__c = accountId;
            }
            upsert accountUpdate;
            PageReference pr = new PageReference('http://www.barringtoncapcorp.com');
            pr.setRedirect(true);
        } catch(Exception e) {
            System.debug('------------- ERROR: ' + e.getStackTraceString());
            System.debug('------------- ERROR: ' + e.getMessage());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was a problem while saving the account information.'));
            return;
        }
    }
    
    private void getAccount() {
        try {
            lender = [
                select
                    Id,
                    Name,

                from Account
                where Id = :accountId
            ];
        
            if(lender == null) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Could not find the account with the given id.'));
                return;
            }
                      
            
        } catch(Exception e) {
            System.debug('------------- ERROR: ' + e.getStackTraceString());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'There was a problem while getting the account information.' + e.getStackTraceString()));
            return;
        }
    }
    
    public String getOptions()
{
//  List<SelectOption> options = new List<SelectOption>();
String listOptions='DEFAULT+';
   Schema.DescribeFieldResult fieldResult =
        Account.Primary_Focus__c.getDescribe();
   List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

   for( Schema.PicklistEntry f : ple)
   {/*
      if(f.isDefaultValue()){
        String selectedCountry = f.getValue();break;
      */
      listOptions+=f;
      
     // }
   }       
   return listOptions;
}
}


TEst Class
@isTest
private class AccountFormControllerTest {

    private static testMethod void test() {
        Account lender = new Account();
        lender.Name = 'Test Account';
        insert lender;
        
        ApexPages.currentPage().getParameters().put('id', lender.Id);
        AccountFormController controller = new AccountFormController();
        controller.accountUpdate.Equity_Debt__c = 'Debt';
        controller.save();
    }
    
    private static testMethod void test2() {
        ApexPages.currentPage().getParameters().put('id', 'some id');
        AccountFormController controller = new AccountFormController();
        controller.save();
        
        AccountFormController controller2 = new AccountFormController();
        controller2.save();
        
        ApexPages.currentPage().getParameters().put('id', '');
        AccountFormController controller3 = new AccountFormController();
          
    }
    
    private static testMethod void test3() {
        ApexPages.currentPage().getParameters().put('id', 'some id');
        AccountFormController controller = new AccountFormController();
        controller.save();
        
        AccountFormController controller2 = new AccountFormController();
        controller2.save();
        
        ApexPages.currentPage().getParameters().put('id', '');
        AccountFormController controller3 = new AccountFormController();
          
    }
    
}

I'm currently getting an error when I try to pass     public String getOptions()  or  String listOptions='DEFAULT+';
 
Hello All,

Can you guys help me solve a problem or suggest any ideas?

Scenario:

-John Doe (contact)
-5 different users can access the contact
-Database has 5 different multi picklist field in Contact for each user so they can assign them based on group.
-Example: Adams Group, Janes Group, Mikes Group, Tonys Group, Master Group...  in contact layout
-Each group has different multipicklist information

Question 1;How can I combine all the groups into 1 field?
Fact: there's about 25 groups.  it will be hard to do it in formula

 

In my visualforce page, I have an array:

var availableTags = [
			"ActionScript",
			"AppleScript",
			"Asp",
			"BASIC",
			"C",
			"C++",
			"Clojure",
			"COBOL",
			"ColdFusion",
			"Erlang",
			"Fortran",
			"Groovy",
			"Haskell",
			"Java",
			"JavaScript",
			"Lisp",
			"Perl",
			"PHP",
			"Python",
			"Ruby",
			"Scala",
			"Scheme"
		];
		

 How can I populate this array with data from salesforce?

 

 

I read on the boards that this would work:

availableTags = "{!designations}";

 But it doesnt work. My data is not getting into the javascript array.

I tried this with the repeat tag as mentioned Here

but still no good.

 

Shouldn't this be simple?

 

 

Is it possible to pass a <list> from apex into javascript as array in VF page?

  • January 13, 2011
  • Like
  • 0