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
2answers
34 views

I am new to the Salesforce platform.I have been getting “Attempt to de reference a null Object” on Custom Object Trigger.Help me to Sort the Error

Apex Trigger trigger CustObjCToPTrigger on Employee__c (before update) { set<Id> ParentIdSet = new set<Id>(); for(Employee__c e : trigger.new){ ...
0
votes
1answer
21 views

How do I call inner classes from execute anonymous or another class

When I try to call this from execute anonymous it fails and says "Type is not visible: OutterClass.InnerClass " OutterClass.InnerClass inresponse = new OutterClass.InnerClass(); System.debug(...
0
votes
1answer
30 views

How to move this redundant logic to for loop [closed]

I am trying to check if a field value is changed and based on that construct a Json. I am checking 3 fields, but it might get increased in future. How can I do this efficiently for this below logic ...
0
votes
1answer
23 views

Value is not getting populated in Number_of_Enrolments__c field

my requirement is whenever a Student Enrolments are created/deleted the Number of Enrolments field on Activity (Parent object) should be updated to reflect the count. Helper class;- public class ...
-1
votes
0answers
13 views

Test Class for PageReference method in custom controller [duplicate]

I am trying to write a test class for multiple page reference methods before deploying a visualforce page with a custom controller to production. The test coverage below isn't capturing the page ...
0
votes
2answers
18 views

Inheritance variable from Master class

Hi Everyone - I am newbie in developer community, I am working on inheritance where I am trying to call the variable of Master class intochild one but I am afriad it is not working out. Any help will ...
1
vote
1answer
33 views

Can we use custom settings in SOQL queries?

I need to use run a query based on the value in custom settings. Delete_Lookup__c is my custom settings. I need to change the output of query based on the values in custom settings. global class ...
0
votes
1answer
34 views

Apex Class & Trigger Issue

I am stuck on three errors that I cannot seem to diagnose in an Apex class and trigger combination. The class is below: public class DelegatedUserSetup { void setObjectives(User[] users) { ...
0
votes
1answer
44 views

For loop inside For

I want to avoid this For loop inside another For... Is there any way for my situation? public class ManagerAccountTeamMember { public static Boolean isFirstTimeBEFORE = true; public static ...
0
votes
2answers
23 views

Error when trying to get Cases from input

Trying to get a list of cases that are equal to the cases in the variable caseInputs but i get three errors. 1.Invalid bind expression type of Integer for column of type String->its probably ...
0
votes
2answers
28 views

open new record after finish flow

I created a visualforce page with an embedded flow. But If I click the "NEXT" button it appears the page https://domain.my.salesforce.com/Accountnull, but it should open the new account ...
0
votes
2answers
22 views

Can't retrieve information from sObject

I am new to Apex so kindly help { public static void showAccountsName() { List<sObject> AccountsList = new List<sObject>(); AccountsList = [Select name from Account]...
-1
votes
1answer
18 views

Test class are failing because of one Trigger

I am allocating a customer community user license whenever a lead is converted into contact and it's working fine. below is my code: trigger CreateCommunityUser on Contact (After insert) { ...
1
vote
1answer
95 views

test.starttest() and test.stoptest() not working

Please let me know how to resolve the below issue.I am new to salesforce,its still giving me an error Too many DML statements: 151.Using Test.starttest() and test.stoptest() is not working. Test Class:...
0
votes
1answer
50 views

user defined apex class

I need to build a wrapper that could essentially hold this format. { record: { id: 123 name: abc start: 1-jan end: 31-jan status: completed records: [{ ...
0
votes
1answer
29 views

Apex method not changing record type of an object

So Im making an Apex class that I want to push to production that will change the record type of an object, to a different record type. Here is the class below: public class removeclassy { List<...
0
votes
1answer
49 views

Virtual and Extend Apex Class - accessing parameter in child class

The first code snippet is from a separate class that calls the OnfidoAPI class which is an extension of the APIBaseUtil and passes over the parameters to APIBaseUtil. My understanding was that the ...
0
votes
0answers
36 views

Callout Error from Batch Job

I have a batch job from which I'm doing callout to wave analytics and based on the response I'm updating one checkbox field on Account. When I execute the batch with the size of 100, I'm getting First ...
0
votes
1answer
43 views

Trouble Updating Account After Delete

I have a trigger class that updates an Account checkbox field as either true or false depending upon whether or not any of the related records in a custom object contain a certain value. All works ...
0
votes
1answer
22 views

What type does the MyCustomClass.class.getName return?

public class MyCustomClass { public static void main() { MyCustomClass myClass = new MyCustomClass(); String myClassName = myClass.class.getName(); // myClassName equals '...
0
votes
1answer
64 views

test class on lead where through an error if email entered is already exists contacts

Apex Class: public class Handler_checkiftheemail { public static void TriggerHAndler(List<Lead> newLeadList){ List<string> LE=new List<string>(); for(Lead La:...
0
votes
1answer
57 views

Trigger Error: External entry point: public void invoke(): executed 1 time in 321 ms

When trying to save a record, I am shown the error insufficient access rights on cross-reference id (WITHOUT an ID). When checking the apex debug logs, I see the error External entry point: public ...
0
votes
2answers
49 views

Test class for trigger on Opportunity Object [duplicate]

@istest public class Test_TriggerOpportunity { private static testmethod void TestOnOpp(){ List<Opportunity> OppList=new LIst<Opportunity>(); Opportunity Opp=new ...
0
votes
1answer
14 views

time zone being removed from query result after putting into a generic sobject

Note i can provide full code examples for running , but for brevity i am including snippets at this time i have a query that i am dynamically retrieving all fields and placing them in an object to ...
2
votes
1answer
124 views

Insert Parent Child records from Wrapper

I have a wrapper class which has one attribute for Parent record and another list of child records. I'm getting this list of wrappers from my lightning component. Now I need to insert these records. ...
0
votes
3answers
50 views

I want to delete last letters of existing Contacts using Batch class. Is it possible? I want to delete all “sfdcpoint” letters

global class BatchApexExample implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { // collect the batches of records or objects ...
0
votes
1answer
22 views

Trouble Bulkifying Trigger Utility Class

I have a utility class for a trigger on a custom object (Territory) that is meant to query all the Territory records for an Account when a Territory record is updated. It then either sets a custom ...
0
votes
1answer
26 views

Bulkified Class?

I have a utility class for a trigger on a custom object that queries the custom object records for an account when one of the custom object records is updated and then sets a custom checkbox field on ...
0
votes
0answers
507 views

External String does not exist error when doing a validation deployment

As part of a new development, I am deploying a set of metadata. I have an ApexClass and a CustomLabel among other things. The ApexClass is making use of a new CustomLabel I am also deploying, however, ...
0
votes
1answer
28 views

Future Callout External Webservice CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, execution of AfterUpdate

When a Lead is created, I have a trigger that references a class that calls an external webservice, that digests its response, and should update a field called region_code__c from a value in the ...
0
votes
0answers
19 views

Reuqest for Run Time via REST API

How we can get RUN_TIME in Apex REST API Event Type via Apex. For example, I got Method column by METHOD__c = RestContext.request.httpMethod. Is there a way to get Run time as well? Thanks https://...
3
votes
1answer
172 views

Why some classes cannot be constructed?

when I started learn Apex, I was confused, because I cannot create date instance like: Date date = new Date(); I had to use static method Date date = Date.newIstance(...); So, why i must use static ...
1
vote
1answer
18 views

Unknown constructor issue

I have an apex class for which i get error: uknown constructor the code: public with sharing class SendDocumentCont{ public String .... public SendDocumentCont(ApexPages.StandardController c) what ...
11
votes
1answer
544 views

Best approach to safely bump up version of classes

I have a huge managed package app that I build many years ago (40% of all classes have v29 as version) and I am thinking of bumping them up all to the latest v50. Is that safe or what could possible ...
1
vote
1answer
25 views

System throwing error for simple codings

Public class StaticExample { Public static void method1() { System.debug(‘I am static method’); } Public void method2() { System.debug(‘I am static method’); } ...
0
votes
1answer
26 views

Error with system.URL.getSalesforceBaseUrl().toExternalForm()

I am not able to save below line of code in my class and I am not sure where am I going wrong. <a href = "system.URL.getSalesforceBaseUrl()+'/'+app.Main_Offer_Name__c"> Click Here</...
0
votes
1answer
37 views

export a report as a CSV with custom object [duplicate]

I want to export report with custom object that when name of report equal to field custom name report on custom object but i want that user can view all list in just select what report is want to ...
0
votes
1answer
60 views

Duplicate @AuraEnabled methods in 2 separate Apex Controllers, is it really code duplication?

so recently our code sniffer flagged 2 methods in 2 of our Apex controllers as "duplicated code" and I'm wondering if this is a false positive in this case, see example below. Both ...
0
votes
2answers
27 views

How to retrieve Apex class (Not sObject) fields in apex dynamically?

I have task to test fields from custom class and i need to find all the fields are exist and return expected data. ex: Class Person{ String Name {get;set;} integer Age {get;set;} } //in ...
0
votes
1answer
28 views

How do I cover invocable method in test class? [duplicate]

I have a simple invocable method that I'm calling from a Flow when certain criteria are met. I'm getting good results from the code as evidenced by reviewing data in the UI, but I'm not sure how to ...
0
votes
1answer
30 views

SOLVED: AggregrateResult is not returning Value

I am attempting to calculate the sum MRR of Assets related to an Account and add it to a field on the Opportunity object. The code doesn't show an error but does not return values when new ...
0
votes
1answer
32 views

How does return work?

I'm trying to understand the use of the return keyword at the end of a method. I made a class to calculate a simple value: public class Calc { Decimal monthlyWage = 32; Decimal ...
2
votes
2answers
82 views

How do you know what to include in a test class for any given trigger?

I've had a fairly simple run in writing test classes, but am not sure if I'm doing it right or adhering to best practices. Below you'll find one of my triggers and its corresponding test class (100% ...
0
votes
1answer
46 views

Trigger Helper & Trigger Utility Classes

I have a trigger and helper class (both below) on a custom object. I've been told that I should have a trigger, helper class, and a utility class as a best practice, but I have not used utility ...
2
votes
1answer
58 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
26 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
29 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
38 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
18 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 ...
0
votes
2answers
41 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('...

1
2 3 4 5
20