• Andrew E
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
Hi all,

I have some apex code that looks like the code below. In my test class, I have a testMethod for successful execution, but I'm having trouble creating a testMethod for the exception. I've been able to trigger the exception, but the test is marked as Fail and I recieve "System.AuraHandledException: Script-thrown exception". As a result, I'm not getting code coverage for this exception.

How can I successfully test an AuraHandledException from a testMethod without breaking the test and having it result in a Fail?
try{
   update account;
}
catch(Exception e){
   throw new AuraHandledException('error updating account');
}

 
Hello all,

I have an actionFunction tag that looks like the following.
<apex:actionFunction name="doNothing" action="{!doSomething}" />

I'm referencing in Javascript as doNothing(), but I'm wondering if there is a way where I can get a callback on JS to know when it finishes running. I know there is an oncomplete attribute, but I really need this to happen within the JS functions I'm building. 
Hello all,

I currently have a function (let's call it function doSave()) executing without being called. It is only referenced twice and I have a System.debug in both functions that call doSave(), but none of them output the System Debug line so I'm pretty certain they are not calling it.

I'm pretty bamboozled. I'd like to add a System.debug line to my doSave() function that would print the stacktrace so I can see what function is calling it or why it is running. Is this possible?
Hi all,

I'm working with an <aura:iteration> that iterates over 56 items. Within the  iteration, I have several nested <aura:if> statements and this makes my table load very very slowly. 

Is there a way to optimize <aura:if> tags to make them render faster? If it better to have one <aura:if> tag with several conditions in isTrue or several <aura:if> tags with just one condition in isTrue?

Any guidance would be appreciated as it takes about 30 seconds for my table to load at the moment. 
Hi all,

I'm building a Lightning application on VisualForce composes of several components. I have one component that is a spinner so every component has its own "showspinner" and "hidespinner" function that calls an Event which is handled by a listener on the VisualForce page to show/hide the spinner. There are a few more functions that all my components have and call on when necessary.

I'm wondering, is this bad design? This makes each component independent as it can be re-used without depending on other components, but it's a lot of repetitive code in my application. Does anyone have any suggestions? I'm thinking if I can somehow create a global method, I can just call it with one line from each component.

Hello,

I have a Lightning Component with an Apex controller. The controller has a constructor that sets some variables, but it doesn't seem to be running when I load my component because the variable is null when I call another function. I can't call it from the component either as I get a notification that "AuraEnabled does not apply to Constructors".
 

See below for an example of what I mean but my case is a lot more complex as I have quite a few variables that need to be set at the beginning and calling a SOQL query every time I call a function that needs these would not be efficient. 
 

public class MyController{

   public User currentUser;

   public MyController(){
      currentUser = [Select Id, FirstName from User where  Id =: UserInfo.getUserId();]
   }

    @AuraEnabled
   public static String getMyName(){
      return currentUser.FirstName;
   }

}
Hello,

When migrating a Visualforce page to Lightning, I've been able to determine how to migrate everything on the VF page into a Lightning component, but then the Apex controller seems like it would be able to stay the same. Are there any considerations to take into account for the Apex controller? I am using a custom controller.
Hi all,

I have some apex code that looks like the code below. In my test class, I have a testMethod for successful execution, but I'm having trouble creating a testMethod for the exception. I've been able to trigger the exception, but the test is marked as Fail and I recieve "System.AuraHandledException: Script-thrown exception". As a result, I'm not getting code coverage for this exception.

How can I successfully test an AuraHandledException from a testMethod without breaking the test and having it result in a Fail?
try{
   update account;
}
catch(Exception e){
   throw new AuraHandledException('error updating account');
}

 

Hello,

I have a Lightning Component with an Apex controller. The controller has a constructor that sets some variables, but it doesn't seem to be running when I load my component because the variable is null when I call another function. I can't call it from the component either as I get a notification that "AuraEnabled does not apply to Constructors".
 

See below for an example of what I mean but my case is a lot more complex as I have quite a few variables that need to be set at the beginning and calling a SOQL query every time I call a function that needs these would not be efficient. 
 

public class MyController{

   public User currentUser;

   public MyController(){
      currentUser = [Select Id, FirstName from User where  Id =: UserInfo.getUserId();]
   }

    @AuraEnabled
   public static String getMyName(){
      return currentUser.FirstName;
   }

}
Hello Everyone,

I'm trying to use force:navigateToComponent, but its not working. Here is my code:
<pre>
({
    NavigatetoComp : function(component, event, helper) {
        
        console.log('Enter Here');
        var evt = $A.get("e.force:navigateToComponent");
        console.log('evt'+evt);
        evt.setParams({
            componentDef: "c:MyComponent2",
            //componentAttributes :{ }
        });
       
        evt.fire();
    }
})
</pre>

It throws following error:
User-added image

Can any body tell why is it so?

Thanks In Advance
Aakanksha Singh