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
0
votes
1answer
55 views

Does an Apex Class run linearly (procedurally?)?

I am used to writing a run method in Java which specifies where the code runs. Outside of this nothing runs unless called. In apex there I don't see a run method. I'm guessing it starts at the top ...
0
votes
1answer
2k views

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY - INVALID_CROSS_REFERENCE_KEY

I'm also getting a the following error from my apex test and trigger while validating. The error,test class and trigger are below. Run Failures: TestAfterPOLogUpdateTest.myUnitTest System....
1
vote
1answer
720 views

How to put a list in the parameter for class and use its variables?

I have a JSON and I need to pass the data to a list, then use it as my class parameter. I've managed to pass JSON to a List, but when I put it in the class, it throws the following error: "global ...
3
votes
1answer
200 views

Can a managed package query and list all the classes installed in a subscriber organization?

By querying the ApexClass object, one can list all the classes that exist within an organization. However, if the code which queries the classes is from a managed packaged, can it see all the records, ...
0
votes
1answer
138 views

How would i write my map/soql query outside of the for loop?

public static void oppFldUpdates(List<Opportunity> newOpps, Map<Id,Opportunity> oldMapps){ Opportunity oldOpp = new Opportunity(); for (Opportunity newOpp :newOpps){ ...
0
votes
2answers
337 views

Populating field value of Case using Apex Class?

I'm trying to populate a lookup field through apex, though am currently testing by populating a simple text field after a form is submitted, activated through the process builder. Below is my code, ...
0
votes
2answers
164 views

Basic Map And I am Stuck in FOR Loop [duplicate]

Here is my Map Map<id,List<Custom_Report_2__c>> mapreports= new Map<id,List<Custom_Report_2__c> >(); for( Custom_Report_2__c cr:cr1){ mapreports.put(cr....
1
vote
1answer
269 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
102 views

Trying to hide inputField - Visualforce Page

Im trying to hide my Billing_Account__c inputField on my visualforce page, If my custom field Entitas_New__c = 'Pusat' on my custom object Master_Visit_Plan__c. This is the vf page, as you can see ...
2
votes
4answers
3k views

System.LimitException: Too many DML statements

I want to mass update my account record. But I got this error when trying to deploy the code. public class Insert_CustID_Old { public void insertCustId() { List<Account> accList = [...
1
vote
1answer
409 views

Scheduling Class to insert new Records

I have written a Schedule Class to insert records when a certain record's date is four days ago. It should insert a new record but of a different record type. So for Example, if a package record type ...
1
vote
1answer
79 views

How Exactly Do the Class and Trigger Connect in this Design Pattern?

Early on as an Apex developer, I adopted the following one-trigger-per-object design pattern: Class public with sharing class caseTriggerHandler { public static boolean firstRun = true; ...
0
votes
0answers
32 views

Cross object value

I need some help with getting some object values.. I have a custome object called Named_user__c and a field on that object called Branch__c.. this object contains name, etc just like user object.. On ...
2
votes
1answer
37 views

Help getting processInstance value

I want to insert this Approval History section on opportunity to my PDF (There`s a pdf button on my opportunity object).. But what appeared on my pdf [ Issue : How to get every status date? You ...
0
votes
2answers
274 views

Email reminder scheduler

I want to make a mail reminder that automatically send the email to my sales user every h+7 h+10 and h+15 created date.. how do I code the scheduler? using IF? for example, I want this mail reminder ...
-1
votes
3answers
2k views

Test Class - DUPLICATE VALUE?

Im new in salesforce programming.. I have a trigger called CR_Approved and test class called CR_Approved_Test.. The trigger purpose = if Change_Request_Item__c.Status__c = Approved and recordType = ...
0
votes
2answers
399 views

ASK - Field value is blank in Apex single email (HTML Template)

My case is i want to send email with attachment in custom object using single email message using HTML Email Template (with letterhead). Current condition i successed to make the email same like ...
1
vote
1answer
2k views

error: DUPLICATE_VALUE, This price definition already exists in this price book: []

Here is the error message & my test class: System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, This price definition already exists in this price book: []...
1
vote
1answer
384 views

Roll Up Field of Open & Closed Activities on Account - Using an APEX class

The use case is that I am trying to have a roll-up field on the account object that is a sum of the total # of Open and Closed activities on the account. This would be easy with a Trigger, but I want ...
0
votes
3answers
2k views

Skip and dont add null value to list?

Im trying to make a mail reminder on case object to every owner/case.. but everytime I execute the code, there`s an error System.EmailException: SendEmail failed. First exception on row 4; first ...
0
votes
1answer
75 views

How to get opportunity history value and convert it to pdf?

im new in salesforce programming.. I made an pdf report (button) on opportunity.. I can get the opportunity object field value (and opportunityLineItem) and convert it to pdf.. but down below the ...
1
vote
1answer
82 views

Apex class getSimpleName() equivalent

I would like to get Apex class name without namespace prefix. I wonder if exists any equivalent method like known in Java getSimpleName() ? Existing method getName() returns apex class name with ...
0
votes
1answer
105 views

Help Apex Class - Email Reminder

I want to make an email reminder if case status != closed to case owner every H+5, H+7, and H+10 .. H = created date and I want to make a table (as email body), so the email body = list of cases ...
1
vote
1answer
975 views

how to get value from map when wrapper class is the key

I have a wrapper class of picklist values and labels. I am creating a map with picklistValues and List as key and value types. Now, I am getting an error won this line -- objResults.get(...
2
votes
1answer
732 views

get set from controller extension to visualforce page

I have a controller with extesion from which I try to pass the subtitle values to my visualforce page but I cant seem ro render it. My system.debug('subtitle 1 '+ subtitle ); gives : subtitle 1 {...
1
vote
3answers
146 views

Help Schedule email reminder

Im new in salesforce apex programming.. I want to make an email reminder if case status != closed to case owner H+5, H+7, and H+10 .. H = created date .. how do i get the owner email value? and ...
1
vote
1answer
683 views

Not able to query attachment coming from email to case

Why is the attachment blank even though i have attached one while creating case from email. List<Case> cases = [SELECT Id,OwnerId, (SELECT id,Name,ContentType FROM ...
1
vote
0answers
480 views

TrailHead EmailManager Apex Test Class

I am using the EmailManager provided in Trailhead and I am writing a test class and it works as expected (and I get over 75% coverage) but I can't seem to get it to 100% coverage because of the ...
-3
votes
1answer
1k 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 ...
0
votes
1answer
688 views

How to show user a message and stop APEX Class execution

I have a APEX Class that runs from a button on a standard record page. It creates a related record in another table. The code works fine as it is now. But I want to add a feature that does a ...
1
vote
1answer
79 views

Wrapper class Referencing?

How do I reference my wrapper class in my prepareshipment method? My goal was to set tNumber and location to = my fields on my shipment object. In my VF page I want tNumber and Location to display ...
9
votes
1answer
1k views

How to deserialize JSON to a class where the same variable name has different data types?

I am trying to deserialize some JSON to a class using JSON.deserialize. My JSON looks like this { "type": "GeometryCollection", "geometries": [ { "type": "Point", ...
-2
votes
1answer
192 views

How to evalute Rule criteria of workflow with Apex Programming? [closed]

I want to evaluate Rule Criteria Expression with Apex Programming. For Example :- Rule Criteria :- (Account: Account Name EQUALS ads) AND (Account: Account Number EQUALS 1234) I want to evaluate ...
1
vote
0answers
40 views

update record based on mutiple queries to related (sort of) objects

My objective: Once an Opportunity is Closed/Won and the quote is the primary, look up the product2 related to the quote line(custom) and find the related subscription plan(custom) and pricebook(...
0
votes
2answers
4k views

Invalid loop variable type expected SObject was Relatie__c

I am trying to make an trigger handler from which I took the logic from the trigger and placed in the handler. Before i can save my handler I get the error: Invalid loop variable type expected ...
0
votes
1answer
123 views

Cannot delete @Deprecated component in a managed package even with SF deletion tool

We have a @deprecated apex class in our managed package and want to delete it. We logged a case to enable the Component Deletion Tool but still cannot delete the @deprecated component. Here's what I ...
1
vote
1answer
49 views

Create Child record when Parent's Parent Updates

I have to be able to create a child record called "seats" when the parent of the parent object of "Seats" changes. Teams -->Tables---> Seats So when Team changes, I need to be able to create Seats ...
3
votes
1answer
65 views

How to merge methods into one

How can I merge these two methods that just set the date for child records when the parent record changes? Or should I just keep them separate? public with sharing class Tables { public static ...
1
vote
1answer
574 views

Help with writing test class for simple Apex soql query

I know similar questions have been asked before, however, I cannot find an example that would lay out how to test my query online. I am trying to roll out a lightning component that queries a custom ...
-3
votes
1answer
92 views

Getting error while inserting bulk data in test class

I have developed the below test class but getting below error. Error: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ...
0
votes
1answer
27 views

Substring based on a word and immediate next third bracket

I have a large text value as below in a custom field of a custom object. FINDDATA: [XY_8852376....... {name:"State__SKN", "data": "State__SKN", defaultContent: '', className:"frozencolumnscolor", ...
0
votes
0answers
106 views

Javascript button click on Apex Page

I have a requirement to develop such that a click on a Javascript button will send an email to a particular email address. After that it will open a new window. On it "Email Sent" will show and then ...
3
votes
1answer
229 views

prevent trigger fire from a future method [duplicate]

I would like know if there is any global variable i can use to prevent trigger fire from a future method. Like I can use System.isBatch() to prevent trigger fire from batch classes
3
votes
1answer
1k views

Inner Classes/Interfaces

the guide says that one difference between Java and Apex is: Inner classes and interfaces can only be declared one level deep inside an outer class. Considering I know in Java what is an Inner class,...
0
votes
1answer
174 views

Alphanumeric 4 Digits Sequential Suffix Code

The project that I'm working now is to add a suffix 4 digits alphanumeric sequential code, to a part number, the suffix is starting with AAA0 and then AAA1, AAA2 and go on, this suffix it will be the ...
0
votes
2answers
498 views

Batch class run in real time through custom button instead of going to anonymous window in Developer console [closed]

We have tool for mass lead conversion in salesforce. We have used lead rule custom object. We can schedule this conversion but has to go to developer console and had to run Id batchJobId = Database....
1
vote
1answer
573 views

How to use the wrapper class in HTTP getmethod [duplicate]

below is my code Created a wrapper class like below public class ResponseWrapper{ public list<Account> lstaccounts; public boolean isError ; public string errorCode; public ...
-1
votes
1answer
206 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 ...
0
votes
1answer
2k views

Create Visualforce Page, Render as PDF using related records data

I am trying to create a Visualforce Page render as a PDF in which it will show the details for a record from where is executed(Object A) and certain data from an Object B that has Object A as a ...
0
votes
1answer
335 views

Trying to turn HTTP 'POST' to 'PUT'; Desire Upsert, Not Just Insert

I originally had the following trigger and REST-callout class that functioned properly: trigger SendOpp_Trigger on Opportunity (before insert, before update) { for(Opportunity o : Trigger.new){ ...

1
3 4
5
6 7
19