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

Secure Guest Users' Org-Wide Defaults and Sharing Model update

We are using force dot com site and on the first-page customer register them as a lead and there is no authentication anyone having that link and create a lead. If salesforce it says created by guest ...
-2
votes
0answers
24 views

How to get elements from a list?

This must be a very basic question, but I am not able to figure it out. I have the following list: ([Email=email,FirstName=fname,LastName=lname,Address=address,Zip=zip,City=city], [Email=email,...
1
vote
0answers
11 views

Attachment as PDF is blank

I'm trying to save an attachment as PDF inside a record. The process happens after insert trigger - when I send the data to a function to generate a pdf as an attachment and saving it in the record. ...
-1
votes
0answers
22 views

Write a trigger that will create a report for any specific object [closed]

Requirement - Write a trigger that will create a report for any specific object It should remove all duplicate rows from each record and only keep the latest ones. Can anyone share the code? Code for ...
-1
votes
2answers
39 views

Empty request body when when using curl

I have a rest service in salesforce which it has to receive different requests. When I test the service sending requests, if I use a REST Client I am able to get the requestbody properly but if I use ...
0
votes
1answer
22 views

This error occurred when the flow tried to update records: CIRCULAR_DEPENDENCY: This case is parented by a case that is also its child [closed]

I am getting the error while updating the case parent ID with the same case ID. Thank you
0
votes
1answer
16 views

Can we able to get source of 'button click event' in lightning experience(Standard Lightning Page) in apex class called by trigger?

Example: We have a custom list view action button in lightning experience and I want to check some conditions on button click and before it updates the record. I don't find any other way to check this,...
0
votes
1answer
19 views

Convert two separate fields Date and time fields to milliseconds

I have two separate fields Date and Time fields. I would like to convert these fields into seconds format. I am using this seonds format to make google API call. https://maps.googleapis.com/maps/...
1
vote
2answers
23 views

Apex Trigger Order of Execution Transaction

I am a bit confused lately regarding the order of execution of multiple updates: Consider the following scenario: I have Three Records: A and B and C A fires an after update trigger that updates ...
-3
votes
2answers
36 views

Error encountered during deployment in Production

I am working on a requirement where I need to trigger email with all attachments on a ticket when owner gets changed. The below mentioned code works as expected in Sandbox and I get 87% code coverage ...
0
votes
0answers
19 views

Generate a flat file using Apex

I would like to generate a text file with a list of products containing the standard information like Product Code, Product Name etc. Initially my idea was to create a report and then export it as a ....
3
votes
2answers
1k views

For loop only loops 5 times

I have a vf page that creates 10 dummy Attachments so it can display on the page. When I go to save the attachments I"m looping through the list and removing the bad ones. The problem is it's only ...
0
votes
2answers
21 views

Want to write trigger on object to update the picklist field

Class : MonsterPositionClass Field : Experience__c Field : Position__c (picklist )> ( values:'Jr Engineer', 'Team Lead') Condition : if(Experience__c >= 7 ) then Team Lead should be shown my ...
-3
votes
0answers
25 views

Can we create Report with the help of apex trigger? [closed]

Can we create Report with the help of apex trigger?
0
votes
0answers
10 views

APEX Replay Debugger truncates String variables

APEX Replay Debugger truncates String variables and displays how many "more" characters would have been there in parentheses. How can I get the full String? None of the options of the Right Click menu ...
0
votes
0answers
22 views

Task Creation when case is created [duplicate]

I am getting below error. Error: Invalid Data. Review all error messages below to correct your data. Apex trigger CaseTaskCreationTrigger caused an unexpected exception, contact your ...
1
vote
1answer
19 views

Having trouble rerendering data on VF page

I am having issues trying to rerender data on my VF page. My VF page has a place to enter a date. It should then use that date in the controller SOQL to filter records by. Then it should refresh the ...
1
vote
0answers
36 views

Schema.getGlobalDescribe not showing all standard object even from System Admin Profile

I am trying to run very simple code in a static method under classs. Method: public class TestUtil { public static void testMethod1() { for(String str : Schema.getGlobalDescribe().keyset()...
0
votes
0answers
27 views

lightning component navigate button is not working

I created a Lightning component and a button "create New Field" is not at all working in the component. Can anyone guide me on this issue if possible please. my component: <div class="slds-grid"&...
1
vote
0answers
18 views

CSV attachment, replacing \n from cell values

I am trying to create a csv attachment through apex, I am getting the csv with the values. But some values for eg. 'Hi I am xyz.\n This is an example code.' are getting split to next cell because of ...
4
votes
2answers
66 views

How to adding dynamic rows/fields to wrapper class?

I have written the following WrapperClass, consisting different object records/rows/fields as members. How can I dynamically update this wrapper class object. In below code i have used only two fields ...
0
votes
0answers
22 views

Test Class Passing but Code Coverage is 0% [duplicate]

I am trying to create some records in the Account object which needs three fields to be populated: Name, Phone and E-mail. I am trying to achieve it using custom controller. I have created a VF Page ...
0
votes
1answer
33 views

How do i get Archived files list on specific record?

One of my requirement is to list out all archived files on specific record so i have created one lightning component and i did following SOQL to get all archived files on specific record but it's not ...
0
votes
0answers
19 views

How to get dynamically dashboard image [closed]

I need to get dashboard component images as URL to create pdf with visualforce page. How can I get them?
0
votes
0answers
17 views

Can not use action tag in a vf page

There was something wrong with my page when I add an action tag to it. Don't know what went wrong. By the way I'm using this page in community site(CloudCraze). (There is nothing in the page yet)The ...
0
votes
1answer
24 views

why user not send email from site in salesforce?

In salesforce when i send email from visualforce page email sent but on site email not sending. List<String> toAddresses = new List<String>(); toaddresses.add('sumit@...
0
votes
2answers
37 views

Trigger for creating Opportunities from custom object

I am creating some automation for a custom object "Handover". When the custom stage field is set to "Accepted", a new Opportunity should automatically be created and the Opportunity lookup field on ...
0
votes
1answer
32 views

How to use value from a SOQL Query within a For Loop?

I have an after trigger that runs when a new opportunity is created. My end goal is to select the Salesforce Record ID value from another type of Opportunity and use that value to update a custom ...
0
votes
1answer
20 views

Apex format function returning weird dates

I am attaching a screenshot which shows a code sample and it's output also. When I normally debug the created date it shows me correct output and then when I try to format it using format function it ...
1
vote
1answer
32 views

Object Permissions from permissions sets don't work as expected

What does the " -- " in the type of permission object? I need to set this to readOnly
0
votes
1answer
31 views

The issue in DateTime Field while saving from lightning component

I'm facing the issue in the Datetiem field type in the lightning component. I'm using for input and call apex method to save the fields for one of my events. Requirement: Save the 2 DateTime field ...
3
votes
0answers
21 views

Are individual object describe calls expensive enough to justify static cache? [duplicate]

Supposing we have a method that executes logic dynamically depending on the SObject type like the following one: public class TestDescriber { public static void callMeManyTimes(SObject record) { ...
-1
votes
0answers
35 views

Need alert on selecting picklist value [closed]

I would like to create an alert selecting picklist value and the alert should display the value of picklist which I have selected. I tried the below code but no luck. <apex:page standardController=...
0
votes
0answers
13 views

Input values not passing to controller through wrapper class in VF page

On saving the table the input text is not committed to database. The initialized value of wrapper class are only shown there. Why is any input value not getting passed to controller? public with ...
0
votes
0answers
10 views

select all option for particular list vf page [closed]

I have two lists on my VF page I gave selection all options for both lists separately. Now if I am selecting 1st list select all option it also selecting all 2nd list but I need select all option ...
0
votes
1answer
65 views
+50

Modal Pop up on standard Lightning record detail page

I have a requirement that when a standard account record is opened, a pop up should be displayed with few fields of account like phone, name, type with ok button. When ok button is clicked, the pop up ...
1
vote
1answer
31 views

Convert Past DateTime to {X} {Duration} Ago in APEX?

Is there any standard way to convert past Datetime to {X} {Duration} ago (string) in Apex ? For example : If current DateTime - 12-Feb 2020 14:30 if Past DateTime is 12 Feb 2020 15:02 Than it ...
3
votes
1answer
74 views

how to call NodeJS from apex using Evergreen function

Salesforce has recently announced the Evergreen serverless functions. Information about the Evergreen can be found: https://developer.salesforce.com/blogs/2019/11/introducing-salesforce-evergreen....
0
votes
0answers
17 views

Access Parent inner class using child class name

I was working integration part, so i need to create a few DTO sample to convert JSON to Object and Object to Json. In my case most part of the Json used remains same for different request and ...
0
votes
0answers
50 views

Unable to display custom object records in lightning app page

I am new to salesforce development and trying to learn salesforce lightning by developing a property project. I had created lightning app page but not able to display custom object records(Property ...
0
votes
0answers
19 views

I want to navigate to create new list view filter on click of a new button in lwc

I want to navigate to create new list view filter on click of a new button in lwc Below is the code i am using to navigate handleNewListView(){ this[NavigationMixin.Navigate]({ ...
0
votes
0answers
24 views

Regex to replace visualforce line only if not commented

I am trying to determine if the markup of a visualforce page contains a line of code and only if it is not commented out then replace it. I was hoping to do a simple string.replace with the regex ...
0
votes
0answers
19 views

Call Custom Controller Extension Method in Aura Component Controller

I have a visualforce page that uses Javascript to execute a lightning component which fires off a flow (as seen below): function selectHandler() { var curUser = '{!curUser}'; console.log(...
0
votes
0answers
10 views

Passing a value from a dynamically queried field into a wrapper class

I'm working on a dynamic lightning component that shows questions and help text. The component shows a combination of two objects, built through a wrapper class. There are 400 fields on the one ...
0
votes
0answers
27 views

Update checkbox on the father object depending on the child values - with a trigger

I need to update the 'Is Cloud Customer' check box in the account object when at least one of the Child's as the Installation type field containing the word 'Cloud'. If none of the Child as 'Cloud' ...
1
vote
1answer
49 views

pass Map as parametre from lwc to apex

I try to pass a map from my lwc to my Apex controller after when i click in button every time I get null Attempt to de-reference a null object Do you have suggestions ? where i was wrong if I want ...
0
votes
0answers
27 views

Converting a List to a Boolean

I have a query: public static List<ID> returnUserPermIds(){ List<PermissionSetAssignment> permissionSetAssignments = [SELECT PermissionSetId from PermissionSetAssignment where ...
0
votes
0answers
22 views

Setting up Named Credential for External Rest API with OAuth2.0

I am trying to understand how to set up the Named Credentials & OAuth Provider in Salesforce for calling the External REST API. Before setting this up I tested the call to the REST API through ...
1
vote
1answer
54 views

Batch->Queueable->Callout+DML ::: Uncommited work pending issue

I am having following structure, where I am getting issue- CalloutException: Uncommited work pending. Ideally, with Queueable it should not throw the same error(since DML is happening at last in ...
-2
votes
0answers
16 views

Need to fetch the address from Opportunity to Order object in my weather server side controller [closed]

I have created a Server Side controller which fetches the data from weather api and shows the weather report. I have a Lightning Component on Order object which has a "city" textbox and a "Submit" ...

1 2 3 4 5 568