• Samyra Chrisp 18
  • NEWBIE
  • 0 Points
  • Member since 2016
  • All Covered

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 3
    Replies
We have been testing Salesforce in a personal development org, and decided to purchase Salesforce.

Is there a way to transfer the setup configurations we did in the developer org to our new Salesforce org?
I don't even know if I'm asking this question correctly.  But I've been asked to revise some code so that when a new Deal is created we also add the team members - another custom object related to the Deal.  This creates the new Deal, but it fails to create the relationship between the team member object and the Deal.  The original class creates an Account/ Deal / Adds Financials / Adds team members simultaneously.

 
Instead of creating a new account, I need to be able to
1) click on the ADD NEW Deal button, and 2) create a new deal that is related to the proper account - and I'm doing that and then 3) add the team members to the new deal, but I'm not doing that.  Somehow I need to get the deal ID into the field

VisualForce Page
<apex:page StandardController="Investment__c" extensions="clsQuickAddController2" tabStyle="Investment__c">
    <apex:sectionHeader title="Deal Entry" subtitle="Add a new Deal."/>
   
    <apex:form id="quickdeal" >
        <apex:pageBlock title="New Deal">
  
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!Save}"/>
            </apex:pageBlockButtons>
            <apex:messages id="errMessage"/>
            <apex:pageBlockSection title="Company Details" columns="2">
                  <apex:OutputField value="{!Investment__c.Target_Company__c}"/>
            </apex:pageBlockSection>
               
            <apex:pageBlockSection id="dealinfo" title="Deal Details" columns="2">
                <apex:inputField value="{!Investment__c.Name}"/>
                <apex:inputField value="{!Investment__c.CCI_Deal_Type__c}"/>
                <apex:outputLabel ></apex:outputLabel> 
                <apex:inputField value="{!Investment__c.CCI_Add_On__c}"/>
                <apex:InputField value="{!Investment__c.Source__c}"/>
                <apex:InputField value="{!Investment__c.Source_Sub_Type__c}"/>
                <apex:inputField value="{!Investment__c.Source_Name__c}"/>
                <apex:inputField value="{!Investment__c.cci_Internal_Source__c}"/>
                <apex:inputField value="{!Investment__c.Pipeline_Comments__c}"/>
                <apex:inputField value="{!Investment__c.Source_Notes__c}"/>
                <apex:inputField value="{!Investment__c.IOI_Due_date__c}"/>
             <apex:pageBlockSectionItem id="POD">
                    <apex:outputLabel value="POD" for="POD"/>
                    <apex:outputPanel >
                       <apex:outputPanel ><apex:OutputLabel value="TB" for="TB"> <apex:inputField value="{!Investment__c.Pod_TB__c}"/></apex:outputLabel> </apex:outputPanel>
                      <apex:outputPanel ><apex:OutputLabel value="RP" for="RP"> <apex:inputField value="{!Investment__c.Pod_RP__c}"/></apex:outputLabel> </apex:outputPanel>
                      <apex:outputPanel ><apex:OutputLabel value="JK" for="JK"> <apex:inputField value="{!Investment__c.Pod_JK__c}"/></apex:outputLabel> </apex:outputPanel>  
                      <apex:outputPanel ><apex:OutputLabel value="EU" for="EU"> <apex:inputField value="{!Investment__c.Pod_EU__c}"/></apex:outputLabel> </apex:outputPanel>
                      <apex:outputPanel ><apex:OutputLabel value="LATAM" for="LATAM"> <apex:inputField value="{!Investment__c.Pod_LATAM__c}"/></apex:outputLabel> </apex:outputPanel>
                    </apex:outputPanel>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>       
            <apex:pageBlockSection title="Potential Team Members"  >
                <apex:pageblockTable id="UserList" value="{!Users}" var="usr" columns="5">        
                    <apex:column style="text-align: left;vertical-align:middle;">
                        <apex:facet name="header">Select</apex:facet>
                        <apex:inputCheckbox value="{!usr.selected}"/>
                    </apex:column>
                    <apex:column style="text-align: left;vertical-align:middle;">
                        <apex:facet name="header">Name</apex:facet>
                        <a href="/{!usr.user.Id}">{!usr.user.Name}</a>
                    </apex:column>
                    <apex:column style="text-align: left;vertical-align:middle;">
                        <apex:facet name="header">Title</apex:facet>
                        <apex:outputField value="{!usr.user.Title}"/>
                    </apex:column>
                </apex:pageblockTable>
            </apex:pageBlockSection>

        </apex:pageBlock>
        
    </apex:form>
 
