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

How to test a List<SelectOtion> in unittest

How to test a List<SelectOtion> in unittest. I have the following apexclass public class WebToObjAttachments { .. public List<SelectOption> CountryOptions { get { ...
0
votes
1answer
32 views

Need to write an apex class to take in a custom object id and receive a list of related object Ids from that custom object

I am new to salesforce and to coding in general and I am struggling to understand how to correctly write this class / SOQL query. Any advice or guidance would be appreciated. I need to specifically ...
0
votes
2answers
17 views

How to get language from visualforce into into controller extension

I am using a force.com site to show a visualforce page where I want the user to have the option to select a language. In the corresponding visualforce page I set the language. How do I get this into ...
0
votes
1answer
21 views

how to refer a record type in a apex class [duplicate]

I'm writing a Apex class to auto delete Case records of record type claims and service failure with created date older than 6 Years here is the code. But i'm failing to Refer the record type in the ...
0
votes
0answers
35 views

How to access a properties' get accessor of another instance within its class?

I have a simple class with a property and a parent that is of the same type. public class BasicProperty { private BasicProperty parentProp; private Integer myCounter = 0; public Integer ...
0
votes
0answers
18 views

Error is displayed while clicking on file link to open

while clicking on the file link to open the file, it is displaying an error as shown below Unable to Access Page The value of the "file" parameter contains a character that is not allowed or the ...
0
votes
1answer
21 views

Return an Instance of a Class in a LWC (Lightning Web Component)

Below I am Trying to Return an Instance of a Class to a LWC JS to then handle and display to the End User. I am able to successfully call the Apex Class and Method and return data, but the data is ...
0
votes
1answer
20 views

can i call my apex class by just the url

Here is my ( i have tested with workbench and it does work) URL to call : /services/apexrest/ContactUpdatetService.SetContactInactive my json: { "contactId":"1234", } Can I just call it by doing ...
0
votes
1answer
28 views

How this method call works? 'Schema.sObjectType.Contact.isDeletable()'?

I'm struggiling to understand this line of code: Schema.sObjectType.Contact.isDeletable() I've read on the Apex Developer Guide that isDeletable is a method of the DescribeSObjectResult class that ...
0
votes
1answer
20 views

How to add pick list value into test class dynamically

I want to add pick list value in test class i.e when i select pick list value it should be updated/added in the corresponding test class
0
votes
1answer
16 views

How to start bach proces from anonymouse window

I Have the following batch process. How do I test this from an anonymous window? global class Batchtest implements Database.Batchable<SObject>{ .. }
-2
votes
0answers
24 views

Not covering Map<String,Object> and pushnotification method in test class [duplicate]

Can anyone help me in increasing coverage of below class which is just 31%.I am trying to insert data to cover all if-else conditions and pushnotification method but unable to do so. public without ...
-2
votes
0answers
29 views

Test class not covering [duplicate]

Need help in test class.Not able to cover these lines:- careTeamUserMap.put(userRec.AccountId,userRec); wrap.hcpImage = careTeamUserMap.get(caseRec.APS_HCP__c).SmallPhotoUrl; ...
0
votes
2answers
35 views

How to insert or escape single quotes at beginning and end of a null value or replace null with single quotes only

I have this method below that Returns a String of Id's separated by '|' operator and it works. However now I would like to add on that if an Id is null or blank replace with just single quotes (''). ...
0
votes
1answer
30 views

How to make a Json object a subclass

I have a Json Object which I created with the online JSON to apex tool. This works a a separate class how can i make this a subclass. I get the error: Inner types are not allowed to have inner ...
-1
votes
1answer
36 views

Help with LeadConvert Trigger Class? (Creating multiple contacts from one lead)

I've written a few classes for this trigger i'm working on and while I can get 100% coverage for these classes and I can't get more than 0% on the trigger. In the sandbox, this trigger works just ...
0
votes
0answers
17 views

Measuring Monthly Targets in Salesforce

I need to measure my Sales team's monthly target. I have setup a custom Object Monthly_Target_Details. I have target date and User (Lookup)field and Opportunity (Lookup)field. My requirement is to ...
0
votes
0answers
18 views

How to separate classes into custom folders

I'm new to salesforce and I am really intrigued by the folder "structure" of the system. Hundreds of classes are stored just in /src/classes/. I tried sfdx with vs code, but just in my new trailhead ...
0
votes
0answers
17 views

Access Parent inner class using child class name

I was working integration part, so i need to create a few DTO sample to convert JSON to Object and Object to Json. In my case most part of the Json used remains same for different request and ...
1
vote
0answers
23 views

How can I make parent class variables Invocable in flow and process builder?

I have a scenario where I have an InvocableMethod which takes a custom Class with properties which are made available with the @InvocableVariable annotation, but I want this class to extend a parent ...
-1
votes
1answer
36 views

Test class is giving only 3% coverage of apex class [duplicate]

i have a class for which have written test class as well, included all conditions in test, which are there in class. But not sure why it is giving me coverage only 3%. have done many changes in it ...
0
votes
1answer
26 views

Value of field not getting updated in test class

trigger OpportunityTrigger on Opportunity (before insert) { for(Opportunity thisOpportunity : Trigger.New) { thisOpportunity.New_Value__c ='Actual Trigger Value'; } } This is my test ...
0
votes
1answer
31 views

Show different class properties at different places

I am calling an GET API, where is am getting account details like name, number, ext Id etc. For parsing the response, i created a class like below. public class AccWrp { public String customer_no;...
0
votes
1answer
30 views

Apex class tried to execute in anonymous window

I am beginner in Salesforce and still in initial steps in understanding the concepts..i tried the below class and the output didn't come as expected public class mytest2 { Public integer marks; ...
0
votes
1answer
29 views

Update related record with batch class

I'm running a batch class over the Timesheet object and for the timesheets that meet the criteria, I want to update the related Contact record. I have a jstcl__TG_Timesheet__c object with a field ...
1
vote
1answer
127 views

Apex Loop break and continue

I want to distribute custom object records to some user. Theres 2 users inside 'assignmentList' and Im trying to distribute each records to these 2 users based on the inputted max amount of call line ...
0
votes
1answer
29 views

Bulkifying a class

I'm trying to process and update a bunch of claims within an occurrence. Please guide and assist me on how to bulkify the below code. My debugs are currently returning empty. Please assist so I can ...
1
vote
1answer
39 views

Invalid type and ID field error

Good day, I"m trying to write this class. But I'm getting an: "Invalid type:Occurence__c" error. Also it's showing invalid ID field: myOcc. Can't figure out what I'm missing, please assist. Here ...
-1
votes
1answer
47 views

How to get more than 50K records in a trigger handler from SOQL [closed]

I have a requirement where I'm getting more than 50k records for a single parent id, and I need those whole records to process them. I now batch is the best option to use but that would be time ...
0
votes
0answers
18 views

Assistance with Test Class [duplicate]

I could get a sample class to automatically deactivate inactive users in Salesforce and did some changes to it: public class DeactivateInactiveUsers implements Schedulable { public void ...
0
votes
1answer
21 views

Illegal assignment from Boolean to Casecomments__c

Please help me to get the test class for below class. public inherited sharing class BI_QuickCloseCompController { private static final String CLASS_NAME='BI_QuickCloseCompController'; ...
1
vote
1answer
50 views

How can I save a class when a batch job is running (without the Ant tool)

I am trying to figure out if we can save a class which is used in a batch job. I am unable to save a class. I can't save the class when a batch job is running. I don't want to abort the job. Is there ...
0
votes
3answers
49 views

Change account owner of Opportunity if it meets criteria in Apex Class

I've written an apex class to update all Opportunities which meet a certain criteria. I understand how to change the fields values on that specific opportunity, but am confused to how I would change ...
1
vote
1answer
38 views

How user is able to Update Record

I have a custom object whose OWD is Public Read/Write and the profile of user has Read and View All permission for that Object. Now I have a Custom Button on that Object using Aura component I'm ...
1
vote
1answer
34 views

Schedulable Apex Class to update fields in Lookup record

I have a Custom (Managed) object called Individual Email Result (et4ae5__IndividualEmailResult__c) which contains a Lookup field to a Contact record (et4ae5__Contact__c) and I want to create a ...
2
votes
2answers
130 views

Push a custom string in a SOQL result

I'm not really sure if this is possible because i'm newbie but, can I push a custom string into a SOQL result? I tried this code multiple times and i also modified it but i can't get the result i ...
-3
votes
1answer
25 views

Need help Schedule Test Class for tast create on Opportunity

I need help on the test class for this schedule on Opportunity. Getting error on below code with comment and only 35% coverage code. global class OppJob_Task_1stPhoneFollowup implements Schedulable { ...
0
votes
1answer
40 views

I have written a trigger and class to first create an account and then 10 identical opportunities. It is working but only creating 1 opportunity

trigger IdenticalopportunityAccount on Account (after insert) { List<opportunity> oppt = new List<opportunity>(); for(Account acctOpp1 : Trigger.new) { if(acctOpp1....
0
votes
1answer
44 views

Using HttpResponse in a seperate class from future

I have written a trigger that calls a class which contains a future method and I need to use the response to update a field. Is there anyway to capture the HttpResponse in a separate class? public ...
0
votes
0answers
37 views

Apex Trigger Error

Here is my Apex Class: public class NavProductHelperClass { public void checkProductAvailability(list<OpportunityLineItem> opids) { for(OpportunityLineItem oli: opids) { ...
0
votes
0answers
49 views

Picklist field value being mapped does not display on original object but does display on mapped object - change code to show on both - how?

I am still learning and have created this code that triggers when: On Enrollment (custom object) When the user changes the enrollment status (picklist field) to 'graduated', it populates the ...
1
vote
1answer
103 views

System.TypeException: Procedure is only valid for System.DmlException and System.MailException

I am trying to send an object(Account) as a parameter from my batch class, I am getting this exception. FATAL_ERROR System.TypeException: Procedure is only valid for System.DmlException and System....
0
votes
0answers
20 views

How to write a test class for the below mentioned trigger (code) [duplicate]

trigger IdentialContact on Account (after insert) { List<contact> cont = new List<contact>(); for (Account acct : Trigger.new) { for (integer i=0 ; i<2 ; i++) { ...
0
votes
0answers
30 views

Deployment Failed Developer Edition

I can't save a class in a developer org. I receive this error: "Can't alter metadata in an active org". How can I resolve this problem?
1
vote
1answer
30 views

Variable does not exist: hed__End_Date__c

public class UpdateGraduated { public static void WhenGraduatedUpdate(List<hed__Program_Enrollment__c> enrollmentListUpdate){ try{ List<hed__Program_Enrollment__c> ...
1
vote
2answers
91 views

Attempting to pass current record's ID from trigger to Class

Code novice here! I am trying to pass the OpportunityContactRole's Opportunity ID from a trigger to a class to a Flow. I would happily use a Process Builder to trigger the Flow but OCR's are yet to ...
-2
votes
1answer
42 views

How to exclude classes and triggers from change set validation

I'm validating a change set and getting the code coverage error stating your orgs code coverage is less than 75% i do not want any apex classes, testclasses, triggeres to be run while validating a ...
0
votes
1answer
23 views

Static method cannot be referenced from a non static context - Test Class

I'm trying to write a test class for this class but not sure how to provide code coverage for what I'm doing here. In my class I'm just running a query, looping through the query and creating a list ...
2
votes
1answer
48 views

I'm trying to create an APEX Batch Class on custom object, but getting an error

Getting an error when trying to create this batch class. Could you advise what I'm doing wrong? Error: Compile Error: Class LocationProcessorBatch must implement the method: void Database.Batchable....
0
votes
0answers
53 views

Create test class to achieve 75% code coverage needed for a Apex Trigger and Class [duplicate]

I wish to update a field from one custom object (Career Path) to another object (Contact details) based on whether a checkbox (Current) is true. Essentially, it updates the Contacts details with the ...

1
2 3 4 5
19