Questions tagged [class]
A class is a template or blueprint from which objects are created. An object is an instance of a class.
1,064
questions
0
votes
0
answers
35
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 ...
-2
votes
0
answers
17
views
I want to show sub folders from folders where type is Report and Dashboard bt in a tree view i want to add all data in wrapper class
I have this Query
can anyone please help me out
SELECT Id, Name, CreatedDate, AccessType, Type, CreatedBy.Name,
(SELECT Name FROM SubFolders ) FROM Folder WHERE Type = 'Report'
1
vote
1
answer
35
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
104
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
68
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
43
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
134
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
32
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
86
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
109
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
122
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
255
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
104
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
65
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
0
answers
19
views
Test class for handler class [duplicate]
public class IsGlobalMemberHandler {
public static void checkGlobalMemberAfterInsert( List<OrderApi__Subscription__c> LstOfSubs){
List<Account> updatedAccLst = new List<...
0
votes
1
answer
206
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
67
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
53
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 ...
0
votes
0
answers
13
views
I need the ContentVersionFilterTest class and ContentDocumentLinkEnricherTest, I'm not able to do it, can someone help? [duplicate]
Class 1: ContentVersionFilter
Class 2:ContentDocumentLinkEnricher
1
vote
1
answer
125
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
237
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)
...
0
votes
1
answer
87
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
162
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
83
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
0
answers
40
views
I want to use Upsert operation in my handler class
I have One trigger and one handler to call my two batch insert and update batch class.
when running the code I get an error(error:>> first error: UNABLE_TO_LOCK_ROW) when I do update and insert ...
0
votes
1
answer
473
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
59
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
0
answers
66
views
how to delete record in Contact field have other picklist value
My batch Class:-
global with sharing class DeleteBulkRecordBatch2 implements Database.Batchable<SObject>, Database.Stateful {
String query = '';
String sObjectType = '';
List<...
0
votes
2
answers
150
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
248
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 ...
0
votes
1
answer
199
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
73
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
0
answers
14
views
Hi i have to write test class for following trigger handler class? can anyone help me in same. Code is mentioned below [duplicate]
public class ActionsToBeTakenTriggerHandler {
public static void handleAfterUpdate(List<Actions_To_Be_Taken__c> atbtList, Map<Id, Actions_To_Be_Taken__c> oldMap){
if(atbtList !=...
0
votes
1
answer
282
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
245
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
0
answers
330
views
Failed to invoke future method error
I am constantly getting an email with the error below. I have tried changing the setTimeout value and that does not seem to work. I am not sure if it is the code that is causing it or maybe the ...
0
votes
1
answer
250
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
50
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
202
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++)
...
0
votes
1
answer
364
views
Need to insert New Event Date and time in Account Field (Event Date Time (manually created)) through Apex Class/Trigger [closed]
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/...
0
votes
1
answer
438
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 ...
0
votes
0
answers
58
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 ...
0
votes
1
answer
147
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 ...
-3
votes
1
answer
50
views
Illegal assignment from List<String> to List<Order> (4:21)",
Im having this issue which I dont understand. Any advice?
-2
votes
1
answer
79
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; ...
2
votes
2
answers
173
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.
0
votes
1
answer
41
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 ...
2
votes
1
answer
261
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 ...