Questions tagged [class]

A class is a template or blueprint from which objects are created. An object is an instance of a class.

Filter by
Sorted by
Tagged with
43
votes
4answers
31k views

Deleting Triggers/Classes from Production

I was recently told ( Deleting a Class with IDE - cannot delete from Production? ): You cannot delete a class in production directly. You will need delete the class from your sandbox and then ...
19
votes
3answers
3k views

How to delete a Test Class WITHOUT using eclipse

I cannot install Eclipse, even if I wanted to. It is not approved software for my org. How can test classes be deleted from production, using deployments? There no 'active' checkbox when I am ...
15
votes
3answers
11k views

Can we access class properties dynamically with Object class?

Is it possible to access Apex class properties dynamically? While we can create Object's, and assign any other class to an Object, I'm not sure how I can access the properties of these Object's. Can ...
10
votes
4answers
17k views

How to delete a class from production using destructiveChanges.xml

Can any one tell me the steps to delete a class using destructiveChanges.xml
32
votes
3answers
14k views

Return Name of class from instance of that class

I need a quick approach to something like: MyClass mc = new MyClass(); String theName = ClassNameProvider.getName(mc); // returns 'MyClass'
5
votes
2answers
9k views

Scheduled Job does not execute. Though shows in GUI

I have a scheduled class that is seen and setup within the Gui. Setup->Monitoring->Scheduled Jobs It is set to run everday at 6PM. It shows started and next scheduled run. However, I started it over ...
42
votes
2answers
5k views

Inheriting non-implicit constructors on Apex classes

