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
2
votes
2answers
713 views

convert report data to csv format and send attachment in mail using apex

Please find below code,I am getting attachment in html format. But i need attachment in csv format. Let me know what changes I have to do ? global class MonthlyScheduler implements System.Schedulable,...
0
votes
1answer
1k views

Delete multiple records from Custom objects with Lightning Components

I am adjusting my salesforce Application to include Lightning Experience compatibility. One of my application functionalities is to delete records from custom objects by pressing a button called ...
-2
votes
1answer
45 views

How to create JSON Generator with apex in post api [duplicate]

I'm new in Apex and we have a requirement, Need to send a record from Salesforce to an external system using Rest API whenever a record is created in Salesforce, I need to send a couple of SF fields ...
0
votes
0answers
31 views

How to convert the created date into current date format [closed]

I have written code which will return the Response deatails. So whenever am created the response and viewd it am not getting the created date in current time date format. It is showing me the ...
0
votes
1answer
580 views

LWC navigation to custom tab encryped the parameters?

I have a LWC Navigation component that is going to a custom tab that inturn loads a VF page, with params. This all works as expected and the url structure for the user is correct. However in the VF ...
-3
votes
0answers
33 views

create custom case record in sales force using Rest API, [closed]

I want integrate Google platform(GCP) with sales force using REST API. Get the Data from GCP to Salesforce store in custom object.Here Google plat form send json format data as notification and sales ...
0
votes
2answers
31 views

How to track formula field which is related with different objects?

I have one formula field on Opportunity which is the calculation of the Revenue from the SubscriptionFee__c object + Rate from the Rate__c object. In Opportunity, we want to track the history of this ...
-3
votes
2answers
109 views

Cover addError in Test Class

I built a trigger to not let the user approve (change Status__c from SST Approved to BA Approved) an Opportunity without filling in Batch__c field. Trigger: trigger OpportunityApprovalValidation on ...
-1
votes
0answers
36 views

Social Login via Apple - signing a JWT to get an access token