</apex:page>



Class
public class clsQuickAddController2 {

    public clsQuickAddController2(ApexPages.StandardController controller) {

    }


 //   Account newAcct;                        
 //   Contact newCon;
//    Opportunity newOpp;         
//    OpportunityContactRole newRole;         
   Investment__c newDeal;
   String companyName;
   String dtype;
   String status = 'Lead';
   String subsource;
   String dealType = 'Private Equity Deal';
   String source = 'Proprietary';
    Country_Configuration__c config;
    public List<TeamMember> members = new List<TeamMember>();
    Id currDealId;
    Id currDealCoId;
    Map<Id, Boolean> currMembers = new Map<Id, Boolean>(); 
   Id parentAccountId;
 //   String currAccountName;
//    List<Financial_Data__c> currData = new List<Financial_Data__c>();
    
    
    public clsQuickAddController2() {
        //Initialize objects
  //      newAcct = new Account();
  //      newAcct.RecordTypeId = clsAccelUtil.getDealCoRecordTypeId();
 //       newCon = new Contact();
  //      newOpp = new Opportunity();
  //      newRole = new OpportunityContactRole();
        newDeal = new Investment__c();
 /*      
        //Financial
        try {
        
            parentAccountId = ApexPages.currentPage().getParameters().get('accountid');
            currAccountName = [SELECT Id, Name from Account where Id = :parentAccountId].Name;
            
            for (Financial_Data__c dat : [SELECT Id, CCI_Revenue_MM__c, CCI_EBITDA_MM__c, CCI_Pre_Tax_MM__c, CCI_Year__c, CCI_Type__c, CCI_Currency__c from Financial_Data__c 
                where Account__c = : parentAccountId ORDER BY CCI_Year__c DESC]) {
                    
                currData.add(dat);
                
            }
            
            System.debug('Data Size: ' + currData.size());
            
        }
        catch (Exception e) {
            System.debug('Exception: ' + e);
        }
  */      
        //added to get Team
        try {
            
            currDealId = ApexPages.currentPage().getParameters().get('dealid');
            currDealCoId = [SELECT Target_Company__c FROM Investment__c WHERE ID = :currDealId].Target_Company__c;
            
            for (CCI_Team_Member__c mem : [SELECT Name__c FROM CCI_Team_Member__c WHERE Deal__c = :currDealId]) {
                currMembers.put(mem.Name__c, true); 
            }
            
        }
        catch(Exception e) {
            System.debug('Exception: ' + e);
        }
        
        try {
            config = [SELECT Id, Country_Format__c, State_Format__c, Validation_Enabled__c FROM Country_Configuration__c WHERE isDeleted=FALSE Limit 1];
        } catch (Exception e) { }
        
        if (config == null) {
            config = new Country_Configuration__c(
                Country_Format__c='Country Name',
                State_Format__c='State Name',
                Validation_Enabled__c=false
            );
        }
    }
    
