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
1answer
31 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
21 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
41 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 ...
-3
votes
0answers
27 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
25 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
91 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
20 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
19 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
30 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
21 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
23 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
39 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
56 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 ...
6
votes
1answer
124 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
33 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
41 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
52 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
30 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<...
1
vote
1answer
42 views

Is there any method to check the POSSIBILITY of converting a string to an Integer type?

Is there any way or method to check the POSSIBILITY of converting a string to an Integer type, or in other words: how do I know if an exception will be thrown when converting a string to an Integer? ...
0
votes
1answer
20 views

How can I cover this contact owner assignment in test class after lead convert?

I have written a trigger helper method that converts to contact and associates the contact with an existing account. The contact owner becomes the owner of the account as shown in this snippet Now I ...
0
votes
2answers
57 views

Need help moving SOQL out of the loop

Hello, I need move this query out of loop: List<Lead> dupeLeads = [SELECT Id, Email FROM Lead WHERE Id != :Ld.Id AND Email =: Ld.Email]; I'm testing various guides on "bulkifying ", ...
-4
votes
1answer
44 views

Need some input on Apex class [closed]

I have a requirement to show all Survey questions/Answers in one single record. I have 5 survey questions. Once survey is completed I need to get all 5 answers and need to populate in different object ...
2
votes
1answer
60 views

Tag and @mentions in custom LWC?

I'm attempting to tag a users in a custom lwc component. THis is my current code. @AuraEnabled public static void postFeedItem(String msgTxt, String recordId){ ConnectApi.FeedElement ...
0
votes
1answer
65 views

Can you help point out the issues in the code

This is a code I have done to fetch all the accounts near a closedwonAccount. I have fetched the closedwonAccount using a flow and called it to the apexclass using @invocable method. I have debugged ...
1
vote
1answer
42 views

How to get the field value from object. I am using deserializeUntyped

I am trying to get the field value from the object. If I loop through the object it looks like Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(RestContext.request....
0
votes
0answers
13 views

How to check if another managed package from same namespace is installed - 2GP

Scenario: Single namespace with multiple 2nd generation managed packages. Core |-Extension 1 |-Extension 2 In this example how can I determine whether or not Extension 1 is installed from Extension 2?...
0
votes
1answer
32 views

Skip Sobject that has an error during DML operation

I have a list of Sobject which I'm trying to update, but I want to skip those Sobjects that throw an error or more precisely those that have Sobject.addError('') during the trigger call. i.e if I ...
2
votes
1answer
34 views

How many flow interviews can I run per transaction?

Is there a limit on the number of autolaunched flows that can be invoked by a process builder or apex trigger/batch in a single transaction ? As per this document , enterprise orgs are entitled to 10,...
0
votes
1answer
52 views

Test class for Transaction Finalizer is not working

I am stuck in the test class for the Transaction Finalizer class. Every time when we create an exception for Queueable class then Finalizer class executing and then the test class throws the error on ...
0
votes
1answer
22 views

Fee field must not be blank

In this trigger apex, I want to give error when Fee_paid__c field must not be blank. We can throw the error as "Please enter amount" I tried above code trigger Not_Negative on Student__c (...
0
votes
0answers
36 views

BillingState Issue

i am trying to get BillingState value from apex trigger before insert, before update. I have troubles when change the value it got the last one and not the actual value I do a debug and get the last ...
-2
votes
1answer
54 views

AsyncApex Scenarios [closed]

I am writing a few Ques for which i have found conflicting answers on Internet. Also I have written my Answers after researching on Internet, but wasnt 100% sure, hence posting these here to clear ...
0
votes
1answer
30 views

Getting Multiple times output

In this batch Apex code, I updated Mr. infront of the name if student is Male and Mrs. infront of the name if student is Female but at in output Mr. or Mrs. is getting multiple times. Please give me ...
0
votes
2answers
25 views

File upload to multiple Opportunity

I have requirement to upload a common file to more than 400 opportunities. I am executing below script on Anonymous window but getting error as Variable does not exist: Id ContentDocumentLink objCDL = ...
0
votes
0answers
41 views

REQUIRED_FIELD_MISSING when saving data

Hello I'm getting this error when saving data from a form to database. This field isn't a field from My contact I just add it to try to solve the issues, but nothing happens. 11:32:59:059 FATAL_ERROR ...
-2
votes
1answer
36 views

Calculate discount

In this batch apex class i want to apply discount to the students. If student is male then we can apply discount 10%. If student is female then we can apply discount 20% The above is the code that i ...
0
votes
1answer
27 views

How to swap two values in visualforce page

In this visualforce page there are two inputs and one button. How to swap the values in given two inputs from input-1 to input-2 and input-2 to input-1. Please provide suggestions I tried the above ...
-2
votes
0answers
24 views

Can we get the Id of the record in Apex in the next line after Insert statement inside a Trigger Handler? [duplicate]

I need to create a Before Insert Trigger for Object A__c, where in I will check if the record has email Id matching with any of the records of Object B__c. If yes, I need to populate Id of that record ...
0
votes
1answer
36 views

Apex Convert Positive Currency to Negative Currency

I'm wondering if my syntax is off. My varCreditRefundAmount is a positive value and when I add it to a new transaction representing a refund, I want to convert it to a negative amount. This is what I'...
0
votes
1answer
30 views

How to create a batch to count the worked days of the users based on LoginTime

I need to create a batch to count the worked days of the users based on LoginTime, excluding only the weekends (Saturday & Sunday), but I'm quite new in the programming area and I have been ...
0
votes
1answer
42 views

Trigger to compare records in different Objects not working as expected

I have refered the following thread to solve my problem. Not sure where I am going wrong. Compare records with same field value from different Objects in apex? Here is my attempt: PROBLEM: While ...