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
3
votes
2answers
428 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 ...
1
vote
1answer
292 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 ...
-2
votes
1answer
20 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 ...
0
votes
1answer
24 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 ...
0
votes
1answer
52 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": [ { &...
0
votes
1answer
27 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; } } ...
0
votes
0answers
42 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%)....
0
votes
1answer
32 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
14 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
vote
1answer
54 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
57 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
45 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
56 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
92 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
45 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
11 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
54 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
52 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
48 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
35 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
56 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
41 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
92 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
140 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
46 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
67 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
31 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
77 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
62 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
32 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
51 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
44 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
45 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
51 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
39 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
35 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
22 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
43 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
45 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
148 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
36 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
2 3 4 5
21