    //Getter + Setter methods
    public String setcurrDealId() {Return this.currDealId;}
    public void getcurrDealId(string s) {this.currDealId = s;}
    public String getSource() { return this.source; }
    public void setSource(String s) { this.source = s; }
    public String getSub() { return this.subsource; }
    public void setSub(String s) { this.subsource = s; }
    public String getStatus() { return this.status; }
    public void setStatus(String s) { this.status = s; }
    public String getCoName() { return this.companyName; }
    public void setCoName(String coname) { this.companyName = coname; }
    public String getType() { return this.dtype; }
    public void setType(String dealtype) { this.dtype = dealtype; }
    public String getDealType() { return this.dealType; }
    public void setDealType(String dtype) { this.dealType = dtype; }
  //  public Account getAccount() { return this.newAcct; }
  //  public void setAccount(Account acct) { this.newAcct = acct; }
  //  public Contact getContact() { return this.newCon; }
  //  public void setContact(Contact con) { this.newCon = con; }
  //  public Opportunity getOpp() { return this.newOpp; }
  //  public void setOpp(Opportunity opp) { this.newOpp = opp; }
     public Investment__c getDeal() { return this.newDeal; }
    public void setDeal(Investment__c deal) { this.newDeal = deal; }
    
    public boolean DisplaySubSource() {
        if (dealType == 'Private Equity Deal')
            return true;
        else
            return false;   
    }
    
    public List<SelectOption> getStates() {
        List<SelectOption> states = new List<SelectOption>();
        states.add(new SelectOption('','--None--'));
        for (State__c st : [SELECT ID, Name, ISO_Code__c, Exclude__c, Country__r.Exclude__c FROM State__c WHERE Exclude__c=FALSE AND isDeleted=FALSE ORDER BY Name]) {
            String displayName;
            if (config.State_Format__c == 'ISO Code') {
                displayName = st.ISO_Code__c;
            } else {
                displayName = st.Name;
            }
            states.add(new SelectOption(displayName, displayName));
        }
        return states;
    }
    
    public List<SelectOption> getCountries() {
        List<SelectOption> countries = new List<SelectOption>();
        countries.add(new SelectOption('','--None--'));
        
        for (Country__c c : [SELECT ID, Name,ISO_3166_2_Code__c, ISO_3166_3_Code__c, Exclude__c, Order__c FROM Country__c WHERE Exclude__c=FALSE AND isDeleted=FALSE ORDER BY Order__c, Name]) {
            String displayName;
            if (config.Country_Format__c == 'ISO 3166-2 Code') {
                displayName = c.ISO_3166_2_Code__c;
            } else if (config.Country_Format__c == 'ISO 3166-3 Code') {
                displayName = c.ISO_3166_3_Code__c;
            } else {
                displayName = c.Name;
            }
            countries.add(new SelectOption(displayName, displayName));
        }
        return countries;
    }
    
    public List<SelectOption> getTypes() {
        List<SelectOption> types = new List<SelectOption>();
        
        if (dealType == 'Private Equity Deal') {
            types.add(new SelectOption('Buyout / Recap', 'Buyout / Recap'));
            types.add(new SelectOption('Divisional Buyout', 'Divisional Buyout'));
            types.add(new SelectOption('Minority Equity Investment', 'Minority Equity Investment'));
            types.add(new SelectOption('Going Private', 'Going Private'));
            types.add(new SelectOption('Merger', 'Merger'));
            types.add(new SelectOption('Mezz Only', 'Mezz Only'));
        }
        else {
            types.add(new SelectOption('Open Market', 'Open Market'));
            types.add(new SelectOption('Toe Hold', 'Toe Hold'));
        }
        
        return types;
    }
    
    public List<SelectOption> getSources() {
        List<SelectOption> sources = new List<SelectOption>();

        if (dealType == 'Private Equity Deal') {
            sources.add(new SelectOption('Proprietary', 'Proprietary'));
            sources.add(new SelectOption('Process', 'Process'));
        }
        else {
            sources.add(new SelectOption('Proprietary', 'Proprietary'));
            sources.add(new SelectOption('Investment Bank', 'Investment Bank'));
        }
        
        return sources;
    }
    
