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

How to compare the Database.Error getStatusCode() value against a string (In a clean way)

I have the following code which uses string concatenation to check the err.getStatusCode() if (err.getStatusCode()+'' != 'ENTITY_IS_DELETED'). My question is, if there's a cleaner/better way to do ...
0
votes
1answer
16 views

use instanceof keyword in a visualforce page

Im trying to use the instanceof keyword in a visualforce template. I would like to pull the MobilePhone field from the Related Owner record. This works when accessed in apex but is not working in the ...
0
votes
1answer
17 views

Fetching data from Apex List<Object> in LWC [duplicate]

I'm trying to display data from an Apex Controller in my LWC. The issue I get, is that it's not working when using a List (I only have an issue with DODetails & paymentDetails). I get a "...
0
votes
1answer
23 views

Sending Simple Apex Post Request

I have narrowed down why my apex post request is not sending to an external API. For some reason the JSON data that I serialize and send is wrong but everything works when I test it using Postman. ...
1
vote
0answers
15 views

Issue in SOQL with field having unicode characters with accent

I want to query records using SOQL in apex based on a string i extract from the file name the user has selected. The use case is to find all the contracts which has PrimaryKey__c = fileName . Here ...
-1
votes
0answers
19 views

Apex class to change and update field values [closed]

What would an apex/batch class look like if I wanted to change any text in the case subject to "Case Subject". Any help would be great. Thanks!
0
votes
0answers
17 views

Unable to pass selected apex:selectRadio value to Apex controller

i have below piece of code : <apex:selectRadio value="{!ProWrap.strActionValue}" disabled="{!ProWrap.disableaction}" > <apex:actionSupport ...
3
votes
1answer
8k views

Method does not exist or incorrect signature: void add(List<String>) from the type List<String>

I am getting Method does not exist or incorrect signature in below method at line splitEmail.add(email.split(EMAIL_SEPARATOR))- private static List<String> setAddress(Set<String> emailids)...
0
votes
0answers
11 views

ContentDocumentLink querry not working with dynamic Id

Im trying to querry the ContentDocumentLink object and althogh I have a ContentDocumentId with a valid ID it wont populate the querry. for(ContentDocument cd: newList){ derp = cd.id; } ...
0
votes
1answer
30 views

how to convert &#39 ; to single quote in apex

Abc&#39;s Place this coming in apex. actual picklist value is => Abc's Place, Abc&#39;s Place is coming from json from Vf page to Javascript Remoting. It's throwing an error when I am ...
0
votes
0answers
12 views

Web-to-case html form creates a case record with status null, despite having a default value on the status field

We have before-insert flow logic that assigns a bunch of values to a Case record, and then a whole lotta more apex trigger logic that goes even further. One of the conditions of the flow, is that the ...
0
votes
2answers
16 views

Visual force page not rendering the ouptput

I have a VF page which should display the opportunity data but when I search for the data using the input field i am not able to see any output and it's not displaying any output even it has the ...
2
votes
2answers
144 views

How can I encrypt a string in Apex in a way that an external system can decrypt using C#?

Our security team has found an issue in our lightning experience site where a link to an external system is adding the account # in the URL. That system is then using that account # to display data on ...
0
votes
1answer
28 views

Loop must iterate over collection: Contact

I'm trying to executing this logic in my console. But getting an error. Please correct me List<Contact> conList = new List<Contact>(FirstName='Test', LastName = 'T', ...
2
votes
1answer
35 views

The Single Responsibility Principle vs SOQL Query/Row Limits

This question was asked similarly last month in Break single responsibility to save a soql call and was closed for being opinion based. The given use case also involved Queueable and so wouldn't ...
3
votes
2answers
1k views

SOQL Query (or other means) to get the icon assigned to an object

Lightning has pre-defined icons for the various standard object types (e.g. Account has the big and small buildings icon) and seems to allow you to associate an icon with a custom object by creating a ...
0
votes
0answers
10 views

Big Objects - How to Retry a Batch?

