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
1 answer
22 views

Data is not retrieving in a set. Help me I am New to Apex

I am new to Apex. When I query Accounts in a List it shows all the records in a list without for loop. But When I query the same in set, it only shows One record. When I Check Size of the set, it ...
user avatar
-1 votes
1 answer
23 views

I am unable to insert 10000 records. Getting Too man query rows error

public class CreateBulkAccounts { @future Public static void method1() { List<Account> acList = new List<Account>(); for(integer i=0; i<10000; i++) ...
user avatar
0 votes
1 answer
33 views

Need to insert New Event Date and time in Account Field (Event Date Time (manually created)) through Apex Class/Trigger

I am trying to insert New Event Start date/time and End date/time in Account object field (Event Date Time). Please help me to trigger code. Once New Event created, the Start Date/Time & End date/...
user avatar
0 votes
1 answer
27 views

Visualforce display a related list from a lookup field on a custom object

I am quite new to salesforce/coding and got myself stuck on a stumbling block when developing object for our internal use. I have and object called Inventory_Skid_c this object has a field called Skid ...
user avatar
  • 3
0 votes
0 answers
17 views

An error occurred in the apex test class [duplicate]

i have to pass the test class but the error is not resolving iam not bale to find the error can you please help what i have to do to pass this test class "message": "Method does not ...
user avatar
  • 1
0 votes
1 answer
23 views

Apex Wrapper class instance field order

// I have a wrapper class like: public class classWrapper { public A A_ITEMS; public B B_ITEMS; public C C_ITEMS; } public class C { public List<CItem> item; } public class ...
user avatar
-3 votes
1 answer
26 views

Illegal assignment from List<String> to List<Order> (4:21)",

Im having this issue which I dont understand. Any advice?
user avatar
-2 votes
1 answer
41 views

Coin Change program in apex

Edit: Figured it out , thanks for help. public class coin { public static Integer amounts(Integer[] coins, Integer amo) { Integer[] dp = new Integer[amo+1]; for(Integer k = 0; ...
user avatar
  • 1
2 votes
2 answers
79 views

Lombok for Salesforce Apex

I'm looking for some solution, which helps me to write less code in Apex. Is there any tool like Lombok for Java.
user avatar
0 votes
1 answer
25 views

Test Class code coverage ( only couple of lines )

Hello this is the first time i try to write a test class, but i don't understand exactly how i can test if the flow was actually launched. Can someone help me with the test class ? It's only a couple ...
user avatar
2 votes
1 answer
59 views

Throw Error on Two Record Merge

I'm working on a requirement where I need to stop contact merge if the child record associated with both of them are same. I have written a before delete trigger on Contact, but I'm not getting ...
user avatar
0 votes
1 answer
44 views

Apex Test Class Fetching Article Details

I need help with writing an apex test class for a class that fetches article titles and article descriptions. Class for example: global class FetchingArticleDetails{ global List<(API name of ...
user avatar
  • 3
0 votes
1 answer
64 views

Help with Parent-Child relationship in apex class

I created the following trigger. trigger Update_Case_Subject on Case (before insert) { for (Case c : trigger.new){ c.Subject = RecordType.DeveloperName + ' - ' + Account.JA_Account_ID__c + ...
user avatar
  • 1
0 votes
1 answer
78 views

covering test class if condition for a variable defined in method

public static String myMethod(String vehicle1){ string abc = 'car'; if (abc == 'bike'){ // lines of code } } Here the issue that I am facing is that the lines of code inside the ...
user avatar
0 votes
2 answers
100 views

Whats wrong with my Apex Class? It throws ERROR Please reference your WSDL or the describe call for the appropriate names

In Execute Anonymous it works fine Code: List<Room__c> c=[SELECT id,Name,Customer__c FROM Room__c]; System.debug(c); But in Apex Class it throws an error as Didn't understand relationship '...
user avatar
0 votes
1 answer
73 views

Enterprise Territory Management (OppTerrAssignDefaultLogicFilter) Test Class Error

I am in the process of implementing the territories within Salesforce and was following the instructions and sample code from the help documents here: https://developer.salesforce.com/docs/atlas.en-us....
user avatar
  • 5
1 vote
0 answers
42 views

update sobject class

I'm trying to update sobject from one to another sf org. I import my custom wsdl sobjectEnterpriseSoapSforceCom and sobjectEnterpriseSoapSforceCom, i pass login but i cannot able to update an sobject. ...
user avatar
  • 11
7 votes
1 answer
146 views

What is the best practice regarding organizing Apex code

I am just curious of what is the best practice, it seems that if I create folders in force-app/main/default/classes and put my classes there everything seems to work fine. Is this in any manner bad or ...
user avatar
0 votes
1 answer
49 views

Trigger to compare records in different Objects not working as expected

I have refered the following thread to solve my problem. Not sure where I am going wrong. Compare records with same field value from different Objects in apex? Here is my attempt: PROBLEM: While ...
user avatar
  • 55
0 votes
0 answers
37 views

Attempt to de-reference a null object but no issues found in the class

I have a Class1 and then there is another Class1_Handle. The Class1 takes a list of OPP, then loops through that and sends Opportunity ID to the Hadelar 1 by 1. The Handler then does a bunch of stuff, ...
user avatar
2 votes
1 answer
312 views

Error on Trigger: Method does not exist or incorrect signature: void CheckPreviousYearEntryByPhoneNumber(list) from type FreeWaterSchemeClass

Problem statement: If the customer phone number was enrolled in free water scheme for 2020, status field in 2021 scheme object should ''You cannot avail this scheme in 2021, as you have already ...
user avatar
  • 55
0 votes
3 answers
58 views

Is there any way we can identify the insertion/updation of record is happened through UI or not

I have requirement where I have one trigger and its calling handler and in handler i have one method, I need to run that method if I am updating the record through UI in,i dont want to run trigger or ...
user avatar
  • 1
0 votes
1 answer
185 views

Update field using Apex

I am very new to Apex and found this site- hoping someone can help me out. We have a LOT of code-free automation on our cases and related objects, so we had to resort to Apex classes to do a few ...
user avatar
0 votes
1 answer
172 views

Add data to query results to LWC

hoping i can get some help on this one: I have an Apex class where im running a SOQL query: public with sharing class TestClass { @AuraEnabled public static List <sobject> getFreqLWC(String ...
user avatar
0 votes
1 answer
135 views

Enable Map type to hold Integer, String, Boolean, Map, List... objects? (But not generic Object)

I'm attempting deserialize a list of a custom object in Apex, but got an error: FATAL_ERROR System.JSONException: Apex Type unsupported in JSON: Object This is because my ContactPostBack class ...
user avatar
  • 9
5 votes
2 answers
502 views

How can I extend the `Set` class?

Is there any way I can extend the Set class? I have numerous places in code where if I a set has no items, I want to add all the items in another set, but if it does have items, I want to retain only ...
user avatar
  • 653
2 votes
1 answer
519 views

No viable alternative at character " "

Second day of being a coder and I'm getting this error... line 1:70 no viable alternative at character '"' Error is in expression '{!search}' in component apex:commandButton in page ...
user avatar
-2 votes
1 answer
69 views

Why isValid is true but failed to deploy with error 'Dependent class is invalid and needs recompilation'?

Why isValid = true but even though still failed to deploy with error 'Dependent class is invalid and needs recompilation'? When I run query Select Id, Name from ApexClass where isValid = false it ...
user avatar
0 votes
1 answer
39 views

Pointers on writing test class for ApexPages.StandardController Controller

I have the following Apex Class that I need to write a test class for. I've never done this before and rather new at this. Can someone offer pointers for this test class? public class ...
user avatar
  • 33
0 votes
1 answer
231 views

how I insert JSON data into Apex class [duplicate]

I have a question about convert the JSON to class and insert and see the Data from standard Account Salesforce (account, contact) This is the serialized data { "conList": [ { &...
user avatar
0 votes
1 answer
156 views

AuraEnabled function gets not value from lwc using class type as parameter

i have the following object: public class myType { public String name {get; set;} public String fields {get; set;} public Integer page {get; set;} public Integer pageSize { get; set; } } ...
user avatar
0 votes
0 answers
43 views

Test class for Messaging.SingleEmailMessage [duplicate]

I wrote a batch class that send the records in email notification with schedule The batch works, but I'm still struggling to write a test class that will get a high code coverage (currently I get 63%)....
user avatar
0 votes
1 answer
33 views

Validate duplicate records in list

I am working on deleting duplicate child records on contact merge. Example: I have a contact C1 and C2 : (C1 has A,B,C records and C2 has A,D,E) records and now record A is the duplicate with same ...
user avatar
  • 11
0 votes
0 answers
16 views

2GP: the same class name in 2 packages with the same namespace [duplicate]

We have 2(2GP) Packages for example "A" and "B" on the one namespace for example "pkg2". In Package A we have an apex trigger with the name "ContactTrigger" and ...
user avatar
  • 11
1 vote
1 answer
113 views

Checking Equality in Lists of Apex Classes

I am writing tests for a flow utility and have been failing tests due to Salesforce by default comparing custom class instances by reference instead of values. I added an equals method to my output ...
user avatar
0 votes
1 answer
36 views

How to get rid of Apex class that is not in use

I want to delete an apex class that is not used anymore but has dependencies with Flows and LWC etc. What would be an ideal way to retire the apex class? Commenting out the lines or deleting the class ...
user avatar
-1 votes
1 answer
213 views

Invocable method with wrapper parameter in console

I have invocable method and trying to pass wrapper as parameter. But i wanna run that in console. How can i do it? It gives me error wrong parameter when i am trying to pass Wrapper Object. public ...
user avatar
0 votes
2 answers
42 views

Incorrect signature error. Query record id by name <Name is unique data>

this code allows users to upload CSV files to update data to Salesforce. What I want is, how to make users can update existing data without inserting record ID as well to update data. I think I can ...
user avatar
0 votes
1 answer
25 views

Test Addition to a List or Set using Test class [duplicate]

I have the following code which is fetching only First Name from Contact where Account Name is 'United Oil & Gas, UK'. public class ContactUK { public List<string> viewcontactUK(...
user avatar
0 votes
1 answer
78 views

How should I write a handler class for this trigger? [closed]

I try to write a trigger handler to this trigger (in order to write test to this trigger), but I don't know how it should be done. This is my trigger: trigger FinancialTrigger on ...
user avatar
  • 1
-2 votes
1 answer
17 views

Update sibling records from the same object fails

I have a custom object called 'myObject__c'. This object has a lookup with Account. Now I want to get the values of an existing record (e.g. recordA) and update another record (e.g. recordB). this is ...
user avatar
  • 21
0 votes
2 answers
246 views

Get Id of the newly created record in Apex

I have the following Apex method: public static void createJourney(Id accountId) { // Step 1: get account record type Account accRecTypeName = [SELECT Id, RecordType....
user avatar
  • 21
0 votes
2 answers
497 views

Soql query to check record type

I want to check the record type of Account before doing anything else. I have the following method: public static void methodName(Id accountId) { // get account record ...
user avatar
  • 21
-3 votes
1 answer
140 views

APEX JOB TO DELETE RECORDS

I have a demand and I need help to create an apex that is in Batch and delete all accounts with more than 10 years on the platform. I managed to get to the code below but I can't advance can someone ...
user avatar
0 votes
0 answers
17 views

I can't see any logs in the debug logs about a class implementing Social.InboundSocialPostHandler

I am trying to review the logs that I have programmed but they are never displayed. I need to see the system.debug found in a class where Social.InboundSocialPostHandler is implemented I've been ...
user avatar
0 votes
1 answer
2k views

Method does not exist or incorrect signature from void type list

I have the following method: public static void updateCaseLastEmailStatus(List<EmailMessage> emUpdateCase) { Id caserecordType = Schema.SObjectType.Case....
user avatar
  • 21
1 vote
1 answer
103 views

PMD showing errors for one class, but not another class with the same issue

I just installed PMD and its pretty janky from my experience, for example I have two classes and it shows the "same name" error for one class but completely ignores it for the other class.......
user avatar
-2 votes
1 answer
52 views

Help with invocable apex method for process builder [closed]

Create apex class that can be lunched from Process Builder (for Account). Apex class should make next logic: When new Account is created, create new Task object with Subject “Negotiations with {...
user avatar
1 vote
1 answer
38 views

Cannot call class from within another class

I have two classes. Inside class B, I want to use the method written in the class A. And I dont know why I get error. Class A look like this: public class ZipCodeUpdateOwnerships { //This ...
user avatar
0 votes
1 answer
137 views

Use same method in before insert Apex code and in button

Maybe a simple question: is there a way I can use the same method to create/update records in a before trigger and in a button? I have an Apex class. Let's call it Stuff.apxc. public class Stuff { ...
user avatar
  • 1

1
2 3 4 5
21