    public List<SelectOption> getSubSource() {
        List<SelectOption> sub = new List<SelectOption>();
        
        if (source == 'Proprietary' && dealType == 'Private Equity Deal') {
            sub.add(new SelectOption('Internal Idea', 'Internal Idea'));
            sub.add(new SelectOption('Corp. Dev.', 'Corp. Dev.'));
            sub.add(new SelectOption('Executive Relationship', 'Executive Relationship'));
            sub.add(new SelectOption('Other', 'Other'));
        }
        else if (source == 'Proprietary' && dealType == 'Public Equity Deal') {
            sub.add(new SelectOption('Investor', 'Investor'));
            sub.add(new SelectOption('Internal Idea', 'Internal Idea'));
            sub.add(new SelectOption('Corp. Dev.', 'Corp. Dev.'));
            sub.add(new SelectOption('Screen', 'Screen'));
            sub.add(new SelectOption('Other', 'Other'));
        }
        else if (source == 'Process' && dealType == 'Private Equity Deal') {
            sub.add(new SelectOption('Auction', 'Auction'));
            sub.add(new SelectOption('Limited', 'Limited'));
            sub.add(new SelectOption('Sole', 'Sole'));
        }
        
        return sub;
    }
    
    public List<SelectOption> getStatuses() {
        List<SelectOption> statuses = new List<SelectOption>();
        
        if (dealType == 'Private Equity Deal') {
            statuses.add(new SelectOption('Closed', 'Closed'));
            statuses.add(new SelectOption('LOI Signed', 'LOI Signed'));
            statuses.add(new SelectOption('LOI Issued', 'LOI Issued'));
            statuses.add(new SelectOption('IOI Issued', 'IOI Issued'));
            statuses.add(new SelectOption('Actionable', 'Actionable'));
            statuses.add(new SelectOption('Hot List', 'Hot List'));
            statuses.add(new SelectOption('Watch List', 'Watch List'));
            statuses.add(new SelectOption('Track List', 'Track List'));
            statuses.add(new SelectOption('Lead', 'Lead'));
            statuses.add(new SelectOption('Dead - IPO', 'Dead - IPO'));
            statuses.add(new SelectOption('Dead - Transaction Occurred', 'Dead - Transaction Occurred'));
            statuses.add(new SelectOption('Dead - AKKR Passed', 'Dead - AKKR Passed'));
        }
        else {
            statuses.add(new SelectOption('Initial Position Taken', 'Initial Position Taken'));
            statuses.add(new SelectOption('Recommendation', 'Recommendation'));
            statuses.add(new SelectOption('Prelimenary Work', 'Prelimenary Work'));
            statuses.add(new SelectOption('Focus List', 'Focus List'));
            statuses.add(new SelectOption('Watch List', 'Watch List'));
            statuses.add(new SelectOption('Lead', 'Lead'));
            statuses.add(new SelectOption('Dead', 'Dead'));
        }
        
        return statuses;
    }
    
    
    public List<SelectOption> getDealTypes() {
        List<SelectOption> dealTypes = new List<SelectOption>();
        dealTypes.add(new SelectOption('Private Equity Deal', 'Private Equity Deal'));
        dealTypes.add(new SelectOption('Public Equity Deal', 'Public Equity Deal'));
        
        return dealTypes;
    }
    