In exploring Big Objects the docs state the below: When working with big data and writing batches of records using APIs or Apex, you can experience a partial batch failure while some records are ...
0
votes
2answers
22 views

Apex Error: Illegal assignment from List<String> to String

I have a requirement to fetch Contact Region from Contact and update the same on User. Here is my logic: list<user> user = [SELECT name,Region__c from User where isactive = true]; Set<...
5
votes
1answer
2k views

How to retrieve connected app using metadata API?

I have created connected App using metadata API,Now I have to retrieve connected App's Information using metadata API,The code is working fine for the Apps which is created manually but not for the ...
0
votes
0answers
36 views

New line in JSON

How should I add a new line to JSON? I have tried adding "\n" "\\n" "\\n" and nothing works. It simply prints '\n' into the json string. This is the sample code: ...
0
votes
0answers
14 views

LWC JEST test for API callouts

I want to write JEST test for the following component: // JS file: HTTPCalloutInLWC.js import { LightningElement, track} from 'lwc'; // importing apex class to make callout import getCurrencyData ...
0
votes
1answer
487 views

Render as PDF not showing the file in proper format header/content/footer issue

I am having an issue with generating a pdf file with the following code. The issue I am facing is that I want the header to show on every page of the pdf and the content not to go out of bounds. Can ...
2
votes
1answer
36 views

“Apex action method must be static and annotated with AuraEnabled” but it is already static and annotated

