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

INVALID_CROSS_REFERENCE_KEY : Invalid cross reference id in After insert Trigger to create ContentDocumentLink

I am encountering the following error when inserting a ContentDocumentLink record : Error [statusCode=INVALID_CROSS_REFERENCE_KEY, code=[xmlrpc=1202, statusCode=INVALID_CROSS_REFERENCE_KEY, ...
0 votes
1 answer
17 views

'Unique count' on reports is counting blank values

I'm using the 'Unique' formula for a summary on a report, but the figure returned is wrong becuase it is to be counting the blank value as a unique value. Is there a way to correct this?
0 votes
1 answer
728 views

Internal Server Error/Bad Request when Passing an object to an Apex Class

Bear with me if this seems pretty basic, i'm starting out in lwc, so have probably missed something obvious. I have a lwc which i am trying to pass some data into an apex method and have it return ...
-1 votes
1 answer
108 views

How do I integrate the Twilio deactivated phone number API into SalesForce using Apex?

I need to integrate the Twilio deactivated phone number API into SalesForce (https://www.twilio.com/docs/sms/deactivated-phone-numbers) This API provides a .txt file with a list of phone numbers that ...
0 votes
1 answer
20 views

How to use OFFSET in SOSL DYNAMIC

I need to use the offset 0 in my Dynamic SOSL, but giving me unexpected token error:- kindly help me out for the below issue CODE :- String sampleSearchText = searchText +'*'; String sample = '%'+...
0 votes
1 answer
24 views

Duplicate object : Apex class fail to deploy

This code worked for me for the creation of a new template as well as a section, but when I added the creation of a new question. I found a problem in the deployment, I will put all the code in order ...
0 votes
1 answer
572 views

how to hide related list button based on date condition

I want to hide a related list button based on specific date conditions. This should apply to standard layout only. For example Opportunities that are created from today onward should display the ...
6 votes
1 answer
2k views

What is a good and free static apex code review plugin for IDEA, eclipse and ANT?

Java has a number of useful and FREE tools for reviewing not just formatting and style but quality of code and bad coding habits. Checkmarx and Code scan could work but they are not free and open ...
0 votes
0 answers
15 views

Inconsistency between Field Dependency values and Picklist values salesforce

In the field dependency mappings, there are few values which doesn't match with the actual field's picklist values. For instance, There's a picklist called MyDependent__c and the values which we have ...
-1 votes
2 answers
927 views

Dynamic calculations using Apex

I need to dynamically calculate a formula in APEX, the formula will be constructed as a string. Consider something similar to JavaScript eval() function. For example I need to calculate value for ((2*...
0 votes
1 answer
23 views

how to read a json received in an apex class

I am new to the APEX programming language. I have a json string that contains an input and output and I need to read the json as input of an apex class and do manipulations on the file to display the ...
0 votes
0 answers
25 views

Send email with file attachment in aura component

I have an aura component and I want to send email with attachment. The files gets added to the record but it doesn't gets attached to the email. The email is send without any attachment. Component: &...
-2 votes
1 answer
29 views

How can i execute the soql in apex in the salesforce developer console? plz help me!

I made a apex class named "FilteredTableControllerTest". and I want to execute this class so that i put FilteredTableControllerTest.testCases(); Debug > Open Excute Anonymous Window >...
4 votes
2 answers
5k views

Issue with "Subscribe to Platform Events" Challenge in the Define and Publish Platform Events Trailhead

I am not spotting what is causing this ERROR: Challenge Not yet complete... here's what's wrong: Publishing an Order_Event__e did not create the associated task successfully. Please check ...
0 votes
1 answer
43 views

I hit maximum character allowance when validating a card number what are my alternatives?

I am validating a field for credit card numbers but I want to be able to check if it is American Express, Visa, or MasterCard as each of these cards have a different amount of numbers. I have tried ...
0 votes
1 answer
46 views

Test code coverage not covering the for loop

EDIT: My latest code with the new error, I used the code suggested by sfdcfox and here is what the error I'm seeing: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-...
0 votes
1 answer
671 views

How to check for duplicate values before insert in visualforce remote objects?

How can i check for duplicate values while inserting data in salesforce using Visualforce Remote Objects. Here is my code: //Get form values. var woDetails = { Case__c: $scope.caseId, ...
1 vote
1 answer
62 views

How To Get All The Favorites In Salesforce?

I am using as reference this documentation: https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_favorites.htm And it says that by doing an HTTP GET request to this url &...
0 votes
1 answer
951 views

How to get value of Selected pick list value to controller if we have multiple Select tags?

Am facing a issue with sending the selected value to the controller if we have multiple select tags on vf page and all the values of picklist are different. <!--<apex:selectList ...
0 votes
0 answers
20 views

Create a contact named ABC in salesforce, if Account ABC does not exist in salesforce.If the account exists, show a error message [closed]

To create apex triggers. Error message Salesforce
1 vote
2 answers
760 views

Pre select multiple option in select option

So this is i donw so far, In this pick list there is two value like active,new. I want to set this both option as pre select by default. Visua force page <tr> <td style="font-...
0 votes
1 answer
30 views

Generation of pdf from lightning aura component and attach the same to case object

I have the requirement like i need to generate the pdf from aura component and the generated pdf should automatically attach to case object. I tried in following ways : I have created lightning ...
57 votes
2 answers
58k views

Apex List For Loops 101

I just have a simple question about how list for loops work that has been bugging me. Does the for loop variable refer to the actual list item? Here's what I mean: Say I have a list of accounts. ...
0 votes
1 answer
36 views

Lightning Base components vs Developing Lightning Web Components

I am looking at the lightning design system component blueprint documentation and reviewing the various ways we can use the Lightning Combobox. For example, in the documentation, they go over Grouped ...
0 votes
0 answers
30 views

Integration - OAuth 2.0 or Integration User

I have a use case where I am trying to run credit checks (external system) for some opportunities. The API's need authenticating and support REST and OIDC. There can be multiple reps using these API's ...
-1 votes
1 answer
43 views

REST web Service to consume PDF in Binary Form from external System

I have a requirement where external system will be posting PDF to salesfore in binary form as REST Post call and I need to cosume the PDF to attach it to the Object as attachments. Following is my ...
0 votes
0 answers
26 views

Authorization required error on submit button to retrieve custom object field

I have created a salesforce site using visualforce page. User will input the value and after a button click, custom object should be displayed on page. After after button click, getting "...
0 votes
0 answers
31 views

getting Error on Test class of Batch Apex class. Want to Inactive Process Builder

I am getting error on test class which i have created of Batch class. below is the Error code which i am geeting. Also I want to inactive my Process Builder Virtual Producer-Subsussion5 . Please help ...
-1 votes
1 answer
31 views

Formula Field and pick list [closed]

IF(AND(ISPICKVAL(Employee_Title__c ,'Software Engineer'),50000, IF(AND(ISPICKVAL(Employee_Title__c ,'Senior Software Engineer'),70000, IF(AND(ISPICKVAL(Employee_Title__c , 'Team Lead'),90000, IF(AND(...
0 votes
2 answers
677 views

Updating the status of a job via Bulk API 2.0

I want to use patch method but its showing invalid. so i used suggested workaround to overcome the issue but now its showing 400 bad request. The link i have gone through for the patch workaround [ ...
0 votes
1 answer
2k views

OTP Generator for Salesforce Communities

We are using Salesforce Community cloud. We have a requirement to generate One Time Password (OTP) and send to email when the user changes his mobile no. Similarly we need to generate OTP and send to ...
0 votes
2 answers
60 views

Why null pointer exception occured?

Following is my code : trigger EmailValidation on Contact (before insert,before update,before delete) { // set to store emails present in the contacts that initiated this trigger set<...
1 vote
1 answer
581 views

Export Salesforce Report (CSV) using java application

I am refering to the post "Can report data be accessed programatically?" and further conversation and had written below java class to export the csv to local drive. Authentication to Salesforce was ...
0 votes
0 answers
45 views

getUserInformation() error [closed]

I am looking at some existing code for a Connected App plug in class where it shows this: private void userUpdates(Map<String, String> updates, Id userId) { User currUser = ...
-1 votes
1 answer
63 views

How to display hyperlink in error message from trigger?

i want to give link to the record in an error message which i am sending from trigger. Message: ERROR: An open opportunity <a href='https://bonial3-dev-ed.my.salesforce.com/0065i000006VOl0AAG'>...
0 votes
1 answer
17 views

Pass record Id to an auto launched flow from an after delete trigger

I have a requirement to update a field on a parent record after a child record is deleted. I would like to call an auto launch flow from an after delete trigger to handle the logic, however I'm having ...
3 votes
1 answer
797 views

Testing @future method Failed Assertion

I have some code that after inserting a task, calls an @future method to update some fields on the contact linked to that task (WhoId). This seems to work fine in sandbox, but I can't seem to get it ...
31 votes
7 answers
28k views

Format APEX code Visual Studio code

Has anyone been able to find a formatting extension for Apex on visual studio code? And if so would they be able to share it?
4 votes
1 answer
507 views

How to display a error message with hyperlink on standard detail page through trigger

I'm trying to add the record link inside the "addError" on the trigger for(Account account : (List<Account>) triggerParams.triggerNew) { String url = URL.getOrgDomainUrl()+'/'+...
1 vote
0 answers
32 views

Lead conversion with a Person Account

I am trying to convert a lead to person account, in the logic we need to create the personAccount during lead conversion time. So I am using "setRelatedPersonAccountRecord", where I am ...
0 votes
2 answers
39 views

I need to make discount depends from Registration date (i.e. 3% discount to Opportunity when Account registered 1-2 years ago, 5% 2-3 years ago)

for (Opportunity opp : TriggeredOpps){ Account parentAccount = parentAccountsMap.get(opp.AccountId); if(parentAccount.Registration_Date__c != null){ Date todayDate = Date.today(); ...
0 votes
0 answers
16 views

Unable to deploy Target Config Property with "Role" Attribute when using FlowAttributeChangeEvent to affect component visibility in Flow?

I am looking to create a visual workflow that based on the output of the LWC component, will affect the display of another component on the same screen. I believe I need to set the role attribute of ...
9 votes
1 answer
9k views

What causes REQUEST_RUNNING_TOO_LONG test errors?

For most of our clients we've got a basic ant script that does a test deploy every night to make sure all the tests pass. Occassionally, we'll get a REQUEST_RUNNING_TOO_LONG error. What's strange is ...
0 votes
0 answers
35 views

How to empty recent list for an object

I have a user who uses the recent sales invoice list for sending emails. The process she uses is: View sales invoice Click on billing contact to display the contact Select Activity related list ...
0 votes
1 answer
55 views

SSO on salesforce only works for certain users

I just started with SSO on salesforce, I made my configuration on one of our sandboxes, the problem is that when I test the SSO connection or when I add a new user on the sandbox, it works well but ...
0 votes
0 answers
15 views

Collection Defaulter Email for sending mail of 4 regions Records at a time [closed]

I created an Apex Scheduler class for sending emails of 4 regions record at a time. But in my code duplicate email will go... Can anyone help me to correct this code? global class ...
0 votes
2 answers
34 views

Database.Stateful, Non-Static Variable Is Null in Finish Method?

I can't figure out what I'm doing wrong here. So, I have a batch class, when I call it, it instantiates a new List<Database.SaveResult>() which is non-static and since I'm implementing Database....
-1 votes
0 answers
23 views

Managing salesforce profiles in the AD FS [closed]

I'm trying to create groups in Active Directory that correspond to salesforce profiles in order to add users via active directory. I found the profile IDs which are in this form "...
0 votes
1 answer
27 views

Before delete trigger to block the deletion of accounts depending on a field an user profile

I'm trying to write an apex trigger that before delete checks the user's profile and a custom field called ID_Prestige__c. If the field is empty you can't delete the account object. Only if you have ...
7 votes
2 answers
11k views

Clone list of SObject records using deepClone() to clone all the fields on records

I am trying to clone the records of a custom object. I know that I can use the deepClone() method of the List class to do this. List<MyCustomObject__c> originalList = [Select Id, Name, Age From ...

1
2 3 4 5
686