Questions tagged [apex]

Questions relating to Apex, the native programming language for the Force.com platform. Use it for general questions on syntax, errors, constructs, and rules of use. Most questions should include a code *excerpt* to help answerers understand specifically what has gone wrong or why you need help.

Filter by
Sorted by
Tagged with
1
vote
1answer
11 views

Apex list splice is not working

How to splice a list in apex? for(String stagename : pickListValuesList) { if(stagename == 'Closed Won' || stagename == 'Closed Lost') { ...
2
votes
1answer
68 views

id's on list are not pulling into new list

I am running into an issue with my method for test where I insert contact records that are in a list and then try to pull the id's to associate it with a different list. When I do my debug for the ...
0
votes
0answers
20 views

Not Found / Forbidden error while using GET Operation in AWS S3 folder

I'm trying to get a csv file from a AWS s3 bucket, I've access to bucket and some of the folders in it. But i'm unable to access("GET") files from one of the folder. I get an error NOT FOUND"/404 when ...
0
votes
1answer
21 views

REST API for Published Knowledge Articles

I have a simple Rest API that I've done in another environment but I have no idea why its not working. When I execute from Dev Console, it gives me: System.NullPointerException: Attempt to de-...
4
votes
0answers
28 views

Sporadic “Insufficient Privileges”

We sometimes receive screen shots from business users indicating they are seeing "Insufficient Privileges" errors. These errors come up in a variety of contexts, but they appear to mostly be ...
1
vote
1answer
27 views

Illegal conversion from List<ActiveContactListController.ContactsWithRoles> to List<AccountContactRelation>

i have this code i getting the error the following error, i'm new to salesforce developer someone can help me? public class ActiveContactListController { @AuraEnabled public static List&...
0
votes
0answers
22 views

Apex: Mapping attributes for registration handler

I'm creating a OpenID Connect registration handler. I found the following code useful and have been trying to tweak it. We are receiving "email" through our third party auth provider - and I would ...
12
votes
2answers
235 views

Is there a maximum result size for @AuraEnabled Apex methods for Lightning Aura components?

I have a Lightning Aura Component with an Apex Controller selecting a (kind of) huge amount of data. It is querying a custom object elfBCProject__c with a sub select on a child object ...
0
votes
1answer
38 views

Apex Query to TaskWhoRelation

Here is my code. Need help to find the right way to check IF logic with TaskWhoRelation.relationId instead objTask.WhoId. Any type of help will be grateful. set<Id> setIds=new set<Id>(); ...
1
vote
1answer
39 views

Page Reference issue in Lightning

I have a command link button on Account page (Create Account). As soon as a user clicks on the button, an edit page gets populated to fill the details. Once the details are filled and hit the save ...
0
votes
0answers
35 views

Error when I try to create OrderItem records Insert failed. INVALID_CROSS_REFERENCE_KEY

I'm trying to create a visualforce page where a user can create multiple OrderItem records at the same time. The error that I get is OrderItem records Insert failed. First exception on row 0; ...
1
vote
1answer
28 views

How to download all Apex classes from Prod using VS code

Now that Force.com IDE plugin for eclipse is unsupportive, is there any way to connect to Prod org using VS code and download all Apex classes. I can see all extensions for SFDX but I do not know how ...
0
votes
0answers
25 views

How to check Weekend days between two dates?

I have Three fields start date,End date and time off. If i give Time of(Number) is 4 and Start date Today, End date will update with Today+4. If i give Start date Friday and time off 3 as per the ...
0
votes
1answer
27 views

Error in Lightning Web component :afterRender threw an error in 'c:lightning' [Cannot read property 'data' of undefined]

Below is my code for Lightning Web Component: HTML File: <template> <template if:true = {files.data}> <template for:each={files.data} for:item='file'> <...
-2
votes
1answer
29 views

Render PDF for Apex Page return “PDF failed to generate” when soql row is 0

I'm having trouble trying to render PDF page when there no record return for SOQL but work perfectly fine if I add a record to the look-up field I do have additional content besides this table if ...
1
vote
1answer
16 views

Datetime Value Issue during time conversion

I have executed following code on developer console and it shows incorrect hour. Since the time used is from Seattle (Pacific time) which is 8 hours behind GMT. So when datetime.hourGMT() is used ...
0
votes
1answer
24 views

Filling a map with a query

i'm having big troubles to fill a map with the data of fields of related objects to the one that is declared as value. Map<Id,GPMIR_obj_energyLead__c> mapToMap = new Map<Id,...
0
votes
0answers
34 views

Send Email (Emailmessage) to update Lead custom field

The  lead object  has a field "Interaction count" . It is a number field. I am using this field for  an active process builder  which is working  on the below criteria: If any Task is created , It ...
3
votes
1answer
299 views

Struggling to deserialize JSON with escaped double quotes

JSON(I am working with): JSONLinter confirms this is a valid JSON. { "errors": [ { "params": { "password": "size must be between 4 and 30", "...
2
votes
1answer
172 views

Is there a way to write this code shorter?

I have something like this: @AuraEnabled public String var1{get;set;} @AuraEnabled public Decimal var2{get;set;} @AuraEnabled public String var3{get;set;} @AuraEnabled public String var4{get;set;} ...
0
votes
1answer
47 views

Process Builder Setup does not load Apex class list

On my sandbox org this request failed when I try to select Apex as an action in Setup > Process Builder: /aura?r=8&ui-process-builder-components-controller-common.ApexTypesDataProvider....
0
votes
1answer
16 views

Trying to deploy Automatic Attachment Cloning trigger between two custom objects [duplicate]

I try to deploy a trigger from sandbox tp production but my test class does not fill the code coverage of the trigger it is supposed to check. I am new to Apex (or Java) & don't know what is ...
0
votes
1answer
21 views

How to generate a stringset of s stringset with unique values

I have a string Set with a set of strings which is a combination of timestamp a recordid. How do I create a new string Set in a neat way with only the records with the latest timestamps Example: ...
0
votes
2answers
40 views

Error: Unknown Property. Need help with creating a custom app [closed]

I'm trying to display ScoreList on a VisualForce Page, but I keep getting the following error on the VF Page: Unknown Property 'Scoring.scoreList' Been stuck on this problem for a while now. Any ...
0
votes
1answer
46 views

Not responsive height in LWC [closed]

do you know if it is possible to express the height of a specific LWC in %? I want to make it responsive, actually when I try to set an height like : height: 100% it seems that the attribute is ...
-1
votes
1answer
40 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
19 views

How to restrict sales-person to download the Quote Document?

I want to restrict the sales-person from downloading the Quote documents in Salesforce CPQ. After the sales-person clicks on [Generate Document] button from quote page,it redirects to Generate ...
0
votes
0answers
24 views

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, [closed]

public void handleBeforeInsert(List<CameleonCPQ__Quote__c> quotes){ // Begin MOD011 //To prevent creating multiple Quotes CameleonCPQ__Quote__c[] quoteList = new list&...
0
votes
2answers
34 views

How to update existing records and upsert new records

I want to update existing task records but a new record gets created instead . What am I doing wrong. Apex: public static void Activities(List<Account> accounts) { Set<Id> persAccIds = ...
0
votes
2answers
45 views

How to get related list of child account to parent account that has self-relationship? [closed]

I have a use case where we have Account record and every account has a self relationship with account itself. I need to display the related list of child accounts contracts/subscriptions on the master ...
-2
votes
1answer
57 views

Help editing an Apex Trigger [closed]

I have the below code that automatically schedules our invoices to be sent out. I want this code to also automatically fire when the field Record__Type__c = Bill Only Order. How can I update the ...
0
votes
1answer
33 views

Null object not so elegantly handled after JSON.deserialize()

According to this post, returning a blank list should handle nulls. But in my case it still complains that it's expecting something but found null. Here is my class: public class PersonProfile { ...
0
votes
0answers
17 views

Retrieve contact from Task/EventRelated from Task/Event Trigger

I am trying to write the code to retrieve the contact from TaskRelated or EventRelated from Task/event trigger. we are updating a few date fields on contact through the Task/Event trigger where we ...
0
votes
0answers
22 views

How to update values on server with Lightning Component?

How can I get values selected on a drop down by a user to save to the records? I believe my issue is in my JS controller "changeDcn".. Component <!--massUpdateItemDecision--> <aura:...
0
votes
1answer
23 views

Didn't understand relationship 'param' in field path

When I Execute, the below code Loan__c param = (Loan__c)Value; List<SObject> loans = [Select Name,Amount__c, Application__c, Business_Impact__c,Borrower__c,...
1
vote
0answers
38 views

No refactorings available on Apex Classes when using VS Code [closed]

I used to be able to refactor/extract methods from VS code as documented here Now whenever I try to do this, I get an error saying No refactorings available I tried uninstalling and installing ...
1
vote
0answers
20 views

Slds-Table data making the table overflowing the horizontal scroll

I have a html table with slds-table class. The table workds fine, as it had dynamic column width based on content The Scroll goes way too long like this-- I tried using slds-truncate with slds-...
0
votes
2answers
36 views

Test Class with No Input [closed]

This is my Controller: And this is my test class: and this is the error I'm receiving:
-1
votes
1answer
12 views

NPE for the case object before insert

I am trying to write a method that goes through and creates the proper local timezone on the case object versus dates that could be done via the user since we might have different time zones for them ...
-3
votes
0answers
25 views

Need help for writing test class of callout. New to integration [closed]

System.UnexpectedException: Script-thrown exception Class.PegaCallbackService.RequestAuthorizationToken: line 29, column 1 Class.PegaCallbackService.SendValidationStatus: line 46, column 1 public ...
0
votes
1answer
25 views

How to define a constructor and pass parameters to schedulable controller

I have a situation where I need to pass a string to schedulable controller from batch or any apex controller. I see that we can do it using public constructor in schedulable implementation. Please let ...
-3
votes
0answers
18 views

Test cases for page reference [closed]

How to write test case for pageReference pr=apexPages.currentpage(); To direct it in the same page Below is my code Pagereferemce pr =apexpages.currentpage(); Pr.setredirect(true); Return pr;
-2
votes
0answers
10 views

hierarchy for custom object [closed]

I have three custom objects objectA__c, ObjectB__c, ObjectC__c, objectA__c is having self lookup, objectA__c is the parent of ObjectB__c, objectB__c is the parent of objectC__c. I want the tree ...
-2
votes
0answers
19 views

dynamically change apex class controller name in lightning component

How can we change the controller name dynamically? I tried to write like below, but it cannot be saved.. <aura:component Controller="{!v.apexClassName}" implements="flexipage:...
-2
votes
1answer
59 views

Coding on apex to work with large data [closed]

I am sort of confused in what approach to take in storing large amounts of data in Salesforce. I have some data that is between 2 - 3 million records and I want to access that data through apex code ...
0
votes
0answers
25 views

Before user trigger [closed]

I'm trying to create a user trigger that sets the nickname field. I'm not getting any errors in my code, but when I try to add a user, i get an error that the Method does not exist or incorrect ...
0
votes
0answers
17 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
0answers
21 views

SOQL Query to fetch the attachment related to Contact from Child Object [closed]

Can someone guide me to fetch the attachments from the custom object which has a lookup of Contact. The scenario is each custom Object record has file attached to it and I want to show it on Contact ...
0
votes
1answer
60 views

Apex callout issue

I have an endpoint which is working by disabling SSL certificate verification in Postman. Also I add a CA certificate and client certificate details. Through Postman I am able to get a response. But ...
0
votes
0answers
30 views

Get file name and extention with trigger [closed]

i have a recquirement where i need to capture file name with extention that the user uploads and to compare file name with record ID. if it matches then i need to update custom field. i have writon a ...