public with sharing class LoanApplicationsData { public static List<Loan_Application__c> getLoanApplications() { @AuraEnabled(cacheable=true) List<Loan_Application__c> ...
1
vote
3answers
130 views

Variable does not exist: User.statecode when deploying Apex class

I use the following code in order to retrieve the list of configured states in the org. private static List<String> getStateList() { List<String> stateList = new List<String>(); ...
0
votes
1answer
2k views

What are the causes of error: Entity is deleted?

I would like to know all the reasons for getting the Entity is deleted error. I can't seem to find it on Apex developer docs. In my case, I'm getting the following error on the after insert trigger of ...
3
votes
1answer
46 views

SOQL for loop with less records - How to approach?

We have a scenario where we need to query 2 large text area fields and add them as a response to an external system. The source object on which these fields are present, we have used SOQL for loop to ...
0
votes
0answers
28 views

How to replace all html tag between the double curly braces in a given string?

I get all the values between the double curly braces but from this logic only getting id String Temp = ''; String temp5 = null; String str = '<html><head><meta content="text/html; ...
0
votes
0answers
18 views

how to assign two different fieldset fields in single table and concatenate them by using lightning component

I have a requirement where in i have to get the 2 fieldsets fields from an single object and concatenate into single table and this has to be implemented using lightning Aura component, below is the ...
2
votes
1answer
826 views

Share a contact with particular user using apex managed Sharing

In my Org. OWD setting for Account Object is Private and for Contact it is Controlled By Parent. So whenever I want to share particular record I am creating an Object of ContactShare and try to update ...
6
votes
1answer
71 views

“Traditional” Trigger Frameworks vs Dynamic Metadata Trigger Frameworks

I'm all too familiar with the Kevin O'Hara trigger framework and have used it as a base framework in many projects before. However, I've recently been doing some in-depth reading about the idea of ...
0
votes
1answer
45 views

How to get values of map passed form apex to lwc js?

Apex code: @AuraEnabled(cacheable=true) public static Map<String,List<String>> getSeatList(id seatId, List<String> fieldSetList) { Map<String,List<String>> ...
0
votes
1answer
27 views

How to avoid for loop and use map or some other technique for below logic [duplicate]

I have below code ,but not able to understand how i can avoid second for loop inside account please suggest public static void getOpenCaseOnAccount() { Map<id,user> userIds = new map<...
0
votes
1answer
31 views

Apex issue in production Too Many SQL queries

I created a LWC using an APEX class Everything worked perfectly on Sandbox but when I moved my code to production I get Too Many SQL queries 101 I don't know what to .. is there something wrong with ...
0
votes
0answers
15 views

Issue with attachment in EmailMessage created via Apex trigger

I have a logic in EmailMessage trigger to create a new case when customer replies to a closed case. If the case is closed, I am cloning the case record to create new case. Since we cannot reparent ...
41
votes
6answers
54k views

Howto wildcard SELECT * to query all fields of objects in APEX?

I have created sObject and I need all the fields and I have many. Is there a way I can directly get all of them rather then typing each one of them.
0
votes
1answer
24 views

I need to design below is any idea its highly appreciate? [closed]

Need to design attached page need idea for this it is possible using LWC and another method we have in salesforce?
0
votes
0answers
14 views

Calling Webservice from Apex class, getting 302 response error

I have the below code trying to make a HTTP callout from a APEX class. The response I get back is System.HttpResponse[Status=Moved Temporarily, StatusCode=302] My class is public with sharing class ...
0
votes
1answer
16 views

How to Executive Parameterized method in Ananymous window

public class helloWorld2 { string firstName; string lastName; public static void Method1(string firstname){ firstname='John'; //lastName='Carter'; system.debug(...
0
votes
1answer
35 views

automatic switch over on integration

I am working on quote object integration but customer is not ready to provide end point details. Instead of that asking me to integrate with temporary mock system and do end to end testing. They are ...
1
vote
1answer
20 views

Trigger to Update Account Lookup Field on custom object with the Account from a related object

I have a custom object Vendor__c and on that object I have a lookup field to Accounts. I want to populate that Accounts lookup field with the account related to another lookup field Projects__c which ...
1
vote
1answer
18 views

Unexpected Token '<' Apex Trigger Error with AND Statement

I'm trying to write a trigger that unlocks order records after they are placed in an approval process. The Trigger pulls a list of all orders where the CreatedDate = TODAY and the ...
5
votes
1answer
798 views

Why are no results returned when performing a SOSL query on ContentNote in a Test Method?

Following the example laid out in Adding SOSL Queries to Unit Tests, I created a test method that inserts a ContentNote record, sets the results using Test.setFixedSearchResults(), and then performs a ...
3
votes
3answers
102 views

Chain Methods with Class that Implements Queable

Update Attempt to Chain in Helper Class -- Not Working -- Separate Class Still Works. My last update was premature. This doWork method still does not control the order of the calls once they are ...
4
votes
3answers
6k views

How to clone object record?

Hi i have code for cloning selected record, but i need to do it without defining each field one by one. Here is an example with 4 fields but in complete, there are almost 40 fields. @AuraEnabled ...
-1
votes
2answers
36 views

Extract all records for current day and month for the last 5 years [closed]

I have a use case where I need a to extract all records of current day and month over last 10 years. For example, today is 14th June 2021, so I need all records of a particular object from 14-6-2021 ...
0
votes
0answers
16 views

refactoring object model and coping with rollup summary fields [closed]

Currently refactoring a solution for a client. The existing object model features a junction object that will need to have a new parent and the existing Master-Detail relationship removed to make room ...
6
votes
2answers
8k views

Content security policy error while loading apex iframe

Issue: We get CSP (Content Security Policy) error with our Visualforce page integration. The issue is that when we access this in sandbox testing, we find that our content is wrapped in an iframe, ...
0
votes
0answers
30 views

Error is coming at the time of deployment compilation is successful [closed]

Below Errors I'm getting only on the deployment to other org, but it is not showing on the compile time and even I tried I compiling all the apex classes and triggers also in the source org ERROR [...
1
vote
1answer
489 views

Trigger Handler

I have a few questions regarding best practices for the methods called from a trigger handler. I am using a trigger handler that calls a method for some processing. I want to call the same method ...
0
votes
0answers
14 views

How do we catch common.apex.runtime.impl.ExecutionException without using generic type 'Exception'?

If there is a scenario where common.apex.runtime.impl.ExecutionException would occur and we want to handle it using try-catch then what would be the most specific type of exception that can be put ...

1
2 3 4 5
645