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

How to properly use stripInaccessible for PMD ApexCRUDViolation [closed]

On triggers I have some PMD ApexCRUDViolation errors. I see on the winter/spring 20 release notes a new apex function "stripinaccessible" to manage records/fields permissions. Could you have some ...
1
vote
0answers
32 views

How to delete a Person Account in Apex Test

I have difficulty to delete Person Account(PA) in Apex test. The reason is that I cannot figure out how to disable the associated user record. The org has Salesforce SSO and PA feature enabled. Here ...
0
votes
1answer
32 views

Adding functionality to change language of a visualforce page through a picklist

I have a visualforce page with a couple of Required Fields. The fields are made Required on the front-end by setting the Required attribute to True. There is a picklist on the top-right corner of the ...
-2
votes
2answers
59 views

Trigger not updating as logic [closed]

In below code user__c is lookup to user, but o.owner.id == s.user__c is not taken when saving the record. public class OpportunityTriggerHelper { public static void ...
0
votes
0answers
17 views

Programmatically: Export Einstein Analytics Dashboard as Image or PDF

is it possible to export an Analytics Dashboard programmatically? Programmatically could be APEX or any API like the Analytics API. The three Options i tried are via "Print Preview": Did not found ...
4
votes
1answer
184 views

Cannot use deserialized JSON for populating map - why?

I have deserialized some JSON into lists of objects: Map<String, Object> Results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); List<Object> ...
0
votes
1answer
28 views

Abstract two functions from a single logic

Here is my code, I know there must be something wrong since I cannot compile it. I just create two INSERT functions and try to use them in the 'createAppoint'. As you can see there are some logics I ...
0
votes
0answers
43 views

FIELD_INTEGRITY_EXCEPTION, Every asset needs an account, a contact, or both and field comparison

I have been trying to insert new assets to the asset table and use the serial_number to check if the asset already exist before inserting it to avoid duplicates. I'm at the point where I am trying to ...
2
votes
1answer
94 views

F2 Rename Symbol in VSCode does not work with Apex

I am unable to get the Rename Symbol F2 command to work in VSCode when editing a Apex class. When I press F2 the floating input appears, once I press enter the code is not updated, and I cannot see ...
-3
votes
1answer
42 views

Unable to cover test class for history object [duplicate]