    public PageReference SaveDeal() {
        SavePoint sp = Database.setSavePoint();

        try {
            
            //Set deal record type
            if (dealType == 'Private Equity Deal')
                newDeal.RecordTypeId = clsAccelUtil.getPrivateDealRecordTypeId();
            else
                newDeal.RecordTypeId = clsAccelUtil.getPublicDealRecordTypeId();
                
            newDeal.CCI_Deal_Type__c = dtype;
            newDeal.Status__c = status;
            newDeal.Source__c = source;
            newDeal.Source_Sub_Type__c = subsource;
            if (newDeal.Name == null)
                newDeal.Name = companyName;
            newDeal.OwnerId = UserInfo.getUserId();
            Database.Insert(newDeal);
   /*
            //Save Account
            newAcct.RecordTypeId = clsAccelUtil.getDealCoRecordTypeId();
            newAcct.Name = companyName;
            newAcct.Type = 'Prospect Company';
            newAcct.OwnerId = UserInfo.getUserId();
            
            try {
                Database.Insert(newAcct);
            } catch (DmlException dml) {
                ApexPages.addMessages(dml);
                newAcct = newAcct.clone();
                Database.rollback(sp);
            }
            
            if (newCon.CCI_Last_Name__c != null) {
                newCon.Salutation = newCon.CCI_Salutation__c;
                newCon.FirstName = newCon.CCI_First_Name__c;
                newCon.LastName = newCon.CCI_Last_Name__c;
                newCon.AccountId = newAcct.Id;
                newCon.OwnerId = UserInfo.getUserId();
                Database.Insert(newCon);    
                newDeal.CCI_Primary_Contact__c = newCon.Id;
            }
            
            newDeal.Target_Company__c = newAcct.Id;
     */       
            currDealId = newDeal.Id;
        //    parentAccountId  = newAcct.Id;
            
            Database.Update(newDeal);
        }   
        catch (DmlException dml) {
            ApexPages.addMessages(dml);
  //          newAcct = newAcct.clone();
            newDeal = newDeal.clone();
            
            Database.rollback(sp);
            return null;
        }
        
        //Add Team
        
        
        List<CCI_Team_Member__c> newMembers = new List<CCI_Team_Member__c>();

        try {
            
            for(TeamMember tm : members) {
            
                if (tm.selected) {
                    CCI_Team_Member__c newMem = new CCI_Team_Member__c();
                    newMem.Name__c = tm.user.Id;
                    newMem.Deal__c = currDealId;
                    newMem.Company__c = currDealCoId;
                    newMembers.add(newMem);
                }   
                
            }   
            
        }   
        catch(Exception e) {
            ApexPages.addMessages(e);
            return null;
        }
        
        try {
            Database.Insert(newMembers);    
        }
        catch(DmlException dml) {
            ApexPages.addMessages(dml);
            return null;
        }
   /*     
        //Add Financials
        try {
            
            List<Financial_Data__c> toBeInserted = new List<Financial_Data__c>();
            
            for(Financial_Data__c item : currData) {
            
                if (item.CCI_Year__c == null)
                    continue;
                item .Account__c = parentAccountId;
                toBeInserted.add(item);  
                
            }
            
            Database.Insert(toBeInserted);  
        }  
        catch(DmlException dml) {
            ApexPages.addMessages(dml);
            return null;
        }
*/
        
        PageReference ref = new PageReference('/' + newDeal.Id);
        ref.setRedirect(true);
        return ref;
        
    }
  /*  
    public PageReference SaveInvestor() {
    
        try {
            
            //Save Account
            newAcct.RecordTypeId = clsAccelUtil.getInvestorCoRecordTypeId();
            newAcct.OwnerId = UserInfo.getUserId();
            Database.Insert(newAcct);
            
            if (newCon.CCI_Last_Name__c != null) {
                newCon.Salutation = newCon.CCI_Salutation__c;
                newCon.FirstName = newCon.CCI_First_Name__c;
                newCon.LastName = newCon.CCI_Last_Name__c;
                newCon.AccountId = newAcct.Id;
                newCon.OwnerId = UserInfo.getUserId();
                Database.Insert(newCon);    
            }
            
            //Save Opportunity
            if (newOpp.Fund__c == null)
                newOpp.Name = newAcct.Name;
            else {
                newOpp.Name = newAcct.Name + ' | ' + [SELECT Name FROM Fund__c WHERE Id = :newOpp.Fund__c LIMIT 1].Name;
            }
            newOpp.AccountId = newAcct.Id;
            newOpp.OwnerId = UserInfo.getUserId();
            newOpp.CloseDate = System.Today().addDays(365);
            Database.Insert(newOpp);
            
            if (newCon.CCI_Last_Name__c != null) {
                newRole.ContactId = newCon.Id;
                newRole.Role = 'Decision Maker';
                newRole.IsPrimary = true;
                newRole.OpportunityId = newOpp.Id;
                Database.Insert(newRole);
            }
            
        }   
        catch (DmlException dml) {
            ApexPages.addMessages(dml);
            return null;
        }
        
        PageReference ref = new PageReference('/' + newOpp.Id);
        ref.setRedirect(true);
        return ref;
        
    }
   */
    //Save Team