I’m basically trying to implement a social login to my website via Apple. One step of the OAuth 2 flow running under the hood is to get an access token. To get it, as per the documentation (https://...
1
vote
1answer
490 views

When I'm validating / Deploying change set , giving me this error - Package installation failure

When I'm deploying some apex classes with lightning components from 1 developer sandbox to another developer sandbox , it is giving me this error with no information. I don't have any managed/...
0
votes
2answers
27 views

Changing of date format in apex

1.How to change the 2021-06-15T02:30:00.000Z to date(15/06/2021) in Apex? I have tried multiple ways but not working please help me with the code.
0
votes
1answer
504 views

Javascript in Web-to-Case form

I want to include javascript in my web-to-case from. My sole purpose of doing so is to Query from Salesforce Database in that form. How can I achieve this functionality. Can I use some controller as ...
1
vote
1answer
2k views

how to convert “04/09/2015T06:00:00.000Z” into apex datetime

How to convert this text "04/09/2015T06:00:00.000Z" into a valid apex datetime ? where the time should be unmodified
0
votes
1answer
33 views

Apex Method to reset (or set to 0) fields values [closed]

I would like a method to reset my values any time I need it. I can call it many times in my code, and I don't want to repeat all each time. Like dataUtils.reset() for (Sobject__c variable : ...
0
votes
2answers
46 views

Need help with a mystery null pointer exception

I'm getting Null Pointer Exception from some recent code changes and I can't figure out where it's coming from. I've put ** around the new code. Any help would be appreciated! System.DmlException: ...
0
votes
1answer
1k views

Apex Trigger for Cloned Record - Values changing before and after insert

I have the following trigger for changing values when a record is cloned: trigger oppAutomation on Opportunity (before insert) { if(trigger.isBefore){ if(trigger.isInsert){ ...
0
votes
1answer
32 views

How to remove particular text from paragraph?

I have rich text field . I want remove font weight style from that. Eg: "<p>Salesforce Technoligy</p><br><p><b>Releases:</b></p><ul><li><b ...
1
vote
0answers
23 views

Lightning Component | Generate Picklist and Associate LastName of Contact from Account Record

I'm adjusting this, so that it's creating multiple contacts associated with the Account. I can't figure out two things. How to pre-populate the Contact.LastName that is associated with Account....
0
votes
2answers
1k views

reRender not working on visualforce page

Here is the apex component <apex:pageBlock id="tableId2"> <apex:pageBlockTable value="{!lstResultWrapper}" var="items" id="table"> <apex:column ...
0
votes
1answer
660 views

Send case attachments in visual force email template

Does anyone know if its possible to send case attachments using visualforce email template? Currently, I have got a process builder that triggers an email related to case details once case is closed. ...
0
votes
1answer
57 views

combine SOQL queries with different order by

I have 2 SOQL queries based on the different 'order by'. Below are the queries list<case> CaseTypeA = [Select Id, status, createddate , Priority from case where status = 'New' order by ...
0
votes
1answer
709 views

Show/Hide Custom Button, As per specific picklist value Selected on Opportunity Field

I want to Show/Hide a Button as per specific Selected picklist field value on record details page for Opportunity Object. If the picklist field value is any thing rather than that value , Button ...
0
votes
0answers
34 views

Apex for Admin Trailhead: Code Not Working

I'm working through the Trailhead and have triple checked my work, watched the video that goes along with the unit, and have researched the problem as much as I know how. The problem is linked here:...
0
votes
1answer
35 views

Query HTTP Calls Made to My Salesforce Org

I would like to know how to obtain the HTTP calls made to a Salesforce org. The org has a few connected third party applications and I would like to identify which applications are making certain ...
0
votes
0answers
44 views

Weather API callout issues

I am currently working on creating a prototype LWC that gives weather information for a given location. The location is being provided via user input. For some cities, it works fine - as in the case ...
3
votes
2answers
693 views

Can we detect presence of a 'Chart' in a report for using <analytics:reportCharts> component?

When using the component I'm receiving following error due to a chart not present in the report, be cause I verified Report exists and is public shared and report types are valid (Summary/Matrix), ...
15
votes
3answers
29k views

How can I query the class which the schedule job will call

I am trying to get the name of the schedule / batch classes called by the schedule job Trying this select Id,CronJobDetailId,CronJobDetail.Name, NextFireTime,PreviousFireTime,State,StartTime,...
2
votes
2answers
501 views

Field is not writable on custom Big Object in APEX

I'm trying to read a set of records from a custom Big Object, update a long text field (not part of the object index), and then upsert back. When trying to update the value of the field I get 'Field ...
2
votes
2answers
116 views

How do I set some List<Account> fields from a List<AggregateResult>?

I am learning Salesforce and Apex and I got the following task: whenever an opportunity is updated or created, calculate the related accounts total number of opportunities and total sum of those ...
0
votes
1answer
25 views

Variable does not exist: Name compilation Error

I am trying to create a new case once the rating of a Hotel is < 45% Here Hotel__c is the parent object and Customer_Reviews__c is child Object with MDR Even though there is a field called Name i ...
0
votes
1answer
246 views

How to get last created record date of all custom objects having total number of records greater than 1 lakh

My requirement as part of org analysis is to get list of all custom objects having more than 100000 records and created date of LAST CREATED record. My tries are as follows:- Go to Setup - Storage ...
9
votes
1answer
145 views

Is there is any way to get standard field api name from standard report types reports in apex?

I want to get the api name of the standard field being used in Reports of Standard report types. I used describe methods to get the columns used in a report. I analysed some of standard reports ...
3
votes
4answers
1k views

http 500 calling apex method imperatively with complex parameter

I am trying to call an Apex method imperatively with complex parameters from a Lightning Web Component but I'm getting an http 500 response every time. Here is what I'm doing which is a copy of this ...
0
votes
2answers
1k views

How to write Batch Apex for counting number of associated Contacts with Account

I'm writing batch class to count number of Contacts associated with Account, I want to update custom field in Account object Number_of_Contacts, this field counts the number of contacts associated ...
0
votes
1answer
44 views

Map returned to JS does not include null values

I use a managed package that gives me the ability to invoke Apex class, get result and handle it. My Static Resource (JS code) invokes Apex to fetch one or more records from the DB and return them ...
0
votes
0answers
28 views

Removing Push Topic in Uninstall Script of Managed Package

Our managed package creates a push topic in the subscriber org as part of our use case. We need to remove this push topic on uninstall of the package. Can we perform delete operation on the push topic ...
0
votes
0answers
33 views

FSL Trigger Exceeding Apex CPU Time Limit

I am attempting to integrate Salesforce using some middleware.  What the integration does it take an Excel sheet, and from that sheet create a Work Order, Service Appointment and Assigned Resource ...
0
votes
1answer
29 views

Granting Account Login Access using Apex

Is there a way to Grant Account Login Acces using Apex? Not through the UI as shown in the screenshot from below. Maybe something using the Tooling API? Or Metadata API? Thank you in advance!
1
vote
4answers
2k views

Maximum number of records a trigger processes in a single batch?

What is the maximum number of records a trigger needs to be able to process in a single transaction/batch? Is it limited to 200? or do triggers need to be able to handle more?
-1
votes
1answer
49 views

Can anyone explain logic inside trigger exception

trigger accountDeletion on Account (before delete) { // Prevent the deletion of accounts if they have related opportunities. for (Account a : [SELECT Id FROM Account WHERE ...
0
votes
1answer
1k views

Is it possible to use Javascript in an Apex class?

I am trying to use an inbound email handler to extract a PDF attachment, and then parse out all of the PDF text and save it on a field. The way I am currently doing this is by using a 3rd party ...
1
vote
1answer
7k views

Lightning component - event.preventDefault()

I have a lightning component which has a form using lightning:recordEditForm and when the user clicks submit I call an apex method which can return error message. So if the method returns an error ...
0
votes
0answers
39 views

how to handle date value blank in csv while deserialize in apex

I have build LWC for uploading the csv file and processing upsert/delete operation through batch class while while deseralizing the JSON string through JSONParser class if date column is present in ...
1
vote
1answer
613 views

Exporting CSV using Reports.NotificationActions

I am trying to include a custom action on future run reports to automatically export the csv content with the report scheduled. I have had success with sending the email in this way, but am ...
0
votes
1answer
496 views

Get Date/Time in GMT for selected date

user selects the date some thing like this c.Date_Time_Scheduled_Service_Call__c=2018-09-28 03:40:00. By default salesforce stores date time in GMT. I would like to get that stored dattime GMT in apex....
0
votes
1answer
786 views

InputText for capturing Date field

I have a Date (Completed_Date) field in my Timesheet object which I want the users to be able to update and Save after a Timesheet is submitted. I have been able to pass the field from Controller to ...
1
vote
1answer
578 views

Get custom multiselect checkbox values in apex

How can I fetch the check-boxes that are selected on my Visualforce Page page if these check-boxes were created dynamically using JavaScript without any apextags? <apex:form> <table ...
0
votes
0answers
53 views

How to compare many fields from two different objects and combine into single value in apex? [closed]

I am extremely sorry I'm running out of ideas about the below concept. please help me I have two objects Install and Condition both have three fields like soft, Medium, Hard. Now I have to compare ...
0
votes
1answer
32 views

What fires first - Case Assignment rules or Omni-channel Queue Based Routing Salesforce?

I have enabled Omni-channel and I also have Assignment rules written on Case Object. If in case we have both of them then in what order Cases would be assigned to agent? Will the cases be assigned ...
0
votes
1answer
39 views

LWC refresh data each time a new record is inserted

I have a custom lwc that has a wire call that retrieves a list of records and some required information to be displayed: @AuraEnabled(Cacheable=true) public static InterPlanetaryCasesController....