Here is my test class public class BoothChangeReportCtrl { @auraEnabled public static List<BoothChangeDetail> getBoothChangeData(){ List<BoothChangeDetail> ...
0
votes
1answer
55 views

How can I pass a GET query param into my server side APEX controller?

Background: I am trying to redirect a user from an external site to my salesforce visualforce page with a GET query param as part of the URL. (This is part of a managed package) I want that parameter ...
4
votes
0answers
36 views

How to access field sensitivity and compliance categorization data?

With Winter'20 release we now can specify Compliance Categorization for fields. However, it's not clear if we can access it in apex. DescribeFieldResult Class doesn't provide any specific methods to ...
3
votes
2answers
119 views

diff between way of declaring list

Wanted to know the difference between these two line List<Int_No__c> outField = new List<Int_No__c>([select Id,Name, from Int_No__c where Dir__c ='Out']); and the second way of ...
-2
votes
0answers
42 views

Facing 101 soql exception in case of testing batch class

I am facing error of 101 soql in case of running test class for batch class. Please find the batch class and test class as below: Batch Class: /******************************************************...
0
votes
1answer
34 views

Hide/Show Section on VF Page based on Record Types

I want to display a section based on the record type, <apex:page standardController="Interviewers_Feedback__c" extensions="ControllerFeedback"> <apex:form id="theForm"> <apex:...
4
votes
2answers
71 views

LWC Get Combobox Option from custom Object

I am making a combobox and am expecting to get the values from the ID and Name of the custom object. I am getting an error: property 'values' of undefined The Apex: I have tested the SOQL in the ...
10
votes
1answer
342 views

Database.Stateful for a specific variable only

Is there anyway to maintain the state of a certain variable in Batch Apex across transactions. Database.Stateful will save the state for all the declared variables, Can i set it for only one specific ...
3
votes
1answer
82 views

Trigger Order of Operations - 1 second gap between before insert and after insert

Testing an apex class and decided to do some bulk testing by inserting 4,000 Account records. However i am getting a CPU timeout error (over 10 second execution time) and a portion of this error seems ...
2
votes
1answer
34 views

LWC Wired Apex to Custom Data Type

I have a requirement to display a data table for open and closed activities based on on some criteria that is from a managed packaged. The challenge was that you can not access the open and closed ...
0
votes
1answer
43 views

Batch with 3 related objects

Suppose i have 3 related objects: Continent - Country - City. Country object is child object of Continent and City is child object of Country. City -> Country -> Continent. I would like make changes ...
1
vote
1answer
28 views

Validate URL is active link

We have some URL fields that have REGEX validation on them, so they look like a valid URL. But we still need to test that the URL actually links to a live page (or live when the record was saved). I ...
-1
votes
1answer
37 views

execution of AfterDelete caused by: System.NullPointerException: Attempt to de-reference a null object

I have tried to write a trigger on custom object Project(), which is having lookup to asset. an asset can have many type of projects including "Collocation", what i am trying to achieve is: to ...
0
votes
0answers
55 views

System.security.NoAccessException: Update access denied for Name, controller action methods may not execute

I have created custom 'Create PDF' button in Quote using VF page. When I try to send email, I'm getting error "System.security.NoAccessException: Update access denied for Name, controller action ...
0
votes
1answer
36 views

unable to cover try catch condition

public class Cls_CheckDuplicateAsin { Public Id oppid; public list<serp__Opportunity_Research__c> serpOppReList; public Map<String,list<serp__Opportunity_Research__c>> ...
0
votes
1answer
47 views

Apex logic to find field utilization for an object? [closed]

I am new to salesforce and I need to find out field utilization for an object through the apex. I need to find out all field of an object by its percentage of usage so that I can show it in LWC.
0
votes
1answer
42 views

How to upload a file to content folder using standard file uploader?

Cant upload file to content folder from standard file uploader I have tried several times uploading files to the folder. But every time it shows can't upload file. If I try to upload file to library ...
0
votes
2answers
59 views

Too Many SOQL Queries 101 [closed]

I have a test class where i am getting 'Too many SOQL Queries : 101' error. I looked up my batch code for any Query violations in FOR loop or DML operations in FOR loop but i couldn't find some. I ...
0
votes
2answers
23 views

Variable not available for a batch query string

I am working on a method that is apart of a batch class to query for Contacts. I'm trying to see if the field "CASL_Compliant_Source__c" is in a keyet that I passed to a makestring method. I keep ...
0
votes
0answers
71 views

Iterate through map (Key,Value) in Lightning data table

I have mapping in the lightning Data table which i need to set in V.column property of lightning dataTable. I am unaware of syntax of iterating through them and setting the values in v.column property....
1
vote
1answer
43 views

How to pass phone and email to invocable method

I have a visual flow from which I want to pass some person account info to an invocable method. It seems that when I use a phone and email field I can't assign them to my invocable class. Is this ...
2
votes
3answers
61 views

Do Scheduled Flows run with Admin permissions?

I have a scheduled flow that calls an Apex Class. This class mainly identifies certain records and, if they are "pending" in an approval process, it recalls them and updates some fields. The process ...
-1
votes
0answers
33 views

pdf filename to visualforce page using iframe [duplicate]

Here is my visualforce page code where I am displaying pdf in iframe but i am not able to set "file name" of this pdf, <apex:page standardController="xyz__c" title="XYZ Form" action="{!Mergepdf}" ...
1
vote
0answers
45 views

What are salesforce.com and Apex like as an application development platform? [closed]

I have seen a post about Salesforce "What are salesforce.com and Apex like as an application development platform?" which is really old but raised some pertinent questions about the inefficiency of ...
0
votes
1answer
90 views

How to display records based on picklist selection using visualforce

I have 3 values in my picklist Account, Contact,Leads. I need to display the duplicate records of selected objects, for example, I have selected Contact then it should display Contact duplicate ...
4
votes
1answer
106 views

Why Does Flow Proceed Even Though Required Fields Are Blank?

Issue 1 I have a screen in my Flow with three required input components: Type (picklist) First Name (text) Last Name (text) However, I am able to click Next even if the required input components ...
0
votes
2answers
34 views

Error While uploading document to File(Contentversion,ContentDocument) In visualforce

I was using Attachment to upload file and link to custom object record in my visualforce page but now moving logic from Attachment to file and linking uploaded file to custom object record(parentsId). ...
2
votes
1answer
48 views

Possible to Break Out of a Loop in Flow Builder?

Background I've set up a nested loop, containing two loops in total, in a Flow: If certain conditions are met while iterating through records in the loops, I would like the Flow to exit/break the ...
0
votes
1answer
28 views

Can't find wrapper class definition

I am modifying inherited code in the apex controller. There is a WrapperJobs object that is returned. However, I cannot find the object definition anywhere. Can you point me to where it could be. ...
0
votes
0answers
54 views

Get record ID from a DataSourceConnection class

I have a Custom DataSourceConnection class (that extends DataSource.Connection) to retrieve related records for contacts from my server API. I need the record ID for the current contact to make my ...
0
votes
1answer
25 views

Pass the ID of current record to Visualforce Component from Apex Class/Controller

I'm working on a Visualforce Email Template which will be sent from the parent Loan (LLC_BI__Loan__c) record in Salesforce, and I'm trying to include fields from the child Entity Involvement (...
0
votes
1answer
12 views

Email address as a parameter in vf page

PageReference retURL = new PageReference('/OrderHistoryguest?orderNumber='+sapOrderNumber +'&email='+userEmailAddress); when i have passing email by apex class to vf page as a url parameter its ...
1
vote
1answer
42 views

Getting content using force.com sites in salesforce

I have a requirement where i have to download archived content from external system. However, salesforce does not allow to get archived content from REST API. The way i can download the archived ...
1
vote
1answer
61 views

Custom Inline Editable Table in LWC

I have created a Custom Inline editable table in LWC. Here are the details: Apex Class : I am getting the fields to be displayed from Field set and created one wrapper class to pass the fields ...
5
votes
1answer
85 views

Error when calling APEX method Imperatively - Submit for approval

I'm trying to pass recordId from LWC to APEX class to sumbit my record for the approval. However it gives me an error. My js: import { LightningElement, track, api, wire } from 'lwc'; import { ...
2
votes
1answer
93 views

How to check if future method has executed

in my apex code I need to do some calculation only when future method has executed I tried below code to check if future method has executed: public static void anotherMethod() { while('Completed' != ...
0
votes
1answer
21 views

Notes & Files related questions

Have a few queries regarding the new Notes . I have searched a few documentation . But havn't foun how this can be removed? How can we restrict Notes sharing option for any particular profile?
-2
votes
1answer
32 views

How to use JSON generator to create object within array [closed]

I have one JSON format { "request": { "key": "NC", "msgId": "XXXXXX", "sourceSystem": "Salesforce", "targetSystem": "test", "objectName": "Notifcation", "payload": { ...
0
votes
1answer
23 views

How to retrieve parent filed value

Let's say a have a code User tempo = [select contact.name from user where id= :UserInfo.getUserId() limit 1 ][0]; how can I take contact.name value from tempo?
0
votes
0answers
16 views

Relationship fields are visible in debug logs but not accessible through code [duplicate]

I have a weird issue where I am grabbing some __r fields and putting them into a generic SObject List (its all the same SObject type). in the debug log for the for loop line I can see the data is ...
1
vote
1answer
57 views

Trigger to update all children not giving expected results

I'm replacing a formula field (due to hitting the max number of 15 object references) with a trigger on Account (after insert/update) and on Contact (before insert/update). There are three account ...