• Pablo Lamas
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 11
    Replies
So I have created a trigger and a trigger handler class, but I cant seem to make either of them trigger in an isAfter && isUpdate call. My updateInstallStatusDesign works fine when it is an isBefore && isUpdate but I need it at the isAfter && isUpdate call. 
Trigger
...
 	else if(Trigger.isAfter && Trigger.isUpdate)
    {
        OpportunityTriggerHandler.updateInstallStatusDesign(Trigger.old, Trigger.new);
        OpportunityTriggerHandler.createRedesignRecords(Trigger.new);
    }
...

TriggerHandlerClass
...
public static void updateInstallStatusDesign(List<Opportunity> originals, List<Opportunity> results)
    {
        updateInstallStatusToDesign(originals, results);
    }
    private static void updateInstallStatusToDesign(List<Opportunity> originals, List<Opportunity> results)
    {
        Map<Id, Opportunity> oldMap = new Map<Id, Opportunity>(originals);
        Map<Id, Opportunity> newMap = new Map<Id, Opportunity>(results);
        
        Set<Id> oppIdsWithStageChange = new Set<Id>();
        Set<Id> installIdsToGet = new Set<Id>();
        
        for(Id current : oldMap.keySet())
        {
            Opportunity oldOpp = oldMap.get(current);
            Opportunity newOpp = newMap.get(current);
            
            if(oldOpp == null || newOpp == null)
                continue;
            
            if(oldOpp.RecordTypeId != '012700000001Sgi' || newOpp.RecordTypeId != '012700000001Sgi')
                continue;
                            
            if(oldOpp.StageName != OpportunityStage.ContractApproved && newOpp.StageName == OpportunityStage.ContractApproved)
            {
                oppIdsWithStageChange.add(current);
                installIdsToGet.add(oldOpp.Installation__c);
                installIdsToGet.add(newOpp.Installation__c);
            }
        } 
        List<Installation__c> neededInstalls = [
               SELECT Id, Name, Install_Status__c
               FROM Installation__c
               WHERE Id IN :installIdsToGet 
        ];
        Map<Id, Installation__c> installationMap = new Map<Id, Installation__c>(neededInstalls);
        
        List<Installation__c> updateInstallations = new List<Installation__c>();
        
        for(Id current : oppIdsWithStageChange)
        {
            Opportunity oldOpp = oldMap.get(current);
            Opportunity newOpp = newMap.get(current);
            Installation__c oldInstall = installationMap.get(oldOpp.Installation__c);
            Installation__c newInstall = installationMap.get(newOpp.Installation__c);
            
            if(oldInstall == null || newInstall == null)
                continue;
                           
            if(oldInstall.Install_Status__c == InstallationStatus.SalesRepReview && newInstall.Install_Status__c == InstallationStatus.SalesRepReview)
            {
                updateInstallations.add(new Installation__c(
                    Id = oldInstall.Id,
                    Install_Status__c = InstallationStatus.Design
                ));
            }
        }
        if(updateInstallations.size() > 0)
        {
            update updateInstallations;
        }
    }
    
    public static void createRedesignRecords(List<Opportunity> results)
    {      
        Set<Id> installsNeedingRedesignRecord = new Set<Id>();     
        
        for(Opportunity curr : results)
        {
            installsNeedingRedesignRecord.add(curr.Installation__c);
        }
        
        List<Installation__c> installs = [
        	   SELECT Id, Name, Install_Status__c, of_Designs__c
               FROM Installation__c
               WHERE Id IN :installsNeedingRedesignRecord 
        ];
        Map<Id, Installation__c> allInstallMap = new Map<Id, Installation__c>(installs);
        
        List<Design__c> desingsToBeCreated = new List<Design__c>();
        
        for(Id installId : installsNeedingRedesignRecord ) 
        {
        	Installation__c currInstall = allInstallMap.get(installId);
            if(currInstall.of_Designs__c <= 1 && currInstall.OppStage__c == OpportunityStage.ContractApproved && currInstall.RecordTypeId == '012700000001Sgi' && currInstall.Install_Status__c == InstallationStatus.Design )
            {
            	desingsToBeCreated.add(new Design__c(
                	RecordTypeId = '01270000000MzZ8',
                	Installation__c = installId,
                	Design_Status__c = 'Revisions Needed',
                	Redesign_Reason__c = 'Building Department',
                	Revision_Number__c = '0'
       	     	));
            }
        }
        
        insert desingsToBeCreated;
    }
...

 
Hello,
I currently having and issue with trying to deploy a fix to a trigger class that we have. When I validate it, I receive the following error: 
      Your code coverage is 8%. You need at least 75% coverage to complete this deployment.
