Questions tagged [class]
A class is a template or blueprint from which objects are created. An object is an instance of a class.
1,072
questions
2
votes
1
answer
83
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 ...
1
vote
1
answer
30
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 ...
-3
votes
0
answers
22
views
How do I write a test class for this trigger? [duplicate]
trigger PreventChecklistAgendaItemRecordsFromDeletion on EN_Agenda_Item__c (before Delete) {
List<RecordType> recordtype = [Select id,Name,SobjectType from RecordType where Name = 'Checklist'...
0
votes
1
answer
37
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 ...
0
votes
1
answer
55
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 ...
-1
votes
1
answer
17
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) {
...
0
votes
0
answers
31
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 ...
0
votes
0
answers
44
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 ...
0
votes
1
answer
48
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-...
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 ...
-1
votes
2
answers
86
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 ...
0
votes
2
answers
47
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 ...
0
votes
2
answers
213
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 ...
-2
votes
1
answer
119
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')
...
0
votes
0
answers
115
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 ...
0
votes
0
answers
130
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 ...
0
votes
0
answers
38
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 ...
1
vote
1
answer
293
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 - ...
0
votes
0
answers
159
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 ...
0
votes
1
answer
262
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,...
0
votes
0
answers
54
views
Dom.XmlNode Query Not Working As Expected for Map
Let me preface this by saying I am not a developer. I'm simply trying to reuse existing code that we have in our system to expand its functionality to another object.
That said, I have an Apex class ...
-1
votes
1
answer
385
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 ...
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 ...
0
votes
1
answer
83
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 ...
1
vote
1
answer
214
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-...
0
votes
1
answer
164
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#...
-1
votes
2
answers
191
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: ...
0
votes
1
answer
1k
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> ...
0
votes
1
answer
352
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 ...
1
vote
2
answers
96
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 ...
0
votes
1
answer
583
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 ...
-1
votes
2
answers
145
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 ...
0
votes
1
answer
68
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 ...
1
vote
1
answer
302
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 ...
2
votes
1
answer
508
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)
...
1
vote
1
answer
267
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
...
0
votes
1
answer
250
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 ...
-2
votes
1
answer
181
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 ...
-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;
...
0
votes
1
answer
1k
views
Call method in another class
I have UtilityController class for creating new records of custom object: Exception_Logs__c.
How to call this class inside another class? So if error occured, then the Exception Log will be created.
I ...
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 ...
0
votes
2
answers
315
views
How to get field value sobject in batch class [closed]
global class DeleteBulkRecordBatch2 implements Database.Batchable<SObject>, Database.Stateful {
String query = '';
String sObjectType = '';
List<String> list_Employee= new ...
0
votes
0
answers
399
views
Batch Apex error: Method does not exist or incorrect signature: void executeBatch(LeadProcessorTest) from the type Database
I'm working on the Use Batch Apex trailhead module and am getting an error on deployment.
force-app\main\default\classes\LeadProcessorTest.cls Method does not exist or incorrect signature: void ...
1
vote
1
answer
549
views
Apex Class CallOut
I'd like to apologize in advance as I'm quite new to writing APEX Classes / Triggers.
I've followed a tutoriel of which the aim is to POST a comment to an external system, in this case it's Jira.
I ...
0
votes
0
answers
268
views
Batch test class passing but not covering execute method
public with sharing class ContractBatch implements Database.Batchable<sObject>,Database.Stateful{
public Database.QueryLocator start(Database.BatchableContext BC){
return Database....
0
votes
1
answer
472
views
Show popup with confirmation button using addMessage and commandlink
I have a requirement where I have to create a popup (using addMessage) that display two options: confirm and cancel, each of these options has an action.
I already tried passing a command link in the ...
3
votes
2
answers
373
views
Create an reactive auxiliary class in the LWC component
I've tried to create auxiliary classes in the component folder to divide logic into smaller parts, but I can't make the data on the page refresh.
for example:
Example file structure:
component/
|-...
0
votes
1
answer
372
views
Test Class Not Covering Return [duplicate]
My test class doesn't seem to cover any of the return methods within my apex class, therefore only giving me 69% code coverage, and I can't deploy into production.
Apex Class - Main
public with ...
0
votes
1
answer
56
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 ...
-1
votes
1
answer
339
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++)
...