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
0
votes
0answers
10 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,...
1
vote
1answer
8 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
0answers
25 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 ...
5
votes
1answer
172 views

How to get list list of flows accessible by a User based on Permission Sets?

In order to provide more granular and controlled access to flows, all our flows are enabled with access setting of "Override default behavior and restrict access to enabled profiles or permission sets"...
2
votes
1answer
30 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", "...
9
votes
2answers
96 views

Clean way to vary sharing at runtime in Apex?

I may need to make many @RestResource Apex classes run either with sharing or without sharing where that option is selected at runtime. But this approach (that I am using at present): /** * Allow ...
-2
votes
1answer
56 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 ...
2
votes
1answer
33 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
2answers
33 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
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
0answers
36 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
19 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
1answer
41 views

Not responsive height in LWC

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

Hot to update existing records and uinsert 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
0answers
23 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
0answers
13 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 ...
-1
votes
1answer
26 views

How to display Salesforce Einstein Analytics dashboard on external website

I have created this dashboard in Einstein Analytics Studio. Is there any way to display this dashboard on my external website.
0
votes
1answer
902 views

Automatically Send Email using email template

I have a VF page thats suppose to send mail out using a template. Now what it does, is create the attachment and opens the template with the attachment as well as autopopulated addresses. Now 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
1answer
84 views

Salesforce CPQ Custom Template Content (Quote Templates) not showing field value from custom controller

I just created a simple quote template. With 1 Template Section. I have assigned that section with a Custom Template content that references a visualforce page I created. Visualforce page, <apex:...
0
votes
0answers
15 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
21 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:...
1
vote
1answer
210 views

Using JWT when calling out from Salesforce to third party API

I have a requirement where on lead conversion in Salesforce, I need to call a third party API and post converted lead's details to that API. I have covered up til the part where we need to add ...
1
vote
1answer
45 views

SOAP API response queryresult to insert account records in salesforce

I am trying to fetch the account records from the queryResult of Salesforce to Salesforce integration response. But unable to split from the data. Can someone please help me. string query1 = 'Select ...
9
votes
3answers
21k views

How to send an Email Template via Apex?

Goal I'm attempting send a good looking HTML from Apex code, here's a stripped back screenshot . Based on the documentation I've reviewed, with Apex we can leverage SalesForce email templates using ...
-2
votes
1answer
57 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
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 ...
13
votes
3answers
13k views

Passing Parameter Into Schedulable Class

Is there a way to pass a parameter into a schedulable class execute method? We were trying to pass a string from another scheduled class into this scheduled class but it looks like we can't do that? ...
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:
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
23 views

No refactorings available: VSC Apex [closed]

I used to be able to refactor/extract methods from VS code as documented here https://developer.salesforce.com/tools/vscode/en/apex/refactoring/ Now whenever I try to do this, I get an error saying "...
6
votes
4answers
4k views

Bulkified Contact Trigger That Creates An Account?

I'm trying to create a trigger on Contacts that automatically creates and associates an Account if one has not been previously created. This was functionality that we had in a managed package that we ...
-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 ...
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-...
-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 ...
0
votes
1answer
14 views

Messaging.sendEmail in APEX not working when launched automatically from flow in Sandbox

I have programmed an autoflow that launches the below class. I need to test the e-mail notifications of Messaging.sendEmail in Sandbox. The strange thing is that when launched manually from the ...
-3
votes
0answers
24 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
445 views

How to auto-populate Close Date (End of this month) in Opportunity page in Salesforce

I have a Requirement : After clicking on New Opportunity Button it will open Opportunity page with some fields auto populated Like 1. Close Date: default to creation date plus 30 ? 2. Opportunity ...
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 ...
-3
votes
0answers
17 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
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:...
23
votes
1answer
56k views

Can anybody explain the UNABLE_TO_LOCK_ROW error?

Error Message: Developer script exception from Nicomatic : quotepotential : quotepotential: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with ...
0
votes
1answer
22 views

How to query only field-history-enabled objects in apex?

We have 5 objects. In these objects, we are only tracking 3 objects’ field history, How can I query on objects with history enabled? I want to get only field history enabled object Names. Please ...
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 ...
6
votes
2answers
166 views

Current state of reliable execution scheduling

A number of approaches to more reliable scheduling and continuous processing have been used over time on the Salesforce platform, all of them suffering from serious drawbacks. These include: suicidal ...
0
votes
1answer
68 views

How can I resolve these two errors in trigger handler

public class AttachmentTriggerHandler { public static void onAfterInsert(List<Attachment> attachments) { handleCreditReportAttachments( attachments ); } public static ...
0
votes
0answers
16 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 ...
-1
votes
1answer
10k views

How to get the date value of current date?

I want an if condition that could check if the day value of the current date is 1. I have applied the logic: if(Date.Today().month()==1) But the above results in months. How can I check for days ...