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
37 views

Apex Class Code Coverage issue when using Class to run test for Trigger

The following trigger has 75% code coverage, but it fails to have code coverage when I use the test class below during the deployment. Apex Trigger: trigger PublishedDate on OpportunityLineItem (...
1
vote
1answer
28 views

Test Class for Business Hours Check

I am trying to build a test class for my new trigger and part of the trigger is to check current time against the org business hours then set it as a boolean yes/no. Code: DateTime now =system.Now();...
0
votes
0answers
14 views

Apex Code Coverage for if/else if test class [duplicate]

if (userList.size() > 0 ) { String profileName = userList[0].Profile.Name; if (profileName == 'CP_CorporateAdminUser' || profileName == CP_SystemConstants.CORPORATE_OPERATION) { ...
0
votes
2answers
33 views

Confusion regarding save order of execution

I have created a number field in the contact object and created a trigger which is adding one number to the number field, a workflow doing the same, and a process builder doing the same now I have ...
0
votes
0answers
18 views

Messaging.PushNotification : change structure of payload

I'm building an app on iOS and Android using react-native without the Salesforce Mobile SDK. I want to be able to send Push Notification to the app using Salesforce PushNotification class in Apex. ...
0
votes
2answers
45 views

Extracting Dynamic String from a String

In the below Email body, I need to grab the External Account Id (4891 in the below example), however, that text can be between 4 and 8 characters long. Once I have the ID I'll find a matching account ...
0
votes
1answer
23 views

Enable Default Email Templates in Case Feed is not working

I am trying to enable the default email template selection logic as per the salesforce provided document - https://help.salesforce.com/articleView?id=case_interaction_default_templates.htm&type=5 ...
0
votes
1answer
41 views

Modal content not displaying correctly

I am creating a lightning component that pops up from a button on Opportunity. In this lightning component I am using multiple recordEditForm tags that are just outside tab tags. When setting the ...
1
vote
1answer
25 views

How to select the language of a custom label in Apex Class

I have an Apex class which sets the subject and body of an email using custom labels. The new requirement is to set this text per the language selected using a picklist field on Quote object. For ...
0
votes
0answers
23 views

Need Help for Apex Test Class [duplicate]

i have a problem with test code coverage of my trigger: that's the code: public class OpportunityLineItemTriggerHandler{ public static Boolean isTriggerFire = true; public static void sync(Set<Id&...
0
votes
2answers
40 views

Combine two different PDFs in single Visualforce page?

I have used below visualforce code to display two pdf in a single page but in the result, I am getting two different PDFs with two sections with iframe. Is it possible to combine these two PDFs in ...
0
votes
1answer
35 views

How to deep clone a batch class?

I have tried deep cloning on the opportunity object which has closed won stages it will also clone the Related Products I have tried cloning the opportunity and it works okay,how will i deep clone it?...
1
vote
0answers
24 views

Populate a Lookup Field Upon Record Creation

I am trying to create a trigger that will populate a lookup field on a custom object called Levvel Forecat. The basic criteria here is that when a new Levvel Forecast record is created with a ...
3
votes
3answers
68 views

Apex more than 50 Queueble jobs

I have this class that call a Queueble job more than 50 times in a loop. I recive the error: Too many queueable jobs added to the queue. The limit is 50. Here is the class: global class ...
1
vote
1answer
96 views

LWC: Can I have an expression and a string as a class combination?

I have a div and I want to assign one css class statically and one dynamically. Something like this: <div class="my-class + {dynamicClass}"></div> However that is not working and I am ...
4
votes
1answer
58 views

Need help in optimizing the below helper class

Logic : For any new record inserts for 'Properties' object, check if its Account_Ref_Ext_ID__c equals to 'Account' object's Chris_Account_Number__c. If it matches, assign Account id to properties ...
1
vote
2answers
130 views

LWC: Removing a class name on scroll

I am trying to remove a class name once the user has scrolled a certain amount. In my JS file for a LWC I have the following: import { LightningElement, wire, api, track } from 'lwc'; function ...
0
votes
1answer
32 views

Scheduling Flow

I am trying to create a screen flow that is scheduled in Salesforce. From the screen flow I call an Invocable method where I pass my input parameters from my screen flow. From there I call a future ...
1
vote
0answers
21 views

Batch fails to deploy

I have a batch that I uploaded into Production successfully on July 20th and then a change to that batch on July 27th, both with no issues. I needed to make another change to that batch today, so I ...
0
votes
1answer
32 views

Error saving classes

When trying to save these two clases highlighted in the photo, you are encountering the error "Invalid api version: 0.0" as highlighted in the image.
0
votes
1answer
26 views

Issues with this Test Class for this Opportunity Trigger

I have created a trigger that on clicking the Sync Quote button it will update Opportunity Products with custom fields our organization needs to put into the accounting system trigger ...
0
votes
1answer
29 views

0% coverage on trigger [duplicate]

I have a working trigger that I'm starting to build my test class for. I've done a few lines and ran a test to make sure it's working as it should and everything seems okay, except the trigger itself ...
-2
votes
2answers
64 views

Attempt to de-reference a null object - error in test class

I am trying to update business unit field in business_unit__c custom object. for this we have used custom settings in trigger and if manually any sales rep is creating based on their role we created a ...
2
votes
1answer
110 views

Where or how can I find what interfaces an out of the box Apex class implements?

Is there a method of discovering (or a place to look up) all of the interfaces that an out of the box Salesforce class (Like LoginHistory) implements? The reason I ask: I'm attempting to test a ...
0
votes
1answer
30 views

Apex classes in Trigger body

We can write apex classes in trigger body and these apex classes will be considered as inner classes as outer class will be trigger class/body. Is there any use case we can define classes in trigger ...
0
votes
0answers
18 views

class test for controller [duplicate]

I need some assistance writing a test class for this extension controller : public with sharing class ControllerOppRel { public Product2 opptyList; public ControllerOppRel (ApexPages....
-1
votes
1answer
32 views

How to Unshare Record By using shared date

I want to Unshare records by Query which I shared 1 month ago. List<CustomObject> rec = [SELECT Id, CreatedDate FROM CustomObject WHERE CreatedDate <Whatever Date]; How I can get Shared ...
0
votes
0answers
41 views

Return Null loses Parameters in Visualforce Page

I have a Savepoint set in apex controller. Inside the try block, I am having Pagereference set to redirect to newly created record id page. On Catch block, I simply want to put return null so that ...
4
votes
1answer
70 views

Apex Class Deployment: duplicate value found: <unknown> duplicates value on record with id: <unknown>

As many others have already done, I am providing yet another cautionary tale of the elusive, misleading, and downright frustrating, magical error: duplicate value found: <unknown> duplicates ...
0
votes
1answer
56 views

with sharing without sharing vs extension?

While going through manuals, it was mentioned Many times that apex classes will not consider security of logged in user but it will run in system mode and we should add custom controller extension to ...
-4
votes
1answer
58 views

Test class for below class [closed]

public class ExampleClass { public static void publishCaseUpdateNotifications(List<Case> cases) { List<Case_Updated__e> notifications = new List<Case_Updated__e>(); for ...
0
votes
0answers
36 views

How to disable the trigger in production with the custom label

I have one trigger onAccount which is not allowing me to insert update new Accounts to other objects so I would like to know how could I disable the trigger/class in the production without moving in ...
1
vote
1answer
32 views

How to add a generic method for Encryption and decryption when using multiple times in the code?

I am trying to encrypt two fields when record is submitted using VF page. As there are multiple functions in my class I am encrypting and decrypting multiple times as needed. Is there a way we can ...
-1
votes
2answers
199 views

count of number of occurrences of the words in the sentence passed to the method [closed]

How do I code a method which expects a string and prints the count of number of occurrences of the words in the sentence passed to the method. Sample Input/Output : Input : My Name is good and I ...
0
votes
1answer
42 views

How to rank Users depends on a custom field in apex? [closed]

Question in detail : I have 20 Users {U1, U2, U3....} and 5 Regions {R1, R2, R3, R4, R5} and Ammount__C custom field on User. Now those users are distributed among those regions. So i want to give ...
2
votes
2answers
109 views

FIELD_INTEGRITY_EXCEPTION, High Volume Portal Users cannot have a user role - Test class

The user role created below is not 'High volume Portal User' but, still production deployment validation fails with error "FIELD_INTEGRITY_EXCEPTION, High Volume Portal Users cannot have a user role". ...
1
vote
0answers
14 views

Need help for create the test class [duplicate]

I'm a new developer and it's my first test class. I need your help to do it the class test for my helper class. HELP ME PLEASE!! @isTest public class TestOrderWizardHelper { static ...
0
votes
0answers
39 views

Call a field inside a class dynamically

I have a JSON that I get as a webservice and deserialize it into classes. The classes are : public class DataStructure{ public String Name; public String Code; public String ...
0
votes
1answer
77 views

We want to get a list of lead and opp. that have the same date (custom fields) in the record as the actual shown lead

What we did so far... We created a visual force page that calls a class and added an extension to get the ID. We got some Error :) (We try to get the ID for the currently displayed Lead, which ...
4
votes
3answers
187 views

How to assert on pagereference where the endpoint of pagereference is predefined [duplicate]

I have a pagereference for which I want to write a test class but get the error Expected: System.PageReference[/CustomLoginPage], Actual: System.PageReference[/CustomLoginPage]. What am I doing wrong:...
0
votes
1answer
40 views

Using without sharing methods inside with sharing class (with sharing applied)

I have a controller ControllerClassA which is with sharing. And i also have another class HelperClassB which is without sharing. I have a method inside a without sharing class HelperClassB which is ...
0
votes
0answers
132 views

Open Add Product page in lightning

I want to display the add product to opportunity price book page(/p/opp/SelectSearch) in lightning. We override the opportunity edit screen with VF and then redirect to this page: ...
1
vote
1answer
39 views

Command Button not saving!

The command button on my Visualforce page is not saving edits to the record. Any help is appreciated! Visualforce Pg: <apex:page action="{!redirectToPartnerships}" extensions="EditExtensions" ...
0
votes
0answers
18 views

Help writing a test class for apex class I want to deploy to prod [duplicate]

Public Class controller_SoqlQuery { public List<AggregateResult> medOppsCount{get;set;} public List<AggregateResult> nonMedOppsCount{get;set;} public List<AggregateResult&...
0
votes
0answers
32 views

How to write Apex test for record creation? [duplicate]

I'm having a hard time writing up a test class for the following Apex class: public class logger { @AuraEnabled public static void insertLog(string name, string id, string location, string ...
0
votes
1answer
56 views

Access Object in Apex Class / Method after passing it from Controller

I (seemed to) have sucessfully passed an object from the client side helper controller into the apex method. However i am having trouble accessing using the dot notation i am used to in javascript and ...
0
votes
0answers
22 views

write a test class for a StandardController [duplicate]

My Controller: public class GeneratePDF { ApexPages.StandardController stdController; public Contact cnt {get;set;} public GeneratePDF(ApexPages.StandardController controller){ ...
0
votes
1answer
45 views

isAfter && isUpdate is not triggering [closed]

So I have created a trigger and a trigger handler class, but I cant seem to make either of them trigger in an isAfter && isUpdate call. My updateInstallStatusDesign works fine when it is an ...
0
votes
1answer
25 views

Saving multiple classes with inter dependencies

I have made some changes in an Org1 and trying to move those changes to Org2. Some classes are changed and some newly added. The classes are compilable in Org1. These classes have interdependency. ...
0
votes
0answers
128 views

System.SObjectException: Invalid field Category for Case

Class.BatchCarrierUpdate.execute: line 59, column 1 Boolean toUpdate = false; for(String strFieldName : caseToCarrierUpdatedFieldMap.keySet()){ System.debug('**...