• Michael Covert
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hello,

I'm currently getting an error from one of my Lightning Components, it works completely as intended but under certain situations it will show this error and I can't seem to figure out how to fix it, to start I'll explain my component a litte.

The component lists all the Opportunities that the user is the Responsible Party on (Responsible Party is a lookup field on the opportunity) and it will refresh with every 5 minutes. This works perfectly.... But it will throw an error if the user switches pages and then goes back to the Responsible Party Component, it will throw the error on the next refresh. I also noticed after leaving that component it will continue to run thr refresh too. Any help would be greatly appreciated, I will show my code below and some of the steps I tried to resolve this issue.

Error:
  • Message: Uncaught Error in $A.getCallback() [Cannot read property 'setCallback' of undefined]
  • Function: Object.getOpps
  • Stack Trace:
    • Object.getOpps()@components/c/ResponsiblePartyList.js:19:15
    • Object.<anonymous>()@components/c/ResponsiblePartyList.js:28:18
-Component-
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" controller="ResponsiblePartyListApexController">
    
    <aura:attribute name="refreshTimer" type="Integer" default="2" access="global" />
    <aura:attribute name="records" type="Opportunity[]" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    
    <Lightning:card title="Opportunities" iconName="standard:opportunity">
        
        <table class="slds-table slds-table_bordered slds-table_cell-buffer">
            <thead>
                <tr class="slds-text-title_caps">
                    <th scope="col"><div class="slds-truncate" title="Borrower Name" >Borrower Name</div></th>
                    <th scope="col"><div class="slds-truncate" title="Stage" >Stage</div></th>
                    <th scope="col"><div class="slds-truncate" title="Loan Officer" >Loan Officer</div></th>
                    <th scope="col"><div class="slds-truncate" title="Last Modified" >Last Modified</div></th>
                    <th scope="col"><div class="slds-truncate" title="Created" >Created</div></th>
                </tr>
            </thead>
            <tbody>
                <aura:iteration items="{!v.records}" var="record" >
                    <tr>
                        <th scope="row" data-label="Borrower Name">
                            <div class="slds-truncate" title="{!record.Borrower_Name__r.LastName + ', ' + record.Borrower_Name__r.FirstName}"><a href="{!'/one/one.app#/sObject/' + record.Id + '/view'}">{!record.Borrower_Name__r.LastName + ', ' + record.Borrower_Name__r.FirstName}</a></div>
                        </th>
                        <td data-label="Stage">
                            <div class="slds-truncate" title="{!record.StageName}">{!record.StageName}</div>
                        </td>
                        <td data-label="Loan Officer">
                            <div class="slds-truncate" title="{!record.Loan_Officer__r.FirstName + ' ' + record.Loan_Officer__r.LastName}">{!record.Loan_Officer__r.FirstName + ' ' + record.Loan_Officer__r.LastName}</div>
                        </td>
                        <td data-label="Last Modified">
                            <ui:outputDate value="{!record.LastModifiedDate}" />
                        </td>
                        <td data-label="Created">
                            <ui:outputDate value="{!record.CreatedDate}" />
                        </td>
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
    </Lightning:card>
</aura:component>
-Controller-
({
	doInit : function(component, event, helper) {
		helper.getOpps(component);
	},
})
 
-Helper-
({
	getOpps : function(component) {
        var refreshTimer = component.get("v.refreshTimer");
        var refresh = (refreshTimer * 60) * 1000;
        var that = this;
        console.log(refresh);
        var action = component.get("c.getOppsDB");
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.records", response..getReturnValue());
            }
        });
        $A.enqueueAction(action);
        
            window.setTimeout($A.getCallback(function() {
            	that.getOpps(component);
        	}), refresh
        );
    }, 
})

I have tried to add an  action.setAbortable(), that did nothing to change it. I also tried adding isValid to the component to ensure it wasn't destroyed. I'm not sure what else I can do to fix the error but still have the auto refesh option, any information would help!

Thanks,
Michael Covert
 
Hello,

I'm having an issue with an Opportunity trigger that I'm writing, the trigger will change a User lookup field called ResponsibleParty to someone on the Opportunity Team when the stage changes. This trigger does work in the dev org, but I can't get it to work with a test class. Below is the Trigger and test class, it is failing when I perform the SOQL query on OpportunityTeamMember, it will return zero rows. Also I can take the test class code and put it right into the execute Annonymous Code windows and it all works.

FYI I'm fairly new to APEX and I'm working on the Bulkifing. 

Trigger -----

trigger Responsible_Party_Change on Opportunity (after update) {
    for (Opportunity opp : Trigger.new) {

        Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
        //Getting the UserID for Opp Team Member with "Partner" Role
        OpportunityTeamMember partner = [SELECT UserId
                            FROM OpportunityTeamMember
                            WHERE OpportunityId = :opp.Id
                            AND TeamMemberRole = 'Partner'
                            LIMIT 1];

       //Getting the UserID for Opp Team Member with "Setup" Role
        OpportunityTeamMember setup = [SELECT UserId
                            FROM OpportunityTeamMember
                            WHERE OpportunityId = :opp.Id
                            AND TeamMemberRole = 'Setup'
                            LIMIT 1];

        //Getting the UserID for Opp Team Member with "Processor" Role
        OpportunityTeamMember processor = [SELECT UserId
                            FROM OpportunityTeamMember
                            WHERE OpportunityId = :opp.Id
                            AND TeamMemberRole = 'Processor'
                            LIMIT 1];

        //IF the Stage is Partner then set Responsible Party to Partner
        if (!oldOpp.StageName.equals('Partner') && opp.StageName.equals('Partner'))
        {
                opp.Responsible_Party__c = partner.UserId;
        }
}

}

