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
0 answers
19 views

Cannot change Status of FeedItem in trigger

I have a simply spam classification logic in trigger which runs when a community user posts a post (FeedItem) in experience cloud sites (community sites). trigger FeedItem_Operation_Trigger on ...
user avatar
0 votes
1 answer
52 views

Apex class access issue with profile : summer 22 release

We are facing many issue related to apex class access across multiple profile. This issue started just after summer22 release patch. Our org is impacted and many users with different profile are ...
user avatar
  • 23
0 votes
0 answers
59 views

How can I refresh data on LWC which is received by Apex method imperatively?

I have written wire and if data is received successfully I am calling function in which apex method is called imperatively, so how can I refresh results of that apex call for example on button click ...
user avatar
-1 votes
0 answers
24 views

How would I write a test class for this Apex Class [duplicate]

I am new to apex and have managed to hack this together. public class ContactsListController { private String sortOrder = 'LastName'; public List<Contact> getContacts() { String ...
user avatar
0 votes
1 answer
31 views

Some History object still show "MISSING LABEL" message when use Schema to get label or get label plural

I try get some objects label or label plural by using Schema method, but for some of History objects I will get follow message in label and label plural: "__ MISSING LABEL __ PropertyFile - val ...
user avatar
1 vote
1 answer
41 views

Add value to multi-select picklist with batch class

I'm trying to add a value to a multi-select picklist with a batch class. The debug statement shows that its being added but it's not saving for some reason. Any ideas? public class ...
user avatar
1 vote
0 answers
45 views

Unable to Set Response Headers in Abstract or Extended Class

I am trying to set the Content-type header to application/json on REST response in apex and no matter where I set it, it always returns application/octetstream. I am using an abstract base class. When ...
user avatar
3 votes
1 answer
229 views

Salesforce Flow Limitations - Loop vs Batch Records

I have recently been digging into salesforce flows. I created quite a large flow (basically a series of subflows). It all worked as expected, and was based on when one of my objects was created or ...
user avatar
-1 votes
2 answers
47 views

How to Assign Custom Metadata value in Apex trigger

I have a requirement whenever Opportunity Stage is moved to "closed won" I need to create a Task and assign it to Queue. I am getting regular requirement from users to create a Task with ...
user avatar
  • 65
0 votes
0 answers
26 views

Guest use receive error No profiling information for SOQL operations

Guest user receives an error after pressing redirect button in VFP 14:55:47.2 (40002254)|CODE_UNIT_FINISHED|VF: /apex/dossierattachmentsform 14:55:47.2 (40024393)|EXECUTION_FINISHED 14:55:47.43 (...
user avatar
  • 17
0 votes
1 answer
27 views

Add an email recipient to an email sent from Salesforce

Is it possible to dynamically add an email recipient to an email sent from Salesforce? What I wanted to achieve is: If an email is sent to the email address a@google.com it should additionally be ...
user avatar
0 votes
1 answer
27 views

how to get Profile name of lastModifiedBy in fflib selector class

I'm facing issue that when I add LastModifiedBy profile name is getting in soql but when query it in fflib then is getting empty list public List<Order> selectOrderIdsByProfileName(Set<Id> ...
user avatar
-1 votes
0 answers
46 views

i want to send SMS with twilio using salesforce api

heyy i try to send sms with twilio using salesforce api but i want to call that apex class in my flow so plz tell how to do it if code is wrong plz let me know here is my code. public class Sendsms { ...
user avatar
  • 1
1 vote
1 answer
47 views

Unable to delete LWC and Apex Classes from Production Org: Entity is Deleted

We created a Lightning Web Component, which has an Apex Controller and Test class. The component is no longer needed and we now want to try and delete it. Using my IDE (IntelliJ and Illuminated Cloud) ...
user avatar
  • 113
0 votes
0 answers
25 views

Unable to deploy LWC in org

I am trying to deploy a LWC in my dev org but unable to do so because of an error: 'Unable to find Apex action method referenced as 'RetrieveContacts.getContactList.' I have checked and the apex class ...
user avatar
  • 53
-1 votes
1 answer
32 views

Checking Set contains from the list<string> element list

I have to list of subset of some text and Set of subset of some text and I'm checking to see if set text contains string from the labels but it seems that does not seems to be working here is my code: ...
user avatar
0 votes
0 answers
26 views

No Emails for the assigned user after Task is created

I have a apex code which creates task when A1 record is assigned to a certain user. The assigned user would/should recieve email notifications. So when a task is created. Saleforce autmatically sends ...
user avatar
  • 49
2 votes
0 answers
19 views

Cannot access salesforce namespaced protected custom metadata

I created a namespaced protected custom metadata to store API keys, it is working fine in my scratch orgs. However, when I am packaging it as 1GP and installing the beta package in a developer test ...
user avatar
0 votes
1 answer
19 views

How can I send a list of records (multiple forms with key-value pairs) in a single request via multipart/form-data HTTP POST

This is not about files, but about key-value pairs. And I already got below to work for ONE submission/record. How do I tweak below to support multiple record submissions? private final static string ...
user avatar
0 votes
1 answer
26 views

Test class for covering running user current application info

I have a class where I am using a method that returns the application label of the current logged in user. I am using that class method in another class method and based on the returned app name, I am ...
user avatar
0 votes
0 answers
7 views

Email replies creating new case

My first question here so not sure if I am missing any details, happy to provide more. I have created a batch class to send out email reminders to contacts that Cases created by them are awaiting ...
user avatar
0 votes
1 answer
24 views

How to get deployment's error messages using SOAP

I'm developing an app that uses APEX + SOAP API to retrieve and deploy metadata (specifically - objects). I'm using apex-mdapi to get it done with SOAP. I want to retrieve deployment's details when it ...
user avatar
0 votes
1 answer
39 views

How to show dynamically all fieldSets and their fields in a page bloc table

I want my visualforce page to show each of my fieldSets in a pageTable, and the columns of the tables to be the fields present in their fieldSet. I want to be able to do that because I dont want to ...
user avatar
  • 43
0 votes
1 answer
23 views

How to pass a list of custom object records from Apex to Visualforce

EDIT: Updated Apex controller I want to pass custom object records to a vf page to be rendered as a table. See below code. The controller method is called from a LWC. Apex Controller: public List<...
user avatar
  • 398
-1 votes
1 answer
41 views

Fetch all the accounts from large account hierarchy

I'm trying to fetch all the accounts from account hierarchy from all the levels, code should work for any number of levels. for example : If there is a account hierarchy then using any of the account ...
user avatar
2 votes
1 answer
48 views

How do I run the default Lead assignment rules on a Lead trigger

Here's my code stripped of the usual professional infrastructure for illustration: trigger LeadTrigger on Lead (after insert, after update, before insert, before update) { if ( ! Util....
user avatar
-1 votes
0 answers
10 views

To send the hyperlink of inserted contacts and opportunity of the record page to the email using batchapex.I am unable to get the hyperlink

global class DemoBatch implements Database.Batchable <sObject>,Database.Stateful { global final String query; global final Integer con; global final Integer opp; List<...
user avatar
  • 1
0 votes
1 answer
26 views

Get value from Map in trigger

I am trying to get values from map and assign the value in trigger. Below is the code so far - I need to get ID based on a value from a Map which I have created. public class AccountTriggerHandler ...
user avatar
-1 votes
0 answers
31 views

UTF8 decoding issue

I have an api exposed and the external system is calling the API and from that, we are creating a record of data received from the external system. Some of the values are in german like 'München' but ...
user avatar
0 votes
0 answers
15 views

Uncaught Error in $A.getCallback() [state.getReturnValue is not a function] Callback failed: apex://CustomButtons/ACTION$getCaseType

Trying to create buttons that displays all the types of cases in the contact record page here are my codes. Component - <aura:component controller="CustomButtons" implements="...
user avatar
0 votes
0 answers
34 views

PMD Configuration For Salesforce

I am new PMD tool, i did below steps to configure PMD for salesforce and unable to proceed. Can anyone please help me here. Please tell me if i am missing something. I have downloaded the PMD for ...
user avatar
0 votes
1 answer
28 views

Attempt to de-reference a null object when throwing a custom exception

I have created a custom Exception class public class StatusException extends Exception{}; when using it to throw an error it's throwing a null pointer exception too. public class ContainerSync2 { ...
user avatar
-1 votes
0 answers
18 views

fetch record with maximum end date [closed]

I have three record on the same object. All the record have end date filed. I need to fetch out the record which has maximum end date among three.
user avatar
  • 5
0 votes
1 answer
18 views

Iterate over all fields of all FieldSet of an SObject

Just posting this because it took me a bit of time to get my answer. For anyone wanting to get a list of all the Fileds present on all the FieldSets of an Object, here is my method. Hope it will be ...
user avatar
  • 43
5 votes
1 answer
74 views

Summer 22: Deleting Public Group doesn't delete Shares in Apex Test

I have a test that was working fine for 2 years, unchanged, which is now failing post Summer 22. Ultimately, it deletes a Public Group and the assertion tests that any associated AccountShares are ...
user avatar
  • 1,057
0 votes
0 answers
24 views

Summer 22 Schedulable Test System.CalloutException

I don't quite know how to explain the behavior we're seeing. I have two test methods that test exactly the same thing (same inputs, same assertions). The only difference is that one schedules the job, ...
user avatar
  • 1,057
0 votes
1 answer
24 views

Error passing argument to Apex method

I have an event that is triggered on a button click. This event calls an Apex class, passing an argument with it. Without the argument, the code runs fine, however when I pass in the parameter I am ...
user avatar
  • 31
0 votes
2 answers
21 views

Are processes triggered if a field is set to the same value as it held before?

An Apex method is called and updates the StageName field from 'Approved' to 'Documentation.' It completes. A different Apex method is called and 'updates' the StageName field on the same record from '...
user avatar
1 vote
0 answers
51 views

Named Credentials with JWT Token Exchange: problem with "subject_token"

I was trying to setup a Named Credentials with JWT Token Exchange (i.e. not the basic "JWT" option) to use GCP Identity Federation and I got this error when doing an APEX Http callout: ...
user avatar
  • 111
0 votes
0 answers
37 views

Is it Possible to Transpose a LWC Datatable, i.e Making the columns rows and rows columns?

Was wondering is it possible to transpose a LWC Datable? For example i want the flip my columns to be the rows and each column will represent a row if that makes sense? It was hard to find anything ...
user avatar
-1 votes
1 answer
24 views

How to compare values in soql query when field may have a different format

I don't know if there is a way to solve this, I couldn't find it. I am importing a CSV file where I am to create an sObject for each line. The thing is, I have to do a query using a value present in ...
user avatar
0 votes
1 answer
19 views

Typecast to SObject list to SObjectType passed to a method

I have a list of SObject and SObjectType parameters passed to a method sObjectTypeRecord in the below method contains Lead.SObjectType,it can also contain any other SObjectType like Account....
user avatar
  • 1,093
1 vote
0 answers
30 views

How to render JSON array from LWC as a table in Visualforce

I have a LWC with a datatable. I need to generate a PDF of this datatable. How can I pass the JSON string which populates the datatable to a VF page and render the table there? See what I have so far ...
user avatar
  • 398
1 vote
0 answers
26 views

How to find out if a schedulable class was ever executed or is scheduled to be at all?

I am considering removing a field, which is no more needed, but I found it is used in a class, that I am not familiar with. It is a schedulable one and I first looked at the scheduled jobs in Setup, ...
user avatar
0 votes
0 answers
16 views

ContentDistributionTrigger after insert ContentDownloadUrl null

I have a ContentDistributionTrigger trigger after insert & update which when fired has a null value for ContentDownloadUrl. The ContentDistribution is created in a ContentDocumentLinkTrigger as ...
user avatar
2 votes
1 answer
114 views

Lean, fast and flexible replacement for the fflib QueryFactory

I just decided to kick the fflib QueryFactory out of a customer project because of its complexity and sub-par performance. My Custom Query Building is fast but I fear I will reinvent the wheel. Which ...
user avatar
0 votes
1 answer
87 views

Order By id not support in Publisher

In my apex code, I have this SOQL: [SELECT ID FROM Publisher Order By Id], this SOQL works fine in API 49, after upgrade to API 54, Salesforce will throw error run this SOQL. After research I found ...
user avatar
-4 votes
0 answers
13 views

Want Test class for below class [duplicate]

global class WebAdmitDailyJob implements Schedulable,Database.Batchable,Database.AllowsCallouts { global void execute(SchedulableContext SC) { Database.executeBatch(new WebAdmitDailyJob(),...
user avatar
0 votes
0 answers
14 views

Test class for files upload method using contentDocumentlink for Guest user [duplicate]

I was trying to write a test which will take input as a file upload field and store file onto a dummy record then attaching it to the Lead record and removing those dummy record data after attaching, ...
user avatar
-1 votes
0 answers
16 views

how to write test class for the attachments [duplicate]

I'm facing problem to how to write test code for the attachment class.Please provide solution for that. Apex Class public class CaseControllerExt { private final Case acase; public Blob afile ...
user avatar
  • 1