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 votes
0 answers
14 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
8 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
0 answers
17 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
22 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
21 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

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

error while saving code

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
15 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
28 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
22 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
29 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
31 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
  • 405
-1 votes
2 answers
26 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
17 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
26 views

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

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
29 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
30 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
21 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
27 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
20 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 votes
0 answers
37 views

How can I upload .png , .pdf, xls files from salesforce to external system? [closed]

My requirement is I want to upload any file type from salesforce to external system. I have written a code but it not ploading png or pdf files in readable format. list<ContentVersion> ...
user avatar
0 votes
0 answers
28 views

Duplicate rules on large data volume

As per Salesforce docs, "In an org with many records, duplicate jobs can fail.". But is there any guidelines on counts? src: Things to Know About Duplicate Jobs Will it be good to use below ...
user avatar
-1 votes
1 answer
24 views

Im getting error Comparison arguments must be compatible types: String, NULL

global class Trainerverificationupdate implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'SELECT ...
user avatar
0 votes
1 answer
16 views

blob is not a valid utf-8 string error [duplicate]

String body = '' + documentList[0].VersionData+ ''; system.debug('body---'+body); HttpRequest req = new HttpRequest(); req.setBody(body); req.setHeader('Content-Type','multipart/form-data; boundary='+...
user avatar
0 votes
1 answer
22 views

I want make test class for batch apex

I want create test class for this batch class and when i execute with this code i got constructor() error. BatchMessageType myClass = new BatchMessageType(); Id newId = Database.executeBatch(myClass);...
user avatar
1 vote
1 answer
23 views

INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST in User.LanguageLocaleKey only from apex code

I'm having a problem creating an user in apex code. I am assigning the user the Catalan language, and it gives me an invalid value error. 10:03:28.1 (29921169)|VARIABLE_ASSIGNMENT|[2228]|this....
user avatar
  • 25
0 votes
1 answer
20 views

Call method in another class

I have UtilityController class for creating new records of custom object: Exception_Logs__c. How to call this class inside another class? So if error occured, then the Exception Log will be created. I ...
user avatar
0 votes
0 answers
27 views

PDF sent in email is broken

I want to send an email with pdf attach to it. I created a visualforce and rendered to pdf and this visualpage to an apex class to get the pdf and a button in LWC to send this email. I manage to send ...
user avatar
0 votes
1 answer
33 views

Hello there this is my Trigger on Account and have to convert this code for mass usage using batch class can anyone help with that?

trigger AccountTrigger001 on Account (after insert, after update) { if(trigger.isInsert == true && trigger.isAfter == true){ AccountTriggerHelperClass001.accData(trigger.new); }...
user avatar
0 votes
2 answers
50 views

Apex Parse Json response Error Unexpected character ('P' (code 80))

I am getting a response from the an Google books listed here As it is, not changing anything: 16:34:04.1 (100890464)|USER_DEBUG|[15]|DEBUG|response: ProcessGBSBookInfo({"ISBN:0451526538":{&...
user avatar
1 vote
1 answer
54 views

How to pass values to Lightning dual listbox?

html: <template> <lightning-dual-listbox name="languages" label="Select Languages" source-label="...
user avatar
  • 45
0 votes
0 answers
42 views

Retrieve the index of item in list before insertion within Stateful Batch Apex Class

I have a batch class that implements the following headers Database.Batchable<Map<String, Object>>, Database.Stateful . Within the DocumentParser class, I am creating a Map Object that is ...
user avatar
0 votes
2 answers
39 views

If sandbox, show a particular link in Lightning component

I know there's ways in apex to detect if in sandbox or prod. What i'm looking to do is in my Aura component, show a link when i'm in a sandbox and show a different link when i'm in prod (not a sandbox)...
user avatar
0 votes
0 answers
15 views

Salesforce lighting component controller override

As a specifc example, My Settings goes to the 'Customizable User Settings' lightning component. Inside this component, you have 'Change Password', This calls the backend class, applauncher....
user avatar
  • 1
0 votes
0 answers
12 views

can i create a field with related list quick links information?

I am needing to create 4 summary fields, in the contact card, I already tried to combine the information between both objects (Cases and contacts) but since both are native objects it will not let me. ...
user avatar
1 vote
0 answers
21 views

How to update inactive portal user record in test class?

We enabled Person Accounts in our org and there is a batch apex class that is scheduled to run every morning which does merging of Accounts in case if there are any duplicates. There is a new ask to ...
user avatar
  • 391
2 votes
1 answer
59 views

Regular Expression is matching non-whole words despite leveraging \b within the expresion

I am having a regex replace issue where the regex statement is matching non whole words. In the below example I have the word 'cormand &'. When I run the regex statement, it return 'corm &'. I ...
user avatar
0 votes
0 answers
34 views

Apex SOQL query works fine in tests but returns nothing from real database

I am having an issue where I have an invocable method that is receiving an Id for a record (in practise it will be receiving it from a flow), then based on that Id it searches for the object using a ...
user avatar
  • 19
0 votes
0 answers
39 views

How to write a trigger that is used dynamically [closed]

Here i created a trigger that is for rollup b/w account and contact , now i need to rollup on different objects ,here what evere the trigger that am using need to work for Account & Contact as ...
user avatar
0 votes
1 answer
46 views

How to send the ID to new page after insert?

There are 2 pages. I inserted one record into an object with the save button on page 1 and transitioning to page 2, Now I want to get the ID on page 2, what should I do? ID was auto-numbered by object....
user avatar
  • 5
0 votes
0 answers
35 views

Display Lookup fields in lwc component [duplicate]

I wrote my lwc code in vscode. Then I wrote in apex class a method that returns list<MyCustomObject__c> =[Select ...]; I used child-to-parent relationship so I used Child__r(Lookup(child) in ...
user avatar
0 votes
0 answers
43 views

sendEmail not working from Apex code/Anonymous Window

I am executing below simple lines of code to trigger an email to my Inbox. I am not receiving the mail and also I see on the logs that there are no errors Access level is already All Email in my org. ...
user avatar
-2 votes
0 answers
28 views

Add 10 business days in Opportunity.CloseDate [closed]

New Object: Holidays__c fields: Name, HolidayDate__c Requirement: If Opportunity close date comes in next 3 days then we need to update Opportunity CloseDate with new date by adding 10 working days. ...
user avatar
0 votes
0 answers
29 views

Why inside of for loop I can select a field which wasn't queried, but I can't use this field inside if clause condition inside the same for loop?

Let's say, I wrote a query that selects only Id field of an Object. Why inside of the for loop I can select a field which wasn't queried and successfully update it, but I can't use this (unqueried ...
user avatar
0 votes
0 answers
20 views

Unbale to update the smallPhotoUrl and fullPhotourl from APEX

I have requirement to update the photo of the user from apex, but when I check the smallPhotoUrl and FullPhotoUrl on the user Object, they are read-only, cant able to find the field-level-security ...
user avatar
-1 votes
0 answers
17 views

Hi, I am getting an flow error -The number of results does not match the number of interviews that were executed in a single bulk execution request

The requirement here is, Request data is coming from Platformevent to a flow and to the invocable method. Request data consists of two strings, one is classname and one is ContetndocumentIds(comma ...
user avatar
  • 33
-1 votes
1 answer
27 views

SFDC's out-of-the-box email to case security standards

We are in the midst of HITRUST certification info-gathering and remediation steps, and because we have SFDC's out-of-the-box email to case as a communication tool, we are looking to understand its ...
user avatar
-1 votes
1 answer
24 views

How to aggregate list value due to field

I have a query like this: List<MyCustomObj> myCustomObjList = [Select code, color, isSold FROM myCustomObj]; and that's the result: myCustomObjList = [a1a, red, true], [a1a, ...
user avatar
  • 1
0 votes
1 answer
34 views

How to remove key-value from JSON

I'm trying to get the Metadata of Global picklist from tooling API Below is the code Map<id, MetadataRecords> metadataMap = new Map<id, MetadataRecords>(); String ...
user avatar
-1 votes
0 answers
26 views

Prevent insertion of record in trigger without using addError() [closed]

I have two Object. 1] Team Members 2] Extra Members. What i want is, i want to store records of member to 'Team Members' Object. if there is already 11 members then 12th record should be stored in '...
user avatar

1
2 3 4 5
691