If I have an abstract parent class like this: abstract class Vehicle { public Vehicle(Person driver) { // } } and then I create a child class like this: public class MagicCarpet ...
43
votes
5answers
2k views

What are all of the reasons why Salesforce customers should upgrade the API version on their Apex classes, triggers, and pages?

I haven't been able to find any official documentation or community discussion of the compelling reasons to upgrade the API version on Apex classes, triggers, and pages. I know there is the general ...
10
votes
7answers
3k views

How to get a list of Test Classes in an org

I need to get all test classes (classes with isTest Annotation) in an Org.. Is there anyway to filter test classes out of all the Apex Classes
15
votes
1answer
3k views

When to add apex class permissions to a profile

The apex class permissions are a bit confusing to me. For example, classes used by page controllers do not need to be added to the profile. Can anyone give a complete list of scenarios on when you ...
2
votes
1answer
508 views

APEX Dataloader fail INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call

I have a trigger and a class that seem to be causing an insert fail in Dataloader. I am trying to insert 200 records to see if an error is generated before moving these to production. I'm just ...
0
votes
1answer
815 views

Roll up Summary via trigger for lookup relationship

I am trying to get this trigger to work but it is giving me an error and I am not able to figure out why. The error I am getting is "attempt to de-reference a null object) Why trigger? We have a ...
0
votes
2answers
4k views

Unable to cover get set in apex test class

I am unable to cover the following class get set method. Need help in creating test class public class Aresult{ public class Parent { public String type {get; set;} public String ...
7
votes
1answer
5k views

Is anyone using classes in anonymous apex?

I can't find anyone writing about this, but this works when executed anonymously: public class foo { public void bar() { system.debug('\n\n#### FOO BAR ####\n\n'); } } foo f = new foo(...
4
votes
1answer
1k views

Tooling API calls from Apex requires user to set up Remote Site Settings?

For a personal project, I'm trying to retrieve Validation Rules from objects to display them inside a Visualforce page. For this I'm using the excellent Tooling API wrapper from Andrew Fawcett, but ...
1
vote
3answers
14k views

Apex : CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY & SELF_REFERENCE_FROM_TRIGGER

I added a new field on Opportunity table to keep a count of records, as well as track the updates made on that record. This is needed for an external system we use. Opportinity table already has ...
1
vote
1answer
9k views

Too many DML rows: 10001(bulk update)

when I try to run the code below I am getting this error: 'Too many DML rows: 10001'. The object that I am trying to update is one of the main object in the org. so it has multiples triggers, ...
4
votes
2answers
27k views

Static method cannot be referenced from a non static context: List<String>

I believe this is a basic query and am missing something out. However am exasperated finding an answer to the issue and thus seek your guidance. The intent is to create a static method ...
-2
votes
1answer
111 views

Wrapper class in Http getmethod

below is my code Created a wrapper class like below public class ResponseWrapper{ public list<Account> lstaccounts; public boolean isError ; public string errorCode; public ...
4
votes
3answers
2k views

Apex Test Execution Stuck in Queue

I have attempting to run an Apex Test Execution and my test has been stuck in "Queue" since yesterday. It doesn't look as though I , as the Admin, have been locked but still no progress on the queue. ...
3
votes
2answers
1k views

Increment Record based on field

I'd like to increment fields based on the quote field, so when a quote is created, a custom field will increment depend on the region (each field will have format of "ZO - {000}). Each region should ...
3
votes
1answer
1k views

Can we create report folders through Apex

I like to create a report folder via Apex trigger/class is it possible. Thanks in advance
3
votes
1answer
4k views

Can we generate a WSDL from an Apex class

Is it possible to generate WSDL from an Apex class ?? Cause i want to check one request but i don't have the WSDl to check from SOAP UI.
2
votes
1answer
1k views

Deleting a Class with IDE - cannot delete from Production?

When trying to delete a Class using IDE (simply right click and delete, and confirming I want it deleted in SF as well), it fails with the following screenshot. I have seen a couple posts via Google ...
1
vote
2answers
74 views

How to use trigger design pattern: ERROR Constructor not defined: [CaseTriggerHandler].<Constructor>()

I am trying to follow the best practice design patterns for triggers but get the error Constructor not defined: [CaseTriggerHandler].(). What am I missing? Trigger trigger CaseTrigger on Case (...
1
vote
2answers
4k views

What is Interface method in salesforce

I have a very simple doubt regarding this Interfaces in sales force, Actually what it says is "This class will have a method but the body will be empty. And body for this method will be provided in ...
0
votes
1answer
121 views

Rewrite apex class to be out of the loop

I have an apex class that I have been having trouble with when I try to upload in bulk accounts. It is tied to triggers that do certain things depending on whether the Customer_Success_Manager__c ...
0
votes
1answer
417 views

Translate spanish characters to english for field values

I have a requirement to translate few predetermined spanish characters to english in field values of different custom objects. I have tried to create a generic code. can someone please let me know ...
0
votes
1answer
26 views

why debug statement show Id instead of name while test class execution?

I run the test class and try to capture the permission set name in debug. But i got Id than name. Any reason why I am getting this ? Please help me to understand. See the image, what i query in ...
-3
votes
1answer
351 views

How to increase code coverage of a test class?

Apex class :- global class BlockIEPolicyCondition implements TxnSecurity.PolicyCondition { public boolean evaluate(TxnSecurity.Event e) { List<User> users = [SELECT ProfileId FROM ...
-4
votes
1answer
62 views

Test class for below class [closed]

public class ExampleClass { public static void publishCaseUpdateNotifications(List<Case> cases) { List<Case_Updated__e> notifications = new List<Case_Updated__e>(); for ...
12
votes
3answers
2k views

Difficulties with Appleman's Trigger Classes

I'm working on a major project that has numerous triggers creating new records on 4 objects while also syncing updates back and forth between 3 of the 4 objects. The new records are primarily created ...
10
votes
1answer
557 views

Why are static variables allowed only in outer classes?

According to the documentation, static variables are allowed only in outer classes. Why is that? Is it because you'd need to instantiate the inner class first?
8
votes
2answers
5k views

Set Contains method is not working correctly after overriding equals() and hashcode() methods

I have created one class name like Test and have overriden its equals() and hashcode() methods and then created its 2 objects like below - Test obj1 = new Test (); Test obj2 = new Test (); and now ...
1
vote
1answer
875 views

Accessing Picklist values from controller

I am trying to bind a pick list from a controller, my goal is to get the IDs from User Object and display them in the pick list. Any help will be appreciate it! VF <apex:selectList value="{!...
0
votes
1answer
473 views

How to get my data into javascript chart by parsing report data?

I have manged to collect all required data but not able to parse it into the list so that i can pass my data into a chart. for now i have added debug data in to chart as static to relate this chart ...
9
votes
2answers
5k views

How to invoke a method of an apex class at run time

We have a usecase where we need to invoke an instance of a class and invoke a method at run time using string. I know with reflection i can instantiate a class. But how do we invoke a method of a ...
6
votes
1answer
1k views

Return different data type using only one method

Is it possible to make an apex method wherein you can return different kind of data type (e.g. Integer, String, Double, etc.)?
5
votes
3answers
3k views

Insert List of Parent and Child Records in One DML Statement

I saw an example how to insert Parent and Child Record in one DML Statement from Developer Guide and It's Working Fine no issue in that. Here In my case I would like insert List Of Both Parent and ...
4
votes
1answer
253 views

Calling APEX class from VisualForce component

I have written a APEX Class and when I copy the code and paste in Developer Console > Debug > Open Execute anonymous window, I get expected results. However, when I call the apex class from ...
4
votes
1answer
978 views

Creating a Custom Object Handler Class

So I want to create handler classes for different Objects with my SF org, specifically for some of the custom objects. For instance I have a Global__c object that stores global settings in encrypted ...
2
votes
1answer
1k views

Help with Triggers / Classes for Case Creation based on Field Change in Customer_Asset

I am new to Salesforce and haven't coded in quite awhile, so please forgive my rookie mistake(s). I am attempting to write a trigger to do the following: Our company manufactures equipment that ...
1
vote
1answer
161 views

JSON content display : Attempt to de-reference a null object

I am trying to display content from a JSON feed on my Salesforce page using APEX/visualforce page. From information gathered, I am able to get the details of the JSON on variable. But when running the ...
1
vote
1answer
7k views

Calling an APEX method from a different class

I have a method in one class, but I need to move it out to another class. I'm aware this question has been asked several times already, but I'm getting an error I don't understand. How can I call a ...
1
vote
1answer
2k views

Best way to implement a singleton class in Apex

I am trying to create a singleton class for one of my apex classes and i am running into challenges. I created some static variables to control the instances but still i am running into multiple ...
10
votes
1answer
506 views

Why can I not reuse the name of Apex classes deleted in previous releases?

Because the documentation defines it that way. Yes since Winter'15 it explicitly states: Although a component is deleted, its Name remains within Salesforce. You can never create another ...
9
votes
1answer
3k views

Creating a class by consuming a WSDL document Schema:attribute

I have a problem with salesforce functionality. I've created flat WSDL file but when I am trying to create class in salesforce I still get this error: Error: Failed to parse wsdl: Unsupported ...
9
votes
1answer
7k views

Too many query rows 50001

Can anyone please tell me if there is something wrong with the scrip below. I am using LIMIT 50000 but still getting this error. I will appreciate any help! code: //for mws chart ...
7
votes
2answers
911 views

DML not allowed on ApexClass

I am trying to move around 80 classes and visualforce pages from sandbox to production by using change set but i got an error One or more components failed Version Compatibility Check. This ...
4
votes
2answers
88 views

Can someone recommend a solid option to help me “get my feet wet”?

I've been interviewing with a company that uses Salesforce as their CRM. I'm a sales professional and have had to use Seibel before but never salesforce. I am hoping someone could supply me with a ...