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

How can I take the values from multi select picklist into another field?

I have a multi select picklist which I need you take the values and put into a child object. The picklist has 100 values. Can't use cross object formula because of char limits. Is there any way to do ...
0
votes
0answers
7 views

Data Integration specialist->Task 3

I am getting this error while checking the challenge--'Could not find the proper Content-Type specified in the header for the JSON payload in the 'ProjectCalloutService' class. I have tried various ...
0
votes
1answer
18 views

How can I write a schedule for this batch inside the same class

global class NumberOfContactsBatch implements Database.Batchable<SObject>, Database.Stateful { global Database.QueryLocator start(Database.BatchableContext context) { return ...
1
vote
0answers
13 views

Does MIXED_DML_OPERATION behave differently in test methods depending on how you run them: Test Execution vs. Deployments?

We typically validate our source control nightly and run all tests. This is essentially a validate only deployment running all tests against production. All tests pass. However, if we were to run ...
1
vote
1answer
18 views

Flow passing in record with picklist value into Invocable Apex method causes error

When I am trying to pass records prepared into an Invocable Apex method from a flow that have had picklist values set on the record I receive the following error message. An Apex error occurred: ...
0
votes
1answer
13 views

How to test a List<SelectOtion> in unittest

How to test a List<SelectOtion> in unittest. I have the following apexclass public class WebToObjAttachments { .. public List<SelectOption> CountryOptions { get { ...
3
votes
1answer
35 views

NullPointerException BeforeInsert on Lead Trigger

I am pretty new to writing custom code in SF and would appreciate any help. I have a trigger on Leads to update Status to "Contacted" when a task on that Lead is "Completed". I found this in a ...
1
vote
1answer
21 views

Create custom method in Apex batch class and make calls to it from execute method

I am trying to call a custom method called addColdCustomerToList from execute method, is that something that can be done inside a batch class. global Database.QueryLocator start(Database....
-2
votes
1answer
22 views

ERROR: 'Variable does not exist

I have a trigger bellow which calculates a sum of field in a related field in custom object . I am getting an error massage Variable does not exist:House_Improvements__c. Any ideas how can I resolve ...
0
votes
0answers
18 views

apex triggers to send email reminders for animal rescue nonprofit

i am trying to create triggers and generate reminders- and make the reminders prompt an email (google is connected with sf and syncing both ways). the former developer left some framework- so there ...
0
votes
1answer
30 views

Apex Generate JSON Dynamically

I'm facing an issue when generating a JSON dynamically.I've created different inner class to represent the JSON: public class OrderActions { public OrderActions(String type, Object addproduct, ...
0
votes
1answer
34 views

Need to write an apex class to take in a custom object id and receive a list of related object Ids from that custom object

I am new to salesforce and to coding in general and I am struggling to understand how to correctly write this class / SOQL query. Any advice or guidance would be appreciated. I need to specifically ...
0
votes
1answer
20 views

Unable to navigate code path for a specific project in VS Code

I am having trouble with navigate the code path by using "Go to definition" / "Peek Preview" for one project. I also don't see any SFDX commands on Command palette. The project has below structure. (I ...
0
votes
1answer
18 views

It is possible to create trigger invoked on EVERY send email message?

i want to make a thing witch one will be working with every sent email from my org. It is possible to write a trigger to do that? The only possibility that comes to my mind is create a factory to send ...
0
votes
0answers
17 views

How To retrieve details from process builder And Flow

We have some routing processes configured using flow and process builder. basically routing is based on category field. If a category is A, it's being routed to Queue ABC. Our clients want a way to ...
0
votes
2answers
17 views

How to get language from visualforce into into controller extension

I am using a force.com site to show a visualforce page where I want the user to have the option to select a language. In the corresponding visualforce page I set the language. How do I get this into ...
0
votes
1answer
19 views

CSV format issue

Here is the current code. I am expecting the 0000 value in my CSV file but it is printing only 0. Can anyone help with this? fileRow = fileRow +','+ '"' +0000+ '"'; // Here I am expecting 0000 value ...
0
votes
0answers
12 views

Fetch Record ID from batch job id

I have a job id for a batch apex class.I need to fetch the record ids from the job id.Is it possible to use an SOQL to fetch the record id for which the particular job id ran. I need help on the query ...
0
votes
1answer
29 views

Communities: accounts, users and contacts management

I am a new user which inherited an organization domain with created communities. I have several questions: Each community has accounts. Each account has contacts. Where can I see users? I am sys ...
0
votes
1answer
15 views

Error in batch class - not getting the correct time

Getting error in the following lines: if(Datetime.now().hourgmt() == 16){ ev.StartDateTime = Datetime.valueOf(Datetime.now().hourgmt()+24); }else{ ...
0
votes
1answer
11 views

SOQL injection issue on source scanner report

I am getting SOQL injection vulnerability on source scanner report. Please check one of the issue below. I tried string.escapeSingleQuotes() on query string. It is helping with removing this issue in ...
0
votes
4answers
62 views

How to write apex class or trigger for changing the opportunity name to lead name after lead is converted [closed]

When a lead is converted to opportunity , the field opportunity name is set with account name default. But I want to change the opportunity name to lead name using apex class or trigger. How can do ...
0
votes
1answer
28 views

CSV File Date Issue

Can anyone help me with this?. How to extract the time from the date field and also the date format while creating the CSV file in the batch class. Please find the below code. String fileRow = ''; ...
0
votes
1answer
24 views

Why dynamically creating Aura Component not working if access level is not defined?

I have a code that creates an Aura component dynamically. $A.createComponent('c:HelloWorld', (content, status, message) => { console.log('Status : '+ status); // Status : ERROR console....
-1
votes
0answers
19 views

I am getting the Error 400 Not a multipart request

I am struggling from last week and getting same error please help me I am trying to upload pdf on the third party system I am using session id and URL to upload to PDF, It is working fine on Postman ...
1
vote
0answers
20 views

Visualforce field value keeps changing after save

I'm having an issue with my visualforce page updating values if after saving even if I don't update that value on the save instance. I think it may be that I have my Save method written incorrectly? ...
0
votes
1answer
21 views

how to refer a record type in a apex class [duplicate]

I'm writing a Apex class to auto delete Case records of record type claims and service failure with created date older than 6 Years here is the code. But i'm failing to Refer the record type in the ...
0
votes
1answer
24 views

You have uncommitted work pending. Please commit or rollback before calling out. Apex Batch

I have a little problem with my batch: List<String> idList; public My_Batch(List<String> ocIdList) { idList= ocIdList; } global Database.QueryLocator start(Database.BatchableContext ...
0
votes
1answer
18 views

Bulk Updating Records in Apex from List?

I am writing code that calls an API to get external client info. I'm at the point where I have it working but I am wondering if there is a more efficient way to save the data to the Account object. ...
3
votes
1answer
57 views

“Can only throw this exception type from VisualForce or Aura context” error on sfdx force:source:push

Our CI (Continuous Integration) build has started failing today on the sfdx force:source:push with this error: cvnp.ContentDocumentLinkTrigger: System.LimitException: Can only throw this ...
-2
votes
1answer
25 views

trigger to stop adding duplicate values into the rich text field

I am working on a trigger which will populate the date on rich text field on Lead object from Related_Tow__c object. can anyone help me out in checking rich text field whether it contains data or not,...
0
votes
0answers
17 views

Issue with JSON Parse With Same attribute names in JSON

Here I have doubt How I Can Parse this JSON on apex and Get the data of "customerPurchaseOrderNumber" numbers, Here problem it is having same name of the json field/atrribute I don't how many it ...
2
votes
0answers
44 views

Multipart form data uploads only the first file when using HttpFormBuilder ( try with given RestEndpoint and Anonymous Apex)

I am using the same solution as Daniel provided : When I use the below method to upload file, one by one, it works fine, jpg, pdf, docx anything. But when I try to upload multiple files using the ...
1
vote
1answer
17 views

field 'Name' can not be sorted in a query call error in only one environment. What can be the issue?

I have an object A which has a lookup to Contact. I am doing a SOQL in an Apex class and it looks like this: SELECT Id, Contact__c, Contact__r.Name FROM A__c ORDER BY Contact__r.Name This SOQL query ...
0
votes
1answer
23 views

Problem with Date format in SOQL

I have a silly problem, when I pass Date from lightning input (type=date) i pass it as a string, and when i creating a query with this paramiter i recived error like below value of filter ...
1
vote
1answer
22 views

How to find a sobject used in which apex class

How to find which object is used in which apex class or trigger.Ex I want to find apex classes where account object is used.
0
votes
0answers
19 views

How to make communities public which has no VF pages/custom code

I have a community where I want to display few Einstien Analytics dashboards which I want public to access without logging in. I found that we can make Community Public using vf pages in public access ...
2
votes
1answer
24 views

How to read/parse an X9.37 file via Apex?

Background X9.37 is a standard format used in electronic check exchange (when a depository institution sends an image cash letter file as a deposit to the Federal Reserve Bank, or when the Federal ...
0
votes
1answer
21 views

Flow Apex Action - return multiple elements?

I have a flow and due to the complexity of the logic, I moved some of the logic into apex (However I need to use minimum apex). I'm looping through some records and finding related records (I need ...
2
votes
3answers
79 views

AuraEnabled Method Causes Internal Server Error for non-Admin Profile

I have an Aura Enabled method in my class that accepts a Case record and a list of a related object records and inserts both of them. The code works fine when I'm logged in as the admin, but the ...
0
votes
1answer
21 views

Accessing query result fields

I am trying to pull values from a query result I'm performing on the Product2 sObject and am trying to save the values from the query into individual variables. My query result: |DEBUG|...
0
votes
0answers
19 views

Never left if condition

I've got a tricky question, my code doesn't work - suprise. I would like to return only a list of 'filtred' data but my code never leav a if condition. So when if condition return true and my script ...
0
votes
1answer
13 views

Apex Specialist Superbadge Null Reference on Challenge 4

Been spinning my wheels on this for awhile. Frustrating thing about these Trailheads is no point of reference for what tests are failing on Salesforce's end that might be producing this error. Here ...
-2
votes
0answers
21 views

Getting following error [closed]

First error: Invalid integer: java.util.GregorianCalendar[time=-3,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,...
0
votes
1answer
33 views

You have uncommitted work pending. Please commit or rollback before calling out even if we put DML in future method

I know as per documentation, we cannot perform DML and then callouts from apex class. In my scenario, I have a callout then I am performing a DML which is placed inside a future method and again ...
0
votes
1answer
19 views

APEX Trigger Not updating numbers on Custom filed Callable_Contacts__c on Account after addition or deletion

My trigger is as follows: trigger AccountCallableContact on Contact (after insert, after delete) { SET<ID> contId = new SET<ID>(); LIST<Account> accountPhonePopulated = ...
1
vote
1answer
22 views

How get a product with a certain UnitPrice?(can I do this in a single request?)

SOQl [SELECT Name,Rating__c,(SELECT Product2Id,UnitPrice FROM PricebookEntries WHERE UnitPrice =: certainUnitPrice) FROM Product2 LIMIT 4] It return all product with some empty UnitPrice
1
vote
2answers
95 views

Is it fine to create a custom exception class that has the same name as a built in one in apex?

I need to throw exceptions within my apex classes here and there, as most of us do. In fact, we can't throw built-in exceptions so we have to create a custom one that extends from the main exception ...
0
votes
0answers
31 views

Error: Field is not writeable — for lookup relationship

I created formula field and is automatically populated the value and its working properly,please find the below formula field code IF( ISBLANK(Community__c), Name, Community__r.Name & " >...
0
votes
1answer
22 views

Get contacts created by lead conversion

I was stuck at a point where I need to get the contacts created by lead conversion. Can someone tell me how to query those contacts when a lead is converted... I am new to salesforce so please help me ...

1
2 3 4 5
574