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
-2
votes
0answers
39 views

Why is this method not running?

I am using Process Builder to call this class. Everything is running correctly in it, except it is not running the last method which I have running at the end. At first I thought it had something to ...
2
votes
1answer
19 views

Why are Apex Class Permissions being enforced in sandbox but not in production?

In our full sandbox, our QA engineer has observed that one of our Lightning Components is failing. Upon further inspection, it turns out that the Apex class the component is calling is not accessible ...
0
votes
1answer
25 views

Creating Parent and Child record in the same DML Statement - Illegal assignment from Lead to Id error

Im trying to work out how I can create a parent and child record at the same time. I've tried to base it on the example salesforce have provided https://developer.salesforce.com/docs/atlas.en-us....
-1
votes
1answer
27 views

I need to create a method in the acount trigger to keep an external id field value updated. (continue in body)

This value has to be the name of the account. Every time an account is inserted or its name changes, it is necessary to update the external id. How can i do that? thanx. Public static void updateAcc ()...
0
votes
2answers
35 views

how can i leave a field without value if the condiction is true?

for(Account acc : lstAc){ Account acount = new Account(); if (acc.Property_Managment_Company__c == 'Independent') { acount.ParentId = THIS FIELD SHOULD BE EMPTY. }...
0
votes
1answer
17 views

How do I use the OwnerID of the record to get related fields from the the user in a class?

This is what the current class looks like but I wish to do the same now with the OwnerID instead of User. public with sharing class BranchService { public static Id getUsersBranchInfo(Id ...
-1
votes
0answers
19 views

Code not covered in Apex Class [duplicate]

I'm trying to increase the code coverage and the below "UpdatePrice ();" is showing as not covered in red, but everything else is. What causes that to happen? Highlighted in red: ...
0
votes
2answers
38 views

Apex coding issue

My executive anonymous window is unable to synchronize with classes;For eg In anonymous Window i wrote: Public class Dog { Public string name; public integer age; public void bark() { System.debug('...
0
votes
1answer
21 views

i'm testing a batch. In the last block i have to verify that the list is not empty and the name equal to 'Kinder'. How can I do that?

@isTest public class QWE_Integration_BatchTest { public static testMethod void metodoTest(){ QWE_Integration__c rec = new QWE_Integration__c(); rec.First_Name__c = '...
1
vote
0answers
38 views

Create an Apex class with a method that returns an array (or list) of string hands-on challenge

I am trying to get on with the Create an Apex class with a method that returns an array (or list) of string hands-on challenge but when I try to check the challenge I get the following error: "...
0
votes
2answers
43 views

Test Data - Static Resources

I have many custom objects with lots of relationships and i want to create some test data for my test classes. For example, i have the Objects Account Opportunity Basket Product Configuration Product ...
0
votes
1answer
50 views

Else if part getting skipped Salesforce Apex

I wrote this class with a method that sends an email from Sendgrid based on each template id. It works fine except, I have an if else statement which only runs the if and else part and not the else if....
0
votes
1answer
29 views

Method does not exist or incorrect signature: void sObjectsInsert(Integer) from the type AccountHandler

Hi all new to Apex here completing Trailhead... I am receiving the error in the title and can't seem to figure out why. Here's my apex class: public class AccountHandler { public static void ...
0
votes
1answer
45 views

How to call a method on a trigger handler class from another trigger handler class

I am using a trigger framework that works quite well. However, I don't know how to call a method on a trigger handler class from another trigger handler class. I am trying to avoid a separate helper ...
0
votes
1answer
23 views

UNABLE_TO_LOCK_ROW while running two or more tests

I'm trying to run two different test classes, but every time I do this, one of them shows error on the setup method, right in the line where I'm going to insert a new user. Is there a way to fix this? ...
0
votes
0answers
16 views

Helper & Trigger Testing Assistance [duplicate]

I am using a similar format for a trigger and helper class. Can anyone help me with a test class? Trigger Trigger TestOrders on Order (Before Insert) { IF(Trigger.IsBefore) { IF(...
0
votes
1answer
31 views

07:40:24:023 FATAL_ERROR System.StringException: Invalid id: a610V0000015C5DQAU

public void updateattendeecb() { System.debug(enteredText1); Id myId = Id.valueOf(enteredText1); list_attendees1=[Select id,Send_Email_for_Certificate__c from EM_Attendee_vod__c where id= :...
0
votes
1answer
27 views

how to write test class for batch class ? this covers only 44% [duplicate]

how to write test class for batch class ? this covers only 44% global Class Batchsample implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database....
0
votes
0answers
33 views

Error INVALID_CROSS_REFERENCE_KEY in test class when deploying to production

I'm getting this error System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] Stack Trace ... This production org is ...
0
votes
0answers
11 views

Make It Easy for Users to Find Paused Flow Interviews for a Record - Test Class

Has anyone successfully created a test class for this? https://help.salesforce.com/articleView?id=flow_pause_cmp_record.htm&type=5
1
vote
1answer
75 views

Confused with how the Protected access modifier works

I have a virtual class with non virtual and virtual methods: public virtual class ComponentVisibility { protected Id currentUserId = null; protected String currentUserRole = ''; protected ...
0
votes
1answer
26 views

No data populating In VF table. Could anyone please help?

The following code is of an api call. public with sharing class customeQuery{ // Initialization public string companyName{get; set;} public List<consoleWrap> ...
1
vote
2answers
106 views

Trigger How to stop Database.executeBatch cannot be callled from a future method error

I'm calling a trigger after insert and after update, which is calling an Apex Class which hits an endpoint. The triggers are working as expected and firing to an endpoint when a checkbox is selected ...
1
vote
1answer
24 views

Custom Apex trigger is no longer firing on contact or account creation

I have a custom Apex Trigger which calls on an Apex class to send contacts and accounts to hit an endpoint on our Server. This was working correctly until I tried to make edits to the trigger. I have ...
-1
votes
1answer
70 views

Create an Apex class that returns contacts based on incoming parameters

why is this problem appearing ? when both are contact field then both should have name field.
0
votes
2answers
33 views

Show/Hide of a div doesn't work sometimes

I have an aura:component which have two divs inside it. I run a query on my controller apex class and based on the returned value from the query, i want to hide or show any one of the div. Based on ...
0
votes
1answer
104 views

Prevent Duplicates Using Wrapper Class in Apex Class

Note* I am a beginner attempting to jump from level 1 to level 10 coding because there is no easy way to accomplish the task. I need to prevent users from inserting duplicates of a custom object ...
0
votes
0answers
23 views

How to manage Custom Setting data from Community at user level

I have Created one custom setting with email digest feature which sends a mail to user through batch classes as per record value stored For Ex- If Internal user stores as Email Digest Daily then he ...
1
vote
0answers
24 views

Class vs Interface in Patch org

Why am I able to change the access specifier for an interface in a patch org but I can't do the same for a class? I know the documentation mentions some restrictions for patch orgs. I'm assuming the ...
0
votes
1answer
25 views

Test class for updated field value

I have a class that is scheduled using CRON. I have created a test class and the test for the CRON is tested ok. However, the field update is not being tested and I cannot see why. Coverage is 57% ...
0
votes
0answers
13 views

Unable to call the Apex Callout from triggers [duplicate]

I have a apex Class which calls external ERP system and create/updates records there. The apex Class is like below public class createSegment { public class getAzureToken{ public String ...
0
votes
0answers
39 views

Button to generate specific .pdf template based on field

We have a .pdf generator setup on the quote object that generates the .pdf based on a visualforce page template. When you click the "Generate .pdf" button on the quote object it initiates a simple ...
0
votes
1answer
58 views

why @isTest is prefered over testmethod? [duplicate]

I just thinking about the reason behind the @isTest liking, as it is admired by compiler or for some other reasons Salesforce does.
2
votes
3answers
71 views

Form Map Key and Value Pair

I find this use case difficult to construct the expected map structure. Here is my use case - Let's say I have 8 quote line items with Group custom picklist field as below. Group Name Quantity ...
1
vote
2answers
55 views

Incorrect signature even though I'm correctly casting the right objects?

For some reason, my code won't compile and I'm not entirely sure why. The method accepts the following arguments public static void doSomething(Map<Id, Order> oldMap, List<Order> ...
1
vote
2answers
41 views

Child to Parent Query: Updating Parent Fields via Apex

I'm new to apex and still trying to figure things out. I'm attempting to pull the Parent data from the Child to then update. I keep receiving the error "Variable does not exist: Location__r". Please ...
0
votes
1answer
37 views

retrieve parent records and create a child records in a single class

I am a beginner in Programming. Please help me resolve this problem. I have a requirement to create a child record (on Billing Line object) if parent records (on Billing object) exist I need to ...
-3
votes
1answer
35 views

How To Write Test Class for HTTP POST Method [duplicate]

How We can Write Test Class for this Method. public static String authMethod(){ Pardot_Credential_Setting__c objSetting = customSetting(); if(objSetting != null){ ...
0
votes
2answers
27 views

List has more than 1 row for assignment to SObject process builder email apex class

An apex class is triggered by a process builder when a field value is changed. I am trying to send an email to all owners of records of a related object and I get this error. It works when there is ...
0
votes
1answer
34 views

How can I drill down to get field values of nested lists?

I have a custom data type, 'CaseOutput' that returns a list of case records. The below system.debug returns the first CaseOutput element. system.debug(CaseEinsteinHandler.getCaseStatus(listInput)[0])...
0
votes
1answer
36 views

Issue with using a Class inside a Trigger: “Method does not exist or incorrect signature”

I am currently trying to get this trigger to work: trigger ContactRelatedOpportunities on Opportunity (after insert, after update) { List<Opportunity> Opps = [SELECT Id FROM Opportunity ...
0
votes
0answers
15 views

Mass Clone Records on a Schedule

I need to mass clone about 200 records 4x a year. Quick summary of the problem I'm trying to solve. I work for a used textbook company, each school term (quarterly), we go to our school customers and ...
0
votes
0answers
14 views

Help with <Select Option> Test Class [duplicate]

I am attempting to write several parts of code that work together to show Classic formatted list views (with pages to click through) in Lightning and am barely knowledgable in HTML, CSS and sort of ...
0
votes
1answer
27 views

Inner Class Constructor

My Scenario is that I need to call the inner class Constructor from another class, Let me know how can I achieve this. Codes: public class A { // Inner Class public class W { ...
0
votes
2answers
55 views

Inner class : Attempt to de-reference a null object

when i try to add "respDetail" to "response" i get the error "Attempt to de-reference a null object", any idee ? thank you public with sharing class Process_WSI { public class Detail { ...
0
votes
2answers
329 views

How to check for null values for all variables of a custom apex wrapper?

I have a wrapper class written in following manner class Wrapper{ String name {get;set;} Integer age {get;set;} EduWrap edu {get;set;} public String returnTest(){ return '...
0
votes
1answer
28 views

Expanding on APEX Class Method

I have a class method that is assigning a Team to a contact record based on the value from another field. I want to expand this logic so that I don't have to write out multiple methods for each team ...
0
votes
1answer
62 views

Test class passing but not getting any code coverage

so I am newer(ish) to Apex still and clearly know that I am not getting any code coverage to my Apex class because I am not referencing the method, my question is how exactly would I go about calling/...
0
votes
1answer
111 views

How to test picklist controller apex class

I have a lightning component that works just fine but I need to test a controller: public class PickListController { @AuraEnabled public static List<String> ...
0
votes
2answers
33 views

Schedule for Batch

I made a Batch class and Schedule to call that class. However, I am not able to test in Execute Anonymous Window. schedule global class UpdateUserDataSchedule implements Schedulable {      global ...

1
2 3 4 5
19