• ztrank
  • NEWBIE
  • 5 Points
  • Member since 2015
  • Fixture Finders LLC

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I have a class that extracts the Type name from an object Instance
public static String extractTypeName(Object classInstance) {
        return String.valueOf(classInstance).split(':').get(0);
    }

In my test class I force a custom exception (declared in the test class) to be thrown, which I am expecting.
catch (exception e) {
            System.assert(e instanceof MyException, e.getMessage());
            System.assertEquals('clear exception', e.getMessage());
        }
This works when I run the test in the sandbox and the test succeeds. However when I run it in production it fails the first assertions and the message I get is "Invalid conversion from runtime type testClass.MyException to String"

Here is the exception declaration
private class MyException extends Exception {}

Any ideas?
  • February 18, 2016
  • Like
  • 0
Hello!~

I'm having trouble to find the best option to do a summary record with n records of the same type. 
Let me explain. 

I have a VF with a extension which gives me a list of a custom Object (ex: List<products__c> prods) i have this "products" n times with differents IDs but some with the same model...
So i have a WrapperClass that recives as a parameter a list of products. (Public productWrapper (List<products__c> p))
I want to summarize the quantity of products of the same model.

EX (i get in the list) 
ID     MODEL  QUANTITY  
01       A           10
02       B            5
03       C            1
04       A            3
05       A            5
06       B            10
07       C            20

so i want my wrapper class to tell me:
Model A: 18 pieces
Model B: 15 pieces
Model C: 21 pieces


but i don't know how exactly to achieve that... 
I know that an AggregateResult list should work but i will group those models for differents parameters and sumarize it as well for those parameters....

Any help?
Thanks.
  • February 18, 2016
  • Like
  • 0
Hello Guys,  i hope somebody can help me ;) I wrote this trigger ( i am a new "developer"^^). Now i need a Test Class for this Trigger to run in our Production. I have no idea how to start :( Maybe its easy but for me .. so pleas help me guys :)

User-added image

Hello,

 

          I have a custom button on a object which open a visual force page pop-up.

Can some body please help me or let me know. Is there any way I can close the window thorough the controller itself.

 

As I Do have validation in which if the data inserted is correct. The windows will close and save the data. And if the data is incorrect the class return a error message. If I write a Ajax close whenever the the call come back with message it close the window without showing the message.

 

Please help me and let me know if we can close the window in apex class (Controller) ???