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
4
votes
1answer
58 views

char vs String in Apex

I'm currently working on creating a tiny expression language in Apex. I'm following https://craftinginterpreters.com which develops a simple lexer / parser in Java. I'm working on the lexer now ...
-1
votes
2answers
34 views

query DescribeSObjectResult class

Is there way I can do some sort of query in my org to see if any of our apex classes uses the DescribeSObjectResult class? if so how can I achieve that? Thanks!
1
vote
1answer
36 views

Is lookup skew bad if it doesn't bring about row lock contention?

On Opportunity there are two lookups fields, the standard Primary Campaign Source, and a custom lookup to object Exhibition__c (which is set to Clear the value of this field if related record is ...
0
votes
1answer
27 views

Is the rule of 'triggers for one object not creating or editing records of a different object' a good idea in a managed package?

Context: Working with Multiple 2GP Packages in a Single Namespace. It's a big package(s). OEM environment so this is the core application used by clients on the salesforce platform and takes ...
-3
votes
1answer
21 views

Why I am getting error : A non foreign key field cannot be referenced in a path expression: AccountId?

I want to set the Description field on Contact object same as the Industry field on the Account object. But when I am executing the below code I am getting error A non foreign key field cannot be ...
0
votes
2answers
35 views

Will acc.Contacts return list of all Contacts related to the Account?

Will acc.Contacts return all the related contacts to the Account? What does actually acc.Contacts means in this code? When I am doing System.debug() it returns (). What should be the output for this ...
0
votes
0answers
26 views

OpportunityLineItem shows UnitPrice with 3 places after decimal

I have an opportunity that has 3 products and each product has a list price of $600 and sales price (UnitPrice) of $400. The amount field on the opportunity is showing $1,199.99 instead of $1200 as ...
0
votes
0answers
25 views

Changeset validation failing with insufficient code coverage

I have an apex class with a platform event trigger that calls a queueable apex using System.enqueueJob() which in turns makes a web service callout in a try-catch block. The response returns by the ...
0
votes
1answer
16 views

How to create aura lightning page to help me visualize data in separate pages?

I have an aura component lightning page with many fields in it. To avoid having too long scrolling I need to separate and visualize the fields in different pages. Is there any lightning component to ...
0
votes
0answers
25 views

Need to get the Application Name using Apex Code

I'm using the below code for getting the Application name in which this executes. I used this Class in the Remote action of the Omniscript. But when I execute this, I'm getting the same application ...
0
votes
2answers
30 views

How to indent code in apex class created using tooling API

I have below apex code to create a new apex class from a string using tooling api apexBody = '{"Name": "myClass", "body": "public class myClass {@AuraEnabled public ...
-3
votes
0answers
18 views

Test Coverage of Action Sent Email Message [duplicate]

I'm using the following Apex Class so when I create a case and then send an email through a Flow and there is a response to that email it will go back to the case. public class SendEmailMessage { ...
0
votes
1answer
23 views

Apex Data Transfer Object. Deserializing data [duplicate]

I am new to Apex and SF and I have to manage some errors from an 3rd party API we are calling. I have been using DTO with very simple response objects and the error response object we get back has one ...
2
votes
1answer
25 views

How to refresh datatable after saving form in Visualforce with CustomController

I'm trying to create a apex:form with an input section where several fields are rendered and the user can save the record. Below this form, is an apex:datatable. I want to rerender the input fields ...
0
votes
1answer
25 views

method not found may be due to parameters format

I'm writing an apex class that gets params from my js. and here is my code piece. action.setParams({ "mapOfFields": { "enf_income_witholdings__x": { ["...
3
votes
0answers
52 views

Queueable Finalizer throwing "ConcurrentPerOrgLongTxn Limit exceeded."

We got some 50 mails for ConcurrentPerOrgLongTxn Limit exceeded. with heading as Developer script exception from ******** : Error processing finalizer for queueable job id: 7079G000000HhWs : ...
0
votes
1answer
41 views

How do I correctly implement the 'isDelete' method?

This is the code I am trying to use. I will also add that in the parameters of the trigger, I have added the 'before delete' and 'after delete' at the top of the trigger. And I am getting the ...
8
votes
1answer
146 views

Retrieve standard and custom notifications of a user in Apex

Is there a way to fetch the unread bell icon notifications of a user in Apex? We have a community built on the Build Your Own (LWR) template where we need to implement an LWC component that displays ...
0
votes
0answers
17 views

it is necessary to check what type of object comes

i create modal window! when i click edit i get id, but i don't know how check type of object public class AccountTableController { @AuraEnabled public static List <Account> getAccountList() { ...
-2
votes
1answer
23 views

convert list with duplicate id to Map

I am working on an apex which is used to clear Hierarchy field values on User records when a user is deactivated. I am stuck at the last part of code. I have a List with same UserID but with different ...
-1
votes
1answer
10 views

Create custom faults in SOAP webservice

I am building a new SOAP webservice in apex and I want to know how to throw custom soap faults. I created custom exceptions in apex and throwed it but the stack trace is also thrown along with the ...
-3
votes
0answers
17 views

How to fetch list of updated fields among all fields in case object [duplicate]

I need list of updated fields in case object, So that the particular list can be added into email alert. For this i have created a custom meta data object and added a text field named Updated_field(...
0
votes
1answer
32 views

FLS Create Security Risk still appears even though object is checked if it is creatable

So I have this code: obj.field1__c = 'placeholder'; if(MyCustomObject__c.sObjectType.getDescribe().isCreateable()){ insert obj; } When I receive the (Checkmarx Source Scanner report), I still get ...
0
votes
1answer
36 views

Flow Complex Apex Defined

I'm trying to pass an apex defined variable from LWC to flow, the class looks like this: public class Subs { @AuraEnabled public String name{get;set;} @AuraEnabled public List<...
-5
votes
0answers
23 views

Lightning component aura lightning input

Need help! i must pass value from aura component(lightning input) in apex controller and update my account List! when i click "Edit" opened modal window with real data! i need edit this data ...
0
votes
1answer
42 views

Two inner loop need to replace with map.can we? [closed]

I am new to coding.here i want to replace the two for loop using map.can we do it? ContentVersion versionIn = [ SELECT VersionData, VersionNumber, PathOnClient FROM ContentVersion WHERE ...
-4
votes
0answers
35 views

Pass values from lightning input in apex controller

Need help! i must pass value from aura component(lightning input) in apex controller and update my account List! when i click "Edit" opened modal window with real data! i need edit this ...
-3
votes
0answers
28 views

Getting JSON_PARSER_ERROR while parsing JSON in workbench

What I'm doing wrong for which I'm getting JSON PARSER ERROR when I'm trying to update a record in workbench.. Inserting a record works fine but updating a record throws this error.. here is my code: @...
3
votes
1answer
93 views

Non-selective query against large object type (more than 200000 rows) - Solution

Below is my query which throws the exception and is used in the trigger handler SELECT Id, RecordTypeId, Status, customObj1__c FROM Case WHERE customObj1__c IN : customObj1_Ids AND RecordTypeId IN : ...
1
vote
0answers
22 views

Unable to save video captured via webcam in Aura Component

I have an Aura component that captures video via webcam and displays it to the user while also giving them the option to save it. The "playback" feature works as expected using the following ...
1
vote
1answer
54 views

Flow Currency Decimal Places being dropped when passed to Apex Class

My flow has a screen where the users enters a value in a currency field that has 2 decimal places and that value gets passed to a variable in an Apex Action within the flow. For some reason, when I ...
0
votes
0answers
20 views

How to hide/restrict fields in Aura component based on User’s Profile?

I want to show/give access to fields in Lightning component based on profile Permissions. Is is possible in lightning?
0
votes
0answers
16 views

update account and contact with help aura modal window

i need help! i need create tree-grid table with Account and Contact! When i click "Edit" button i must edit Name and Phone i create table and modal window, but i can't update Account and ...
0
votes
2answers
31 views

Managed Class is not visible

I am trying to copy a visualforce page, that is a part of a managed package, so that is to say recreate it, and then add a couple of lines of functionality to it so that I can add something to it, and ...
0
votes
0answers
25 views

Get Current Tab URL

I am trying to pull the URL for whatever record the user is on when they launch my screenflow. For example if they are on an account I would need the account URL: "https://mydomain--partial....
0
votes
1answer
23 views

How to use Conditional Field Rendering with Field Sets

I was looking for an example of conditional rendering of fields: like the one here How to hide/show the fields based on Picklist value My question is, how would you do this with the standard FieldSet ...
2
votes
1answer
24 views

Query in Apex Class is duplicated every time wire decorator in LWC is triggered

I'm still fairly new to LWC & Apex, so here goes: I have a datatable and a lightning input field which is passing a searchKey variable to the wire decorator: @wire(getAllChildRecordsByRecType, { ...
0
votes
1answer
40 views

Alternatives for multiple If statements

I need to compare the fields and depending on that if its true then update a boolean variable and if its false then capture this field and get the label and append it to a string. I have like 10-12 ...
0
votes
1answer
59 views

Batch class for deleting child record when parent record is deleted

I have written this code for deleting child records when parent record gets deleted. But when i execute this i dont get any error nor the records are getting deleted. Kindly help me where i have done ...
7
votes
1answer
126 views

What is the best practice regarding organizing Apex code

I am just curious of what is the best practice, it seems that if I create folders in force-app/main/default/classes and put my classes there everything seems to work fine. Is this in any manner bad or ...
0
votes
1answer
43 views

Error: Unable to resolve nonexistent file

I am getting this error while creating the lightning web component. Component files were created successfully but this error popped up. How to solve it or should I ignore it. 12:26:51.167 Starting ...
-4
votes
1answer
49 views

i want an answer is : A=APPLE,ANT ; B=BISCUIT ; C=CAT; D=DANCE,DOG [closed]

List<String> lst_AllWords = new List<String>{'Apple', 'Biscuit', 'Ant', 'Cat','Dog','Dance','Eagle','Elephant'}; // list<string> lsts=new list<string>{'A','B','C','D'}; Map<...
-1
votes
0answers
17 views

Classt Testing with catch exceptions [duplicate]

I already create a test class, but I think is too simpple, and my cover is 44% public class PortalProveedoresController { public boolean displayPopup {get; set;} public string idprov{get;set;} public ...
0
votes
1answer
23 views

Task - Save & Close

Working to smooth agent workflow by setting the tab (in salesforce) the task is open in to, "close" after the "save" button is clicked. Currently when the user clicks, "save&...
-4
votes
1answer
46 views

Unreachable statement (14:9)

I've this class public with sharing class CreateContact { @AuraEnabled(cacheable=true) // Method to get Account Name. public static string getAccountName(String recordId) { ...
-3
votes
1answer
47 views

Test Class for an existing Apex Class

Apex Class public class DistanceRecord { public class FlowInputs { @invocableVariable public String AccountId; } @InvocableMethod public static void getAcct(List<FlowInputs&...
-3
votes
1answer
42 views

Trigger Apex Trigger if a custom field (bool) is true

I have this code that sends information to a webhook, I only need to send information when the field WebTrig__c (checkbox) = True. I wrote this code but for both cases it sends the information to the ...
1
vote
1answer
56 views

Can we convert PDF file to Word Document?

I have a VF page on which I save that VF page content as a PDF, Now there is a new requirement in which I have to save a Word DOC file as well with that PDF so that I can perform some changes on it. ...
0
votes
0answers
31 views

Apex class access for community user

I am exposing a Apex class through rest API to outside world. Since this is going to basic API no need for authentication and security so implementing through Sites. I am just starting with basic code ...
-1
votes
0answers
18 views

Calculating list of numbers using arithmetic operations

I am looking to calculate the list of numbers using the arithmetic operations +,-,/,* in a single method. This is the code I tried. public class Calculation { public void calculate(List<...