     public String getDealName() {
        return [SELECT Name FROM Investment__c WHERE Id = : currDealId].ID;    
    }
    
    public List<TeamMember> getUsers() {
    
        try {
    
            for(User usr : [SELECT Id, Name, Title FROM User Where IsActive = true]) {
                
                if (currMembers.get(usr.Id) == null) {
                    TeamMember temp = new TeamMember(usr);
                    members.add(temp);
                }
            }   
            
        }
        catch(Exception e) {
            System.debug('Exception: ' + e);    
        }
        
        return members;
    }
   
    
    public PageReference Cancel() {
        PageReference ref = new PageReference('/' + currDealId);
        ref.setRedirect(true);
        return ref; 
    }
       
//Save Financials

  /*  
    public String getName() { return currAccountName; }
 
     public List<Financial_Data__c> getData() {
        return currData;
    }
    
    public void AddItem() {
    
        Financial_Data__c newItem = new Financial_Data__c();
        newItem.Account__c = newAcct.Id;
        currData.add(newItem);
        
    } 
  */   
    public PageReference BacktoAccount() {
        PageReference ref = new PageReference('/' + newDeal.Id);
        ref.setRedirect(true);
        return ref; 
    }
    
}

 
I have been asked to  add a list of all potential team members to an opportunity quick start screen and allow users to select team members?   
I believe I need to use visualforce pages and apex code to do this, but I'm not sure exactly what to do and if it is possible
I've built a process that updates records as they are created that runs an hour after the account/contact/address are created.  Now I've been asked to create a process that will update the records that were already created. 

I'd like to build a process that only runs on update, but I can't figure that out.

Can you give me any suggests?
I need to set up email to case.  Email services is not turned on in the org.

The first message I see is:

Before creating email services, create Apex classes that implement the Messaging.InboundEmailHandler interface.

global class myHandler implements Messaging.InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) { Messaging.InboundEmailResult result = new Messaging.InboundEmailresult(); return result; } }

I tried setting this up in a sandbox and deploying through an outbound change set, but deployment fails   

I'm a novice at this, and I'm not sure what to do next.
I am trying to build a trigger to update a field on Account for a custom object that has a lookup relationship to the acccount (Investment__c).

The field on Account that I'm trying to update is DealCount__c  Number (3, 0).
The field on Investment__c that I am using to get the count is Deal_Unique_ID__c

The ID for Investment__c is a text field.

Any help or advice is greatly appreciated....my experience writting triggers is almost non-existent...and I'm trying to learn.  

Below is the error I'm receiving and the trigger:

//Error:Apex trigger AllDealCounts caused an unexpected exception, contact your administrator: AllDealCounts: execution of AfterUpdate caused by: System.StringException: Invalid id: PharmaMetrics (2017): External entry point
//Trigger
trigger AllDealCounts on Investment__c (after update,after insert) 
{
List <ID> DealIDs = new List<Id> ();
List <Account> accounts = new List<Account>();
List <AggregateResult> requirements = New List<AggregateResult>();

for(Investment__c req:trigger.new)
{
DealIDs.add(req.Name);
}
Accounts = [Select ID, DealCount__c from Account  where ID in :accounts];
 Requirements = [Select Target_Company__C,  Count(Deal_Unique_ID__c) from Investment__c where Target_Company__c in :accounts group by Target_Company__c];
For(AggregateResult ar: requirements)
{
for(Account a:accounts) 
{
if (ar.get('Accounts') == a.ID)
{a.DealCount__c =  Decimal.ValueOf(String.ValueOf(ar.get('expr0'))) ;}
}
}
}
I have a Multi-Select pick list that defaults to "-None Selected'"

When a check box is checked I want to remove "-None Selected-" and require the user to select another value(s).

