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
0answers
37 views

Test class for Messaging.SingleEmailMessage

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%)....
0
votes
1answer
29 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 ...
0
votes
0answers
13 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 ...
-1
votes
0answers
27 views

I am unable to get all the metadata of my sandbox in VS code

I connected my Vs code to the Salesforce sandbox, after connecting my org to VS Code I am only seeing some metadata partially loaded, I couldn't see all the metadata, how do I get all my metadata in ...
1
vote
1answer
48 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 ...
0
votes
1answer
27 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 ...
-1
votes
1answer
37 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 ...
0
votes
2answers
39 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 ...
0
votes
1answer
23 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(...
0
votes
1answer
38 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 ...
-2
votes
1answer
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 ...
0
votes
2answers
50 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....
0
votes
2answers
69 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 ...
-3
votes
1answer
39 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 ...
0
votes
0answers
10 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 ...
0
votes
1answer
30 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....
1
vote
1answer
47 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.......
-2
votes
1answer
47 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 {...
1
vote
1answer
34 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 ...
0
votes
1answer
48 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 { ...
0
votes
2answers
33 views

Trigger handler class not working

I have a trigger on a custom object. The code works fine when I put it in a trigger file but it does not work when I try putting it in a handler class and then calling the method from the trigger. ...
0
votes
1answer
70 views

how to use most efficient way to keep single Map in Apex?

I am completely new to Apex programming and I don't know how to efficiently get values from the Map key. below is the example I need to check three different keys and based on the matching it should ...
0
votes
1answer
43 views

Compare records with same field value from different Objects in apex?

I have two lists with having the same field in a different object. How to compare the list of name is present in my list if yes then its should be update else it should only create a new record not ...
0
votes
1answer
44 views

Facing Mixed DML operation for apex class

I have written a scheduler for deactivating salesforce users who doesn't logged in for last 90 days. The code is working as expected if I remove exception logging into a salesforce object at line #14. ...
0
votes
1answer
51 views

Pass trigger record values to Apex class for Http callout

I'm fairly new to custom development/coding in general. I've created some Stock__c records in my playground and am trying to update their price using an Http callout to IEX Cloud API. What I can't ...
0
votes
1answer
24 views

Defining Map of Tasks using User ID as Key

My goal is to send an email to users with their respective open tasks. I tried: UserInfo.getUserId () but I realized that it only works for the current user. Therefore, I'm trying to create a Map with ...
2
votes
0answers
71 views

Internal Salesforce Error occured when inserting CartItem via Test Class

Since Monday (May 10, 2021), we've encountered an issue in our test class that we didn't encountered previously. There was a Salesforce update on May 10 so I suspect this was the cause of our issue. ...
0
votes
2answers
58 views

Error " List has no rows for assignment to SObject"

I am doing a wrapper class binding account and its related contact and opp record. For starters, there is only one Account with the name 'Account1'. 'Account1' only has 1 Contact and 1 Opportunity. My ...
0
votes
2answers
31 views

adding a check before insert

How do I add a check to see if any cases need to be inserted before processing the insert statement in the code below? public class StockItemDeleter { // declare a method, which accepts a list of ...
0
votes
0answers
50 views

Properties of Objects that are other Object Types won't serialize

I have a weird problem. So I've created an object where three of the properties of said objects are actually custom types. So the "merchant" object has "BillingAddress", "...
0
votes
1answer
39 views

Pass object of custom class as parameter to another class

I want to make something like in the code below, but it didnt work. Erorr: Method does not exist or incorrect signature: void method1() from the type SObject. public with sharing class Test1{ ...
0
votes
1answer
43 views

Writing a Simple APEX Class

Sorry, this could be a simple question, but I'm struggling to find a way to modify a code and convert a lead into an existing Account. I'm trying to do this by using the setAccountID method. The ID ...
0
votes
2answers
46 views

When is `this` required to refer to an Apex instance variable?

I was writing an Apex class, and wasn't referring to this whenever I referenced an instance variable. My tests were working. When I noticed this, I tried prepending this. to each of the instance ...
0
votes
1answer
43 views

Why does the Apex compiler think I'm trying to call a function with a void signature?

I have built this class, in the attempt to pass some JSON from JavaScript to Apex: public with sharing class QueryDefinition { public Integer lim; public Integer offset; public String ...
0
votes
2answers
38 views

I am new to the Salesforce platform.I have been getting "Attempt to de reference a null Object" on Custom Object Trigger.Help me to Sort the Error

Apex Trigger trigger CustObjCToPTrigger on Employee__c (before update) { set<Id> ParentIdSet = new set<Id>(); for(Employee__c e : trigger.new){ ...
0
votes
1answer
29 views

How do I call inner classes from execute anonymous or another class

When I try to call this from execute anonymous it fails and says "Type is not visible: OutterClass.InnerClass " OutterClass.InnerClass inresponse = new OutterClass.InnerClass(); System.debug(...
0
votes
1answer
32 views

How to move this redundant logic to for loop [closed]

I am trying to check if a field value is changed and based on that construct a Json. I am checking 3 fields, but it might get increased in future. How can I do this efficiently for this below logic ...
0
votes
1answer
24 views

Value is not getting populated in Number_of_Enrolments__c field

my requirement is whenever a Student Enrolments are created/deleted the Number of Enrolments field on Activity (Parent object) should be updated to reflect the count. Helper class;- public class ...
0
votes
2answers
21 views

Inheritance variable from Master class

Hi Everyone - I am newbie in developer community, I am working on inheritance where I am trying to call the variable of Master class intochild one but I am afriad it is not working out. Any help will ...
1
vote
1answer
38 views

Can we use custom settings in SOQL queries?

I need to use run a query based on the value in custom settings. Delete_Lookup__c is my custom settings. I need to change the output of query based on the values in custom settings. global class ...
0
votes
1answer
44 views

Apex Class & Trigger Issue

I am stuck on three errors that I cannot seem to diagnose in an Apex class and trigger combination. The class is below: public class DelegatedUserSetup { void setObjectives(User[] users) { ...
0
votes
1answer
53 views

For loop inside For

I want to avoid this For loop inside another For... Is there any way for my situation? public class ManagerAccountTeamMember { public static Boolean isFirstTimeBEFORE = true; public static ...
0
votes
2answers
30 views

Error when trying to get Cases from input

Trying to get a list of cases that are equal to the cases in the variable caseInputs but i get three errors. 1.Invalid bind expression type of Integer for column of type String->its probably ...
0
votes
2answers
115 views

open new record after finish flow

I created a visualforce page with an embedded flow. But If I click the "NEXT" button it appears the page https://domain.my.salesforce.com/Accountnull, but it should open the new account ...
-1
votes
2answers
34 views

Can't retrieve information from sObject

I am new to Apex so kindly help { public static void showAccountsName() { List<sObject> AccountsList = new List<sObject>(); AccountsList = [Select name from Account]...
-1
votes
1answer
22 views

Test class are failing because of one Trigger

I am allocating a customer community user license whenever a lead is converted into contact and it's working fine. below is my code: trigger CreateCommunityUser on Contact (After insert) { ...
1
vote
1answer
227 views

test.starttest() and test.stoptest() not working

Please let me know how to resolve the below issue.I am new to salesforce,its still giving me an error Too many DML statements: 151.Using Test.starttest() and test.stoptest() is not working. Test Class:...
0
votes
1answer
66 views

user defined apex class

I need to build a wrapper that could essentially hold this format. { record: { id: 123 name: abc start: 1-jan end: 31-jan status: completed records: [{ ...
0
votes
1answer
75 views

Apex method not changing record type of an object

So Im making an Apex class that I want to push to production that will change the record type of an object, to a different record type. Here is the class below: public class removeclassy { List<...
0
votes
1answer
65 views

Virtual and Extend Apex Class - accessing parameter in child class

The first code snippet is from a separate class that calls the OnfidoAPI class which is an extension of the APIBaseUtil and passes over the parameters to APIBaseUtil. My understanding was that the ...

1
2 3 4 5
21