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

how to create and send the request/response body for the post method in test class

static testMethod void testPost(){ RestRequest req = new RestRequest(); RestResponse res = new RestResponse(); Profile testEditorProfile = [Select id from Profile where Name= :System....
0
votes
1answer
24 views

How to send flattened data from Javascript file of LWC to Apex method?

I get data from a wrapper class and flatten the data in JS file of my LWC as follows: @wire(getAccount, { id: '$recordId' }) wired(result) { this.refreshTable = result; if (result....
0
votes
1answer
17 views

Bulkifying a class

I'm trying to process and update a bunch of claims within an occurrence. Please guide and assist me on how to bulkify the below code. My debugs are currently returning empty. Please assist so I can ...
0
votes
2answers
16 views

SOSL query getting malformed query exception

I have built up a dynamic search query using sosl The query string given below FIND {a016g00000D57xKAAR} IN ALL FIELDS RETURNING Attachment(ParentId), ContentVersion(FirstPublishLocationId), ...
-2
votes
1answer
22 views

If condition for Values in Map<string,List<string>in apex

I have below snapshot where i just wanted to check if map is having the value 20 in it or not. How i can write if condition for list of string values map<string,List<string>> getmap=new ...
0
votes
0answers
14 views

How to display opportunities related list under each and every account in visualforce page

I can display Account hierarchy using viisualforce. Pleasea let me know how to display related opportunities under each account. apex controller: public class hierarchyComponentController { ...
0
votes
1answer
19 views

How to query multiple object records without using soql within a for loop

I have a Map<String, String> objectNameWithQueryString; objectNameWithQueryString consists of 'ObjectAPIName' as the key and a 'soql query string as the value'. My requirement is to perform ...
0
votes
0answers
9 views

how to email template update based on service number [closed]

How it is possible to email template update to compose mail dropdown list based on the Service number field..
1
vote
0answers
15 views

how to solve this attachment functionality

i faced a problem in salesforce, i want to get userId from localstorage and input type= file value {file is jpg/png} and then put them into apex class as a parameter via apex action function. but the ...
0
votes
2answers
20 views

How to convert json string to List<Map<String, Object>> in salesforce apex class?

I have this json string. [ { "id":2, "name":"Abc_SS", "description":"Abc" }, { "id":100, "name":"sales", "description":"sales" } ] How I can convert this json to List&...
0
votes
0answers
17 views

Copying correct case subject in case while cloning?

In our org we have email-to-case functionality, if the case created by email to case was closed and user replies to that closed case we are creating a new case by cloning. below was the example of ...
0
votes
0answers
15 views

How to fight duplicate Accounts in my Salesforce Database

What are the different methods used for finding and merging duplicates in the Salesforce Database? Currently, I am finding many duplicate accounts. This is clear from either the name of the account or ...
0
votes
0answers
16 views

Using query locator in selector class without any order by clause, is it possible? Example code shown in photo

! I want to return a query locator from a selector class having query without any order by clause, is it possible? Or can I create order by clause dynamically in selector class code? Something ...
0
votes
0answers
15 views

DUPLICATE_VALUE Error while inserting a knowledge article

I am receiving the following error while inserting knowledge article through the class. DUPLICATE_VALUE, The URL Name cannot match the draft or published version of any other article I tried using ...
1
vote
0answers
26 views

Can't Return values in Apex from Flow Winter 19

I'm trying to refactor a flow I built in Spring 20, back to Winter 19. In Spring 20, I can just create a resource for my Apex Output. I've called this variable {!apexReturnedObj} I'm trying do some ...
-1
votes
1answer
36 views

Deploying apex class and trigger [closed]

I have created an apex trigger that runs when an Event is deleted to notify an external API of the deletion. All the trigger does is invoke a static future method in an apex class to make the HTTP ...
3
votes
1answer
79 views

What is the “default time to live” (TTL) for Platform Cache?

The Platform Cache Partition Class allows a time to live to be specified when a value is put into the cache: put(key, value, ttlSecs) Stores the specified key/value pair as a cached entry in the ...
0
votes
1answer
20 views

Unable to disable edit access for a field in visual force page

I'm trying to remove edit access for a field for the users with specific conditions. I've tried with input text & disabled tag working perfectly fine but I've faced some issues with some users due ...
0
votes
1answer
28 views

Lightning-combobox not showing any value sometimes

I have intermittent problem on my lwc whereby some user not able to see the values when clicking the picklist value (lightning-combobox). When I login using system admin, I also have the same problem ...
0
votes
1answer
18 views

Custom authentication handler for community

how can I implement a custom auth handler for my Customer Community via Apex and log the user in (all through Apex)? Reason: I have a Customer Community, users and all that (works fine). The company ...
0
votes
0answers
20 views

Javascript proxies were not generated for controller {MyApexClass}: may not use public remoted methods inside an iframe

I have an apex controller for a VF-page. I got this error couple of days ago. I got this error on my UAT-org but not on my dev-org, even though both are running on the spring 20' release. if I ...
1
vote
1answer
28 views

Return page reference with if statements

I'm wondering how to call new pagereference with if conditional statements, here is my controller; public with sharing class TargetController{ //Set up all getter and setter method public ...
0
votes
1answer
34 views

Compiler error with the batch

public with sharing class APTS_UsageInput_InsertTempRecordsBatch implements Database.Batchable<APTS_UsageInputWrapper> { public List <APTS_UsageInputWrapper> inputList = new List<...
-2
votes
0answers
47 views

Display related list of Child Accounts on Parent account Page

Salesforce has the "Parent Account" field. I'd like to be able to choose a parent account and then somehow make it so that the related list can also show records from the child accounts. For example:...
0
votes
0answers
28 views

Apex batch job failing with “First error: Read timed out”

I have a batch job that is failing with the following error First error: Read timed out In the debug log, I got the repsonse as FATAL_ERROR|System.CalloutException: Read timed out When I ...
2
votes
1answer
102 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
82 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
26 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
34 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
35 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
28 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 ...
13
votes
2answers
265 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
39 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
43 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 ...
1
vote
1answer
43 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
34 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
26 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
31 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
30 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
17 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
36 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
307 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
176 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
51 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
18 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
41 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
47 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 ...