Is this possible?  And how can I remove the field.  I know I can use a validation rule, but the users don't want to have to remove "-None Selected'" so I need to have this happen automatically.
I need to build a dynamic formula that will allow me to name the fields based on the current year.

For example, I've built out a formula
if(isNull(X2017_EBITDA__c)=False,"2017: $" &  Text(X2017_Revenue__c) & " | $" & Text( X2017_EBITDA__c )&BR()&
"2016: $"&TEXT( X2016_Revenue__c )&" | $"&TEXT( X2016_EBITDA__c )&BR()&
"2015: $"&TEXT( X2015_Revenue__c )&" | $"&TEXT( X2015_EBITDA__c )

I'd like to fill in the year in the field names dynamically based on the current year.  Is this possible?
I have a button that is working with a fairly simple nested case statement to create echosign documents based on changes in the field region__c:
/apex/echosign_dev1__AgreementTemplateProcess?masterid={!Lead_Appointment__c.Id}&templateId={!CASE(Upper(Text(Lead_Appointment__c.Region__c)),
"HOU", "a03i000000H3qRW",
"SAN", "a03i000000H3qRW",
"AUS", "a03i000000H3qRW",
"DFW","a03i000000LQMc5",
"TYL","a03i000000LQMc5",
"MOD","a03i000000LQMc5","a03i000000H3qRW" )}
I need to add two additional criteria to the case statement and I'm unsure how to proceed.  
  If Signers__c =1 and Contracts__c =1 and Region = "AUS", then return specific package
  If Signers__c=2 and Contracts__c = 1 and Region ="AUS", then return a different package
 If Signers__c=1 and Contracts__c=2 and Region ="AUS", then return a different package
 If Signers__c+2 and Contracts__c=2 and Region = "AUS", then return another package.

I need to loop through each of the regions and each Signer/Contract option.
Any advice will be greatly apprecitated.
I am trying to build a trigger to update a field on Account for a custom object that has a lookup relationship to the acccount (Investment__c).

The field on Account that I'm trying to update is DealCount__c  Number (3, 0).
The field on Investment__c that I am using to get the count is Deal_Unique_ID__c

The ID for Investment__c is a text field.

Any help or advice is greatly appreciated....my experience writting triggers is almost non-existent...and I'm trying to learn.  

Below is the error I'm receiving and the trigger:

//Error:Apex trigger AllDealCounts caused an unexpected exception, contact your administrator: AllDealCounts: execution of AfterUpdate caused by: System.StringException: Invalid id: PharmaMetrics (2017): External entry point
//Trigger
trigger AllDealCounts on Investment__c (after update,after insert) 
{
List <ID> DealIDs = new List<Id> ();
List <Account> accounts = new List<Account>();
List <AggregateResult> requirements = New List<AggregateResult>();

for(Investment__c req:trigger.new)
{
DealIDs.add(req.Name);
}
Accounts = [Select ID, DealCount__c from Account  where ID in :accounts];
 Requirements = [Select Target_Company__C,  Count(Deal_Unique_ID__c) from Investment__c where Target_Company__c in :accounts group by Target_Company__c];
For(AggregateResult ar: requirements)
{
for(Account a:accounts) 
{
if (ar.get('Accounts') == a.ID)
{a.DealCount__c =  Decimal.ValueOf(String.ValueOf(ar.get('expr0'))) ;}
}
}
}
I need to build a dynamic formula that will allow me to name the fields based on the current year.

For example, I've built out a formula
if(isNull(X2017_EBITDA__c)=False,"2017: $" &  Text(X2017_Revenue__c) & " | $" & Text( X2017_EBITDA__c )&BR()&
"2016: $"&TEXT( X2016_Revenue__c )&" | $"&TEXT( X2016_EBITDA__c )&BR()&
"2015: $"&TEXT( X2015_Revenue__c )&" | $"&TEXT( X2015_EBITDA__c )

I'd like to fill in the year in the field names dynamically based on the current year.  Is this possible?