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

Apex heap size too large: Batch Apex Stateful Class when processing all records in DB

I am creating a TF-IDF Cosine Similarity batch class to find duplicate / fuzzy match records in our salesforce instance. We have 351,000 account records and when I run the batch class I recieve the ...
user avatar
0 votes
0 answers
14 views

Linkedin Integration with Salesforce

I'm building a job seeker platform and I want the user to extract their profile data from LinkedIn. For this purpose, I'm using the LinkedIn API to fetch the profile data from LinkedIn using Apex ...
user avatar
0 votes
0 answers
42 views

Get REST API for a XML Response

I am writing a REST API that simply gets a response for a url. However the challenging part is that the response is in xml format instead of json. I am not sure how to parse this xml and get specific ...
user avatar
0 votes
0 answers
23 views

How to generate key prefix for "unstable" types

I use a mocking framework that exposes a method for generating mock record ids. The utility method uses getKeyPrefix() to mock an Id. This works for most object types but doesn't work for __Share ...
user avatar
  • 2,615
0 votes
0 answers
22 views

Email Read Receipts

My org has Enhanced Email enabled, and sending an email though the Activities panel on a record page allows me to see whether or not the email has been opened and updates the Last Opened and First ...
user avatar
1 vote
0 answers
35 views

APEX - Loop and SOQL - Performance Question (Time and Space Complexity)

Hello Salesforce Devs! I'm just curious to know which one of the below has better performance when looking up child records. For example, finding number of cases on an account: #1: List<Account> ...
user avatar
0 votes
0 answers
28 views

Lookup field from two objects up from a field

Hi I am creating an after insert Trigger of an object and I am facing a small problem when creating a related record from other object when the trigger from other object is triggered. The situation is ...
user avatar
0 votes
0 answers
22 views

How to get child records from parent in custom metadata type

I have 4 custom meta datatypes Dynamic Datatable Dynamic Datatable Columns Dynamic Datatable Cell Attributes Dynamic Datatable Type Attributes The structure of this looks like this: Here Data Table ...
user avatar
0 votes
0 answers
39 views

Same Lead converted twice...sometimes