Test Class -----

@isTest
private class ResponsiblePartyChangeTest {
    
    @isTest static void StageChangeTest() {
        Opportunity opp = new Opportunity();
        opp.CloseDate = Date.Today();
        opp.OwnerId = UserInfo.getUserId();
        opp.Name = 'Test Opp';
        opp.StageName = 'Officer';
        Insert(opp);

        opp.StageName = 'Partner';
        Update(opp);
    }
    
}


Any help would be greatly Appreciated!!

 
Hello,

Just a little background on my situation, I'm a new Admin/Developer for Salesforce, my company recently started using Salesforce and I'm trying to fulfill all the needs as they come. I have NOT had the time to go through any formal trainning on Salesforce Admin/Dev, I do have .Net programming experience though.

What I need help with is an issue with downloading Files/Attachments from an Opportunity, currently we have users that will upload 5-15 PDF's to an Opportunity and a different user will need to download all the files to process them in another system. Currently I don't see any way to "Download All Files" so the users have been downloading them one at a time and when they have 5-10 different Opportunities like this it becomes a time consuming task.

I have been tasked with finding an efficent way to download all the files/attachments, to accomplish this task I was trying to access the attachments from Apex so I could work with them programmically. Currently I can't even get that to work, everything I try returns zero rows, so this is how I was trying to access those Files/Attachments. Again I am very new, so feel free to suggest better methods to accomplish this task! 

string opportunityId = '0018000000M34fSfdsfS';
List<Attachment> attList = [Select Id, Name FROM Attachment WHERE ParentId =: opportunityId];

I know the Opportunity has Files that I can view but still the query returns zero rows. I also tried some combinations of CombinedAttachments and ContentDocument but still struggling, any help would be greatly appreciated! 
Hello,

I'm having an issue with an Opportunity trigger that I'm writing, the trigger will change a User lookup field called ResponsibleParty to someone on the Opportunity Team when the stage changes. This trigger does work in the dev org, but I can't get it to work with a test class. Below is the Trigger and test class, it is failing when I perform the SOQL query on OpportunityTeamMember, it will return zero rows. Also I can take the test class code and put it right into the execute Annonymous Code windows and it all works.

FYI I'm fairly new to APEX and I'm working on the Bulkifing. 

Trigger -----

trigger Responsible_Party_Change on Opportunity (after update) {
    for (Opportunity opp : Trigger.new) {

        Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
        //Getting the UserID for Opp Team Member with "Partner" Role
        OpportunityTeamMember partner = [SELECT UserId
                            FROM OpportunityTeamMember
                            WHERE OpportunityId = :opp.Id
                            AND TeamMemberRole = 'Partner'
                            LIMIT 1];

       //Getting the UserID for Opp Team Member with "Setup" Role
        OpportunityTeamMember setup = [SELECT UserId
                            FROM OpportunityTeamMember
                            WHERE OpportunityId = :opp.Id
                            AND TeamMemberRole = 'Setup'
                            LIMIT 1];

        //Getting the UserID for Opp Team Member with "Processor" Role
        OpportunityTeamMember processor = [SELECT UserId
                            FROM OpportunityTeamMember
                            WHERE OpportunityId = :opp.Id
                            AND TeamMemberRole = 'Processor'
                            LIMIT 1];

        //IF the Stage is Partner then set Responsible Party to Partner
        if (!oldOpp.StageName.equals('Partner') && opp.StageName.equals('Partner'))
        {
                opp.Responsible_Party__c = partner.UserId;
        }
}

}

Test Class -----

@isTest
private class ResponsiblePartyChangeTest {
    
    @isTest static void StageChangeTest() {
        Opportunity opp = new Opportunity();
        opp.CloseDate = Date.Today();
        opp.OwnerId = UserInfo.getUserId();
        opp.Name = 'Test Opp';
        opp.StageName = 'Officer';
        Insert(opp);

        opp.StageName = 'Partner';
        Update(opp);
    }
    
}


Any help would be greatly Appreciated!!

 
Hello,

Just a little background on my situation, I'm a new Admin/Developer for Salesforce, my company recently started using Salesforce and I'm trying to fulfill all the needs as they come. I have NOT had the time to go through any formal trainning on Salesforce Admin/Dev, I do have .Net programming experience though.

What I need help with is an issue with downloading Files/Attachments from an Opportunity, currently we have users that will upload 5-15 PDF's to an Opportunity and a different user will need to download all the files to process them in another system. Currently I don't see any way to "Download All Files" so the users have been downloading them one at a time and when they have 5-10 different Opportunities like this it becomes a time consuming task.

I have been tasked with finding an efficent way to download all the files/attachments, to accomplish this task I was trying to access the attachments from Apex so I could work with them programmically. Currently I can't even get that to work, everything I try returns zero rows, so this is how I was trying to access those Files/Attachments. Again I am very new, so feel free to suggest better methods to accomplish this task! 

string opportunityId = '0018000000M34fSfdsfS';
List<Attachment> attList = [Select Id, Name FROM Attachment WHERE ParentId =: opportunityId];

I know the Opportunity has Files that I can view but still the query returns zero rows. I also tried some combinations of CombinedAttachments and ContentDocument but still struggling, any help would be greatly appreciated!