Skip to main content

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
1 vote
1 answer
76 views

Is there a sf command to list all apex classes in my Org?

I want to use an sf command to list all the names of the apex classes I have in my Org.Is there a command I can use ?
TheHmad Al's user avatar
0 votes
0 answers
16 views

Test class to cover 75% code coverage , getting fatal error for the codes [duplicate]

Test coverage for the below Apex classes are not enough, getting errors while deployment. public class AccountDiscountsController { public Account accountRec { get; set; } public String accId { get; ...
Nav Vel's user avatar
0 votes
0 answers
34 views

I need to send an email with a batch Class that summarises all opportunity amounts

I just don't know why this code does not work, if anyone has any suggestions, i'm happy to hear them! public with sharing class OppAmountForAccount implements Database.Batchable<sObject> { ...
Florin Hreniuc's user avatar
0 votes
1 answer
33 views

Apex Class not working in Prod. Works great in Sandbox

I am really new to Apex, so I apologize if this has been asked/answered. I created an Apex class for a flow in the Sandbox. It was working great, when I used the outbound change set to move it to ...
Grace's user avatar
  • 1
1 vote
1 answer
57 views

Getting error while implementing the trigger dispatcher architecture

when I am writing implementing class, I am getting the error Error: Compile Error: Class signingFormHandler must implement the method: void ITriggerHandler.initialize(String) at line 1 column 14 ...
Kumar's user avatar
  • 23
0 votes
0 answers
74 views

Getting "Invalid Type: Home__c" on VS Code while trying to deploy a class

So I have followed everything in the tutorials/challenges/projects and have been able to pass every one, however, on this one: https://trailhead.salesforce.com/content/learn/projects/get-started-with-...
Dhokoh's user avatar
  • 1
0 votes
1 answer
272 views

Values are not displayed on the omniscript for multiselect element using custom value

I have a multiselect element on the omniscript and I am keeping the source as custom and calling an apex class. The problem is that the values are not getting displayed. Apex Class: global class ...
code234's user avatar
  • 325
0 votes
1 answer
131 views

Do mock classes need @IsTest?

Should mock classes always be annotated with @IsTest? Are the reasons not to annotate them? The reason that I'm asking is that I stumbled upon a mock class with a custom constructor for testing that ...
Semmel's user avatar
  • 2,509
0 votes
1 answer
34 views

I am creating a class with two methods that return two lists but only the first list is getting populated whereas the second list remains empty

public with sharing class ProductController { @AuraEnabled(cacheable=true) public static List<Category__c> getCategories() { return [SELECT Id, Name FROM Category__c with ...
Faheem's user avatar
  • 1
0 votes
1 answer
103 views

2 Constructors with same name in Apex Class

First actual post here. I am fairly new to Apex Classes and I'm working on an existing project. The previous developer has the following inside of an apex class: private List<id> ...
tneo's user avatar
  • 3
-1 votes
1 answer
61 views

Can't find the apex class in scheduled apex [duplicate]

how to find the apex class in this scheduled apex record.its not showing the apex class , then I try this in apex jobs section but it's also not showing. Please give me solution for that . How do I ...
Pamoda Wijesinghe's user avatar
1 vote
1 answer
103 views

Below is my class I want recordId from the Database.error

for (Database.SaveResult result : saveResultList) { if (result.isSuccess()) { successCount++; system.debug('Get id of success Record'+result.getid()); } ...
Faizan Shaikh's user avatar
2 votes
1 answer
370 views

Is it possible to split up the LightningElement class into multiple files in LWC?

Description Let's say I have a class that extends LightningElement of ~450 lines of code. Now I want to split up the class into multiple files to manage the code. I do have some helper functions that ...
Z0q's user avatar
  • 91
1 vote
1 answer
80 views

Automatically, or at creation, assign a new class to a profile

We are testing the use of the new Integration License for API use. . We have been using the Admin license for our portal, which automatically gets assigned permissions to any new classes that are ...
Irene's user avatar
  • 1,849
0 votes
1 answer
71 views

Querying CampaignMembers based on Lead fields

New to Apex and code in general so I would appreciate any recommendation on how I´m approaching this problem. My Lead Object has a custom field utm_content__c that will hold as value the Id of the ...
Sebastian C's user avatar
0 votes
1 answer
167 views

Trying to change user role as a portal user

I have a without sharing apex class, which gets called from a flow. Inside that apex class I'm trying to change the role of a portal user, the flow gets invoked when portal user changes something on ...
salesforce Developer's user avatar
-1 votes
1 answer
25 views

Unexpected Tokens on Test Class for Apex Trigger: What am I doing wrong to create a test class for this Trigger trying to deploy to Production?

@isTest public class LeadRemovalTestClass { Static testmethod void updateRecord() trigger UpdateLeadOnRemoval on ActionCadenceTrackerChangeEvent (after insert) { ...
Mark5000 Crimper's user avatar
0 votes
0 answers
39 views

Trying to show FullPhotoURL on a visualforce table

On our org we're capturing a referral person (Referral_Person_Opp__c) on the Opportunity Object - this field is a look up on the User Object. I have created a simple table to show the top 5 referral ...
Timmy's user avatar
  • 11
0 votes
0 answers
54 views

How do I capture the Picklist Selected Event and write the code behind?

To everyone, I'm new to SFDC, but I'm not new to development. Here is what I'm trying to do: 1.) Place Picklist on the Lead page with values RDC and Wire - this is done 2.) Capture the Picklist ...
Eric C.'s user avatar
0 votes
1 answer
76 views

Sort Map results

I have a map which I want to sort the results in ASC order Let's say that yearToDate is holding the below result The result I have in yearToDate is yearToDate::{Year 1=2023-09-15 00:00:00, Year 2=2024-...
KSL's user avatar
  • 522
0 votes
0 answers
25 views

test class covering only 53% [duplicate]

Test Class: @isTest private class OpportunityTriggerHandlerverifiedIOTest { @isTest static void testOpportunityTriggerHandler() { // Create test data Opportunity ...
swaroopa's user avatar
-1 votes
2 answers
290 views

How to do code coverage for Trigger/create a test class and trigger handler for trigger [duplicate]

First, I am totally new to Apex Trigger, I'm still learning the Apex Class and Triggers. I just found a code that actually works in our org. So what it does are below. get the record type id and ...
Paul Grael's user avatar
0 votes
2 answers
214 views

LWC component which fetches data via apex not visible when site published

So there's a News reminder Component in my website and from Apex class method the records from Member object are fetched and displayed on cards. The functionality works fine in LWC Builder but when i ...
MOUSIN MULANI's user avatar
0 votes
2 answers
1k views

How do you pass a List of records to a batch apex class to be inserted?

I need to clone +10000 records. Yes,I'm aware of all of the limits and pitfalls associated with tying a trigger to a batch apex class. I'm accounting for it as only 1-2 people will be able to perform ...
Andrew Bloch's user avatar
-2 votes
1 answer
154 views

How do I write a Test Class with >80% code coverage for this class that Generates a Service Contract?

Here is the Apex Class as written: public class GenerateServiceContract { @InvocableMethod(label='GenerateServiceContract' description= 'fetchOrderItems and contractLineItems' category='Order') ...
Mark's user avatar
  • 1
0 votes
0 answers
261 views

Getting error 'Invalid type: EmailMessage'

I have create one class which implements Messaging.InboundEmailHandler. It was working fine until now, but now I am getting Invalid type: EmailMessage while editing the class. And, when testing the ...
Ruturaj Chothe's user avatar
0 votes
0 answers
177 views

line -1, column -1: Method does not exist or incorrect signature: void executeBatch() from the type Database Stack Trace: null

I keep getting this error for every Apex Test when trying to move this Apex Class to production. It is an updated version to an old class that I did not make. I could not write this myself but I only ...
Kole Meehan's user avatar
0 votes
0 answers
39 views

Help with Test Class for Before Insert Trigger [duplicate]

I created a trigger for a custom object (Event Registration), before the record saves the trigger will search Salesforce for the contact in a certain record type, if it exists attach the contact. If ...
Dorel's user avatar
  • 1
1 vote
1 answer
597 views

How can I execute a global Apex class from the Anonymous Apex window?

Hi I have a managed package installed in an org with several global classes. Which are documented as the following: Apex class - global with sharing class FeatureConsoleService Method of Class - ...
plateaued1's user avatar
0 votes
0 answers
301 views

Updating Test Class

I am super new to Apex and am trying to update some code in production. I have it working in a sandbox but the problem is getting enough test coverage. I didn't write this so I am trying to work with ...
Michelle Busch's user avatar
0 votes
1 answer
482 views

How to mock a file attachment size in Apex Salesforce to test

I have to test a method that return a boolean false when the attachment upload is bigger than 25 megas, I tried to test this one using the code below but there is a limit dml exception string too long,...
GRC7's user avatar
  • 3
-1 votes
1 answer
471 views

Multiple payloads sent to REST api endpoint from Apex Trigger issue

When we create/update a Case , we send those details/data/payload information to our REST api endpoint via SF developer console using APEX Trigger + Class. The Case has few lookup/mapping fields to ...
That Coder's user avatar
0 votes
0 answers
35 views

I can't implement the test class - List has no rows for assignment to SObject [duplicate]

I was able to create a class that gets the data of an opportunity (the ID is passed by GET) and displays a form on a VisualForce page that allows sending an email with invoice attached... Everything ...
Fran Bedia's user avatar
0 votes
1 answer
107 views

System.debug message only shows in logs when outside of classes or methods in VScode

I'm trying to see the system.debug message in the output console log when I run the SFDX: Execute Anonymous Apex with Editor Contents, but it doesn't seem to want to appear. I've seen a lot of ...
KB2021's user avatar
  • 83
1 vote
1 answer
236 views

Lightning Web Component (LWC), Can I include both in identifier reference and hard-coded value in class attribute?

I can put an identifier in the class attribute of an element in a Lightning Web Component; double-quotes are omitted. <th scope="col" class={flexipageRegionWidth}> Or I can put a hard-...
Ken's user avatar
  • 430
0 votes
1 answer
194 views

Compile Error: Invalid type: ApexStepRequest

I am trying to follow the example in the developer guide: (https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_json.meta/bi_dev_guide_json/bi_dbjson_steps_types_apex.htm#...
nelly askjer's user avatar
-1 votes
2 answers
290 views

Not able to extend class in already defined Global class

I have a Global class that is part of a managed package of my developer org. In that class, I'm trying to extend another managed package Global class but getting an error as Type is not visible: ...
Vijay N's user avatar
  • 23
0 votes
1 answer
2k views

Sort a list alphabetically

i have a multiselect picklist field Roles and i was trying to get the values in alphabetical order based on that(Roles) field.The method is as follows public static List<opportunityRoles> ...
Tency Serah's user avatar
0 votes
1 answer
456 views

Error:Method does not exist or incorrect signature: void add(List<Contact>) from the type List<List<GetContact.methodOutputs>>

I am trying to pass a firstname and lastname to an invocable method and get a list back of contacts filterd on firstname and lastname but get the error before saving my class: Method does not exist ...
Thomas's user avatar
  • 2,310
1 vote
2 answers
133 views

Apex Model : Illegal Value for Primitive

I was trying to avoid posting this on here with so many threads on this topic, but I am really hoping someone can help me figure out what I'm missing here. I keep receiving an "Illegal Value for ...
nigeldendy's user avatar
0 votes
1 answer
761 views

How to handle and get duplicate values after receiving the duplicate value error message

I'm working on a batch that inserts members to a campaign, the insertion is done with a csv file. Now i have been trying to handle any duplicate values as well, to avoid errors but mostly i would like ...
Toris's user avatar
  • 17
-1 votes
2 answers
194 views

Can we add the debug statement without a method?

I am new to programming world and i have this Doubt public class new { integer h=10; system.debug(h); } this code is not working untill i create a Method and add this debug statement!!! is it ...
ASHWIN TIWARI's user avatar
0 votes
1 answer
73 views

CPU Time limit exception inside trigger

Facing issue while running the trigger , However unable to find the issue as code is moreover optimised and using map already. Logic is on the basis of field A and B find related record in another ...
Marvel's user avatar
  • 17
1 vote
1 answer
421 views

Insert or update campaign member after if condition

I'm trying to check if a campaign member has already been entered in a campaign in case affemative update the status otherwise enter the member. This is my code, but currently it doesn't work very ...
Toris's user avatar
  • 17
2 votes
1 answer
644 views

Populate lookup field - Apex class

Is it possible to populate lookup field on Case with ID of custom object using Apex Class? We have 2 fields and 1 object: RC__c on Account (picklist) Responsibility_Center__c on Case (lookup) ...
ApexNewbie's user avatar
1 vote
1 answer
353 views

Send Email to list of Contacts in Cases

I have a problem writing an Apex class which will send the emails to the list of Cases based on specified criteria from scheduled flow. Here is my code: public class EmailClass { @InvocableMethod ...
NewToApex's user avatar
0 votes
1 answer
261 views

Can't reference variable outside of for loop

I am trying to see if the map is changed (rate_card__c) and then query all of the members associated with that id. And update with the rate card. We have business accounts and people accounts a person ...
SoleHack's user avatar
  • 115
-2 votes
1 answer
343 views

use method() from other apex classes into the VF page [closed]

Can we use method() from other apex classes into the VF page directly and by not using the controller of that VF page? In Java, we can use package and do so, but I have no idea what to do with the ...
RAJAT MAJUMDER's user avatar
-2 votes
1 answer
34 views

in test class should pass lastweek is not equal to currentweek [duplicate]

Main class global with sharing class FCSTWeeklyCopyBatchCtl implements DataBase.Batchable<sObject> { public Date todaysDate; public String dayOfWeek; public Date mstartDate; ...
satya's user avatar
  • 1
0 votes
1 answer
63 views

Issue in test class for a trigger [closed]

I am writing a test class for a trigger and in the trigger and the helper class the code is to generate contract numbers according to the record types. @isTest public class ...
PJ98's user avatar
  • 25

1
2 3 4 5
22