I am trying to figure out why sometimes I see leads converted twice. The same lead will get converted (I have a formula on the account showing the converted lead id and when this happens one will have ...
user avatar
0 votes
1 answer
37 views

Before insert trigger List has no rows for assignment to SObject

I want with this before insert trigger to get for the first the last OBJ__c created for my Account(Compte__c) and put the value in the field (Last__c ) and also get the other information (Compte__r....
user avatar
0 votes
1 answer
32 views

In Queueable apex it mentions that we can add up to 50 jobs to the queue with System.enqueueJob in a single transaction. How to do it though?

I read the documentation on Queueable interface capability to add up to 50 jobs to the queue with System.enqueueJob in a single transaction. However, no example is provided for it? If you have used ...
user avatar
  • 1
0 votes
0 answers
27 views

Apex Test Class Error : Variable does not exist(method cannot be invoked)

After writing the soql apex class, I am having a hard time writing the test code. I'm trying to connect the soqlapex class and method to the test code, but I keep getting errors. I newly declared a ...
user avatar
-2 votes
0 answers
12 views

Code coverage for Batch Apex help [duplicate]

can anyone help me with code coverage for this batch apex Please ? Thank you In advance global class OppBatch implements Database.Batchable<sObject>, Schedulable , Database.Stateful, Database....
user avatar
-2 votes
1 answer
26 views

Apex Test Class assertion fails on mismatched strings

Actual Class: trigger AvoidDeleteRequirementRecordWhenStatusIsApproved on Requirement__c (before delete) { for(Requirement__c r : trigger.old){ if(r.Status__c == 'Approved'){ ...
user avatar
  • 1
0 votes
0 answers
30 views

Apex Controller extension to filter records on Visualforce Apex

SPARTADMS__Corporate_Document__c is managed package object . Using visualforce page I am able to pull all records from this object . Below is the code : <apex:page standardController="...
user avatar
0 votes
0 answers
20 views

How I access an apex:inputField value in my controller without saving the record?

<apex:inputField value="{!conpro.prod_Diesel__c}" rendered="{!bidual.Prod_Cat__c == 'Branded'}"> <apex:actionSupport event="onchange" action="{!...
user avatar
0 votes
1 answer
12 views

how to copy value from a account field in my case type_of_customer__c of picklist datatype to contact field of same field name?

public class contactTriggerHandler { public void beforeInsert(List<contact> newList) { set<ID> s= new set<ID>(); for(contact con: newList) { ...
user avatar
1 vote
2 answers
260 views

RegEx pattern matcher issue

I'm struggling with a "simple" RegEx problem. I wan't to check a sting if the pattern "BN123456" or "bn123456" is included and if so, extract it. The pattern could be in ...
user avatar
0 votes
0 answers
19 views

Access licensed object records from Partner Community

We are planning to expose some of our org data to a partner Community using Experince Cloud. However the data which we want to expose is licensed and can only be viewed with users having that license. ...
user avatar
-1 votes
0 answers
16 views

Create ContentDocument in apex which should be editable by any user who has access to the parent record [closed]

Is there any way, we can create a content document in apex which can be edited by any user who has access to its parent record? Or is there any way we can share the contentdocument with all users with ...
user avatar
0 votes
1 answer
19 views

Null Data in my columns

With this code I don't get any value , I get the column with the name but their are no value , I don't now what is the mistake . Some help please . public with sharing class Action { @AuraEnabled(...
user avatar
0 votes
0 answers
35 views

How to get a list of record that ordered by the days between 2 date fields?

I am having an sObject named Example__c. This object has a Date field Start_Date__c. I also have a record sourceExample from Example__c with Start_Date__c is dateStart. I want to find in this Object ...
user avatar
1 vote
0 answers
21 views

Chatter Posts created from Apex not visible from Profile view

I am creating a chatter post (FeedItem) from a trigger on a custom object after update of that object. I want that post to be visible on the user's profile that I have specified in the ParentId. The ...
user avatar
  • 21
0 votes
0 answers
21 views

Redirect to a record page with a certain tab already open

I want to to redirect my user to the record page after a visualForce page, but I don't want to be redirected to the usual record detail tab open. I want to be redirected to the same page, but with the ...
user avatar
  • 77
0 votes
1 answer
52 views

Flow Invocable Apex - The number of results does not match

Hi I'm running into the following error when my scheduled flow does an Apex Action The number of results does not match the number of interviews that were executed in a single bulk execution request. ...
user avatar
  • 7
0 votes
1 answer
51 views

SOQL query in .js file in LWC

Can I write SOQL query in js file of LWC Comp. I don't want to do query in apex class. Is there any way for doing that?
user avatar
-1 votes
0 answers
32 views

Tracking data pullback from SFMC to the CRM [closed]

If we are using Salesforce data to sending emails from Salesforce marketing cloud then how to pull back the tracking details like (opens,clicks) data from SFMC to CRM/SFDC. When we are using ...
user avatar
  • 1
0 votes
0 answers
30 views

B2B LEX Order integration with external OMS - unit tests with OrderSummary

We are working on a new B2B implementation for one of our clients. One of the tasks is to send the order data from B2B to the client's OMS. This is not SF OMS. I am looking into the SF data model for ...
user avatar
  • 101
0 votes
1 answer
39 views

VF component email template to send list of opportunities against each owner. The templates loads the only last value of list

//VF Component <apex:repeat value="{!oppUserList}" var="opp"> <tr> <td> {!opp.Name} </td> </...
user avatar
  • 15
0 votes
0 answers
43 views

How to remove duplicate value in an salesforce custom object

KYC is a custom object, Kyc is having a lookup with account and lead. I have written 2 triggers to create KYC records one on the lead and another on the account. Now when the lead is created KYC ...
user avatar
-1 votes
0 answers
24 views

How to implement a logic that stores on fields how many child records are on the parent entity

I am novice in anything connected to salesforce(I mostly learn Java). So, the task is to Create two custom fields on the Account object: a. Contact Count (Contact_Count__c) b. Opportunity Count (...
user avatar
0 votes
0 answers
16 views

How to filter a data table on selecting a picklist value in aura components?

So I have got different picklists in my aura component and I want to filter the visible data on selection of some value/values. I have three picklists in my component for selecting values and I have ...
user avatar
  • 1
0 votes
1 answer
32 views

How can I not override other people changes while using IDE?

I use IntelliJ with the Illuminated Cloud 2 plugin Whenever I make a change in a class, I need to do "refresh metadata" to the class before making a change or the current code for that class ...
user avatar
  • 35
0 votes
1 answer
31 views

Apex CPU Error Timeout on Simple Invocable Method

When dataloading accounts - I keep getting an Apex CPU Timeout Error on the following action in the flow. There aren't many contacts on the accounts being passed in - (less than 20?) Am I missing ...
user avatar
  • 131
-1 votes
0 answers
36 views

How to retrieve the current Object ID of a school custom Object in Apex class in order to show only the students of this school [closed]

I have many schools and in each school I want to add the LWC which is a table containing student informations. How to I take the ID of the School record I am in in order to write my SELECT SOQL query.
user avatar
-1 votes
0 answers
30 views

error while saving code [closed]

i am getting error in this line res.responseBody = Blob.valueOf(e.getMessage()) = resWrap.errorCode; error message: Expression cannot be assigned How can I resolve this error?
user avatar
-1 votes
1 answer
17 views

Link a Student Name to the Student Custom Object in LWC SalesForce [closed]

When I created the LWC components it contains the Student Name with his grade I want to allow the user when he clicks on the Student Name to be redirected to the student record in Student Custom ...
user avatar
-2 votes
1 answer
30 views

I am getting an error while executing this code : Method does not exist or invalid signature:Void start() from the type Companies Test

Public class CompaniesTest { public List<String> logs = new List<String>(); public static string GD_Synthego_API_Token_Id = EncodingUtil.URLENCODE(System.label....
user avatar
-1 votes
0 answers
28 views

How to change password for a user without knowing old password for community site user using Apex?

I am trying to update the password for a community site user using the VF page and Apex. I'm using the below code and it's working fine for the org but I can't log into the community site using the ...
user avatar
0 votes
1 answer
33 views

I need to make discount depends from Registration date

I need to create discount and in the future if we need to change discout amount or Years from registration, we need to do this without code changes My code public with sharing class ...
user avatar
0 votes
1 answer
39 views

should exception's inner class be public or private

Scenario: I have 1 APEX class, in which I have inner class extending exception, as can be seen below: public with sharing class ClassA{ PUBLIC/PRIVATE class ClassBException extends ClassCException {...
user avatar
  • 417
-1 votes
2 answers
30 views

How to get count of rollup summary, formula field, relationship field(Both lookup and master-detail) on an sObject in apex salesforce?

I am trying to build a Lightning Web Component in which user will select a sObject and the object limit related to that sObject will show, like how many rollup summary, formula field, relationship ...
user avatar
0 votes
0 answers
19 views

Issue in capturing approval comments in trigger

Helper class: Public class HelperClass_ApprovalTrigger{ Public static void afterTrigger(List<Grant_Contract__c> newList) { User gUser = new User(); gUser=[SELECT ...
user avatar
  • 11
0 votes
0 answers
28 views

I am writing test class for Apex batch but I am getting just 17% test coverage [duplicate]

Batch class public class StoreWorkTimeBatch2 implements Database.Batchable<sObject>{ public Database.QueryLocator start(Database.BatchableContext bc) { // 1. Get Custom ...
user avatar
  • 1
0 votes
1 answer
31 views

Difficulties with a repeat that should print a list of images in the VFP

I have some images in Documents, and I am saving the link to these images in a list, the idea is that all the images contained in that list are printed in a contentType="application/msword" ...
user avatar
0 votes
0 answers
21 views

remove popup in aura

I am new to salesforce and learning the aura framework, in that I am stuck at a point where a blank pop-up got opened every time when we clicked on a create PO button, for the past 2 days I am trying ...
user avatar
1 vote
0 answers
42 views

Difference in behaviour of a class when invoked in Platform Event Trigger vs Anonymous Apex

Hello SF StackExchange community, I am currently encountering a strange behaviour with Platform Events Trigger and couldn't find an explanation. I am getting the "attempt to de-reference a null ...
user avatar
  • 75
0 votes
0 answers
26 views

field is not updating and showing no error for guest user

The below method is being called from the guest user and it seems to work absolutely fine as there are no errors and the debug logs are showing the updated user record. But when I query the record ...
user avatar
0 votes
0 answers
31 views

sfdx force:source:deploy with RunSpecifiedTests run all apex test

Our organization uses below command for validation sfdx force:source:deploy --sourcepath {{ CI_PROJECT_DIR }}/src_delta -l RunSpecifiedTests -r "$(cat {{ TEST_CASES }})" --json -c -w 0 A ...
user avatar
0 votes
0 answers
21 views

Before insert trigger based on a field

I want by my code to Retrieve the Last Object inserted by its creation date in the LastObject__c field in a before insert Trigger . I don't now if this code is correct or now . Some help please ...
user avatar

1
2 3 4 5
691