The issue is that, this isnt a regular apex class, it is a trigger. From what I understand, triggers need to have >0% code coverage, which I have 8% code coverage. Any ideas as to why this is being evaluated at the 75% code coverage and not at the >0% code coverage. 
Hello,
So I am having a bit of an issue when trying to save changes on fields that I have made inline editable within my visualforce class. It all displays correctly and I can click on everything I need, but when I hit save, it causes an issue with one of the triggers we have that states that only one record at a time can be saved. I was told to traverse the list and save as it traverses and that would solve it, turns out that is not an option as well since it will hit the limits of a package that we have installed. So I was left with thinking if this is plausible through other means? Would a javascript script work to save indivual records at at time and not triger either of the issues I have stated? Any assistance would be greatly appreciated. 

VF Page
-------------------------
<apex:page standardController="Installation__c" extensions="InlineEditingController" recordSetVar="Installation" >

    <apex:form >
        <apex:pageBlock title="Edit Report">
                      
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel" />
            </apex:pageBlockButtons>
            
            <apex:pageBlockTable value="{!records}" var="rec">                  
                <apex:column value="{!rec.Expected_Rebate_Amount__c}"></apex:column>            
                <apex:column value="{!rec.Opportunity__r.Name}"></apex:column>
                <apex:column value="{!rec.Name}"></apex:column>  
                <apex:column value="{!rec.Rebate__r.Name}"></apex:column>  
                <apex:column value="{!rec.Phone_Numbers__c}"></apex:column>  
                <apex:column value="{!rec.Email__c}"></apex:column>
                    <apex:column headerValue="*Rebate Status">
                        <apex:outputField value="{!rec.Rebate__r.Rebate_Status__c}">
                            <apex:inlineEditSupport event="ondblclick" showOnEdit="update"/>
                        </apex:outputField>
                    </apex:column>
                    <apex:column headerValue="*Initial Interconnection Submitted Date">
                        <apex:outputField value="{!rec.Rebate__r.Net_Metering_Submitted__c}">
                            <apex:inlineEditSupport event="ondblclick" showOnEdit="update"/>
                        </apex:outputField>
                    </apex:column>
                    <apex:column value="{!rec.Elect_Co__c}"></apex:column>  
                    <apex:column value="{!rec.Job_Site_Street_Address__c}" ></apex:column>  
                    <apex:column value="{!rec.System_Size__c}"></apex:column>          
                    <apex:column value="{!rec.Days_Aging__c}"></apex:column>     
                    <apex:column value="{!rec.Rebate_Notes__c}"></apex:column> 

                    <apex:column value="{!rec.Total_Cost_of_Install__c}"></apex:column> 
            </apex:pageBlockTable>
         
            <apex:panelGrid cellpadding="5" cellspacing="5" columns="5" >
                <apex:commandButton value="|<" action="{!first}"  />
                <apex:commandButton value="<" action="{!previous}" rendered="{!HasPrevious}" />
                <apex:commandButton value=">" action="{!next}" rendered="{!HasNext}" />
                <apex:commandButton value=">|" action="{!last}"  />   
           </apex:panelGrid>
           
         </apex:pageBlock>
    </apex:form>
</apex:page>

Controller
------------------
public class InlineEditingController{
    public List<Installation__c> records {get;set;}
   
    public InlineEditingController(ApexPages.StandardSetController setCon){
        records = [SELECT Id, Name, Expected_Rebate_Amount__c,Opportunity__r.Name, Rebate__r.Name, Phone_Numbers__c, Email__c, Rebate__r.Rebate_Status__c, Rebate__r.Net_Metering_Submitted__c, Elect_Co__c,Job_Site_Street_Address__c,System_Size__c,Days_Aging__c, Rebate_Notes__c, Total_Cost_of_Install__c FROM Installation__c WHERE Initial_Interconnection_Submitted__c = null AND (Install_Status__c = 'Design' OR Install_Status__c = 'Permit Submitted' OR Install_Status__c = 'Permit Revisions Needed' OR Install_Status__c = 'Permit Ready to be Picked Up' OR Install_Status__c = 'Permit Picked Up/Schedule Install' OR Install_Status__c = 'Install Scheduled with Customer' OR Install_Status__c = 'Installation in Process' OR Install_Status__c = 'Install Complete - Pending Local Inspections' OR Install_Status__c = 'Install Complete - Pending PTO' OR Install_Status__c = 'Install Complete - Pending Final Approvals') AND Opportunity__r.RecordType.Name = '1LE Commercial Sales'];
    }
    
    public PageReference save(){
        for(Installation__c i : records){          
            update records;
        }
        return null;   
    }
 }
 
Hello,
I have created a workflow that sends out an outbound message based of some fields not being equal to null and for some odd reason we have a profile that cannot send the outbound message and I have checked the box on the profile settings that allows for outbound messages to be sent. The endpoint URL is not the issue given that my profile(System Administrator) and other profiles(Executives) that we have can send the outbound message without an issue. I have checked all the permissions on the profile compared to mine and they have more things checked than I do. Any assistance would be greatly appreciated.
Hello,
I currently having and issue with trying to deploy a fix to a trigger class that we have. When I validate it, I receive the following error: 
      Your code coverage is 8%. You need at least 75% coverage to complete this deployment.
The issue is that, this isnt a regular apex class, it is a trigger. From what I understand, triggers need to have >0% code coverage, which I have 8% code coverage. Any ideas as to why this is being evaluated at the 75% code coverage and not at the >0% code coverage. 
Hello,
So I am having a bit of an issue when trying to save changes on fields that I have made inline editable within my visualforce class. It all displays correctly and I can click on everything I need, but when I hit save, it causes an issue with one of the triggers we have that states that only one record at a time can be saved. I was told to traverse the list and save as it traverses and that would solve it, turns out that is not an option as well since it will hit the limits of a package that we have installed. So I was left with thinking if this is plausible through other means? Would a javascript script work to save indivual records at at time and not triger either of the issues I have stated? Any assistance would be greatly appreciated. 

VF Page
-------------------------
<apex:page standardController="Installation__c" extensions="InlineEditingController" recordSetVar="Installation" >

    <apex:form >
        <apex:pageBlock title="Edit Report">
                      
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel" />
            </apex:pageBlockButtons>
            
            <apex:pageBlockTable value="{!records}" var="rec">                  
                <apex:column value="{!rec.Expected_Rebate_Amount__c}"></apex:column>            
                <apex:column value="{!rec.Opportunity__r.Name}"></apex:column>
                <apex:column value="{!rec.Name}"></apex:column>  
                <apex:column value="{!rec.Rebate__r.Name}"></apex:column>  
                <apex:column value="{!rec.Phone_Numbers__c}"></apex:column>  
                <apex:column value="{!rec.Email__c}"></apex:column>
                    <apex:column headerValue="*Rebate Status">
                        <apex:outputField value="{!rec.Rebate__r.Rebate_Status__c}">
                            <apex:inlineEditSupport event="ondblclick" showOnEdit="update"/>
                        </apex:outputField>
                    </apex:column>
                    <apex:column headerValue="*Initial Interconnection Submitted Date">
                        <apex:outputField value="{!rec.Rebate__r.Net_Metering_Submitted__c}">
                            <apex:inlineEditSupport event="ondblclick" showOnEdit="update"/>
                        </apex:outputField>
                    </apex:column>
                    <apex:column value="{!rec.Elect_Co__c}"></apex:column>  
                    <apex:column value="{!rec.Job_Site_Street_Address__c}" ></apex:column>  
                    <apex:column value="{!rec.System_Size__c}"></apex:column>          
                    <apex:column value="{!rec.Days_Aging__c}"></apex:column>     
                    <apex:column value="{!rec.Rebate_Notes__c}"></apex:column> 

                    <apex:column value="{!rec.Total_Cost_of_Install__c}"></apex:column> 
            </apex:pageBlockTable>
         
            <apex:panelGrid cellpadding="5" cellspacing="5" columns="5" >
                <apex:commandButton value="|<" action="{!first}"  />
                <apex:commandButton value="<" action="{!previous}" rendered="{!HasPrevious}" />
                <apex:commandButton value=">" action="{!next}" rendered="{!HasNext}" />
                <apex:commandButton value=">|" action="{!last}"  />   
           </apex:panelGrid>
           
         </apex:pageBlock>
    </apex:form>
</apex:page>

Controller
------------------
public class InlineEditingController{
    public List<Installation__c> records {get;set;}
   
    public InlineEditingController(ApexPages.StandardSetController setCon){
        records = [SELECT Id, Name, Expected_Rebate_Amount__c,Opportunity__r.Name, Rebate__r.Name, Phone_Numbers__c, Email__c, Rebate__r.Rebate_Status__c, Rebate__r.Net_Metering_Submitted__c, Elect_Co__c,Job_Site_Street_Address__c,System_Size__c,Days_Aging__c, Rebate_Notes__c, Total_Cost_of_Install__c FROM Installation__c WHERE Initial_Interconnection_Submitted__c = null AND (Install_Status__c = 'Design' OR Install_Status__c = 'Permit Submitted' OR Install_Status__c = 'Permit Revisions Needed' OR Install_Status__c = 'Permit Ready to be Picked Up' OR Install_Status__c = 'Permit Picked Up/Schedule Install' OR Install_Status__c = 'Install Scheduled with Customer' OR Install_Status__c = 'Installation in Process' OR Install_Status__c = 'Install Complete - Pending Local Inspections' OR Install_Status__c = 'Install Complete - Pending PTO' OR Install_Status__c = 'Install Complete - Pending Final Approvals') AND Opportunity__r.RecordType.Name = '1LE Commercial Sales'];
    }
    
    public PageReference save(){
        for(Installation__c i : records){          
            update records;
        }
        return null;   
    }
 }
 
Hello,
I have created a workflow that sends out an outbound message based of some fields not being equal to null and for some odd reason we have a profile that cannot send the outbound message and I have checked the box on the profile settings that allows for outbound messages to be sent. The endpoint URL is not the issue given that my profile(System Administrator) and other profiles(Executives) that we have can send the outbound message without an issue. I have checked all the permissions on the profile compared to mine and they have more things checked than I do. Any assistance would be greatly appreciated.