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
vote
2answers
627 views

Visualforce table display

I have created table using <table> tags. In that table Column Header values are coming dynamically from Apex class as a List<string>. While displaying it on the Visualforce page I am using ...
0
votes
1answer
23 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
25 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
14 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
1answer
2k views

System.CalloutException: Unable to tunnel through proxy. Proxy returns “HTTP/1.1 503 Service Unavailable”

I'm trying to make an HTTP Request to other System. They provided the endpoint URL which contains a Port number. https://Test.com:50001/RESTAP/BGN/PRDV/CREATE When I'm trying to make the request I ...
0
votes
1answer
773 views

Salesforce CPQ error when marking Renewal Quoted on Contract

When attempting to mark 'Renewal Quoted' on a contract within Salesforce, I'm getting an error stemming from managed Salesforce CPQ code: Error:Apex trigger SBQQ.ContractAfter caused an unexpected ...
0
votes
1answer
16 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
50 views

Sharing files when communityId is null

I'm currently trying to share files on groups where i'm an internal user. My communityId is null I'm using both of these methods: postFeedElement(communityId, feedElement) ...
1
vote
1answer
29 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
3
votes
2answers
50 views

Shortest and most efficient way to query ALL accessible fields of an object

Now that stripInaccessible() and WITH_SECURITY_ENFORCED are GA I wonder what is the most readable and efficient way to do a SELECT all_accessible_fields_for_user FROM AnyObject WHERE Id = ...
2
votes
1answer
481 views

rerender input file losing file.?

I am rendering <apex:inputfile> by adding a new row but I am losing file when I click add row button. I am able to add a new row but the path is lost. Please help! <apex:repeat value="...
0
votes
1answer
630 views

New button override does not pre-populate the master detail field with the parent object record!

I created a visualforce page to override the new button of custom object called "Employment History" which is a child object to the standard contact object. I did this in order for the record name (in ...
0
votes
2answers
35 views

Display account name on alert

How to get the name of Account as alert in visualforce page. I tried getting name of the user using below code. <apex:page standardController="Account" recordSetVar="Accounts" sidebar="False" ...
0
votes
1answer
519 views

@readOnly method in lightning

I have requirement to make a readOnly query in Lightning. I have tried @readonly annotation with @auraenabled Annotation. But it is giving me this error: too many soql rows 50001 How can I ...
1
vote
2answers
608 views

Enable corresponding command button when corresponding checkbox is selected in pageblock table

I have a requirement where if user selects an apex input checkbox then apex command button should be enabled. These two (checkbox,command button) are in columns of page block table.Below is the code ...
1
vote
1answer
28 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 ...
-1
votes
0answers
34 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=...
16
votes
2answers
1k views

How to use an Apex Email Service to store emails on a record EXACTLY as Salesforce does?

I have used the Lightning Experience UI to send an Email from a Record Homepage via Activity-Tab. This looks like this (bottom-right!): Now I want (vice versa) to store an incoming email received by ...
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) { ...
0
votes
0answers
14 views

Add Custom fields in “My Settings” page for User

I need to add a Date field in "Approver Settings" section from "My Settings" page. I created this field "Delegate Till" - and added in User layout. But this just adds field "Additional Information" ...
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
9 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
0answers
23 views

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 ...
0
votes
0answers
48 views

not able to create component using overlaylibrary component

I need to create a contract after getting confirmation from user like this: I'm using simple lds to create a contract, when the user selects okay I should be able to create a contract. I have used ...
0
votes
2answers
757 views

System.HttpResponse[Status=Unauthorized, StatusCode=401] from Apex Controller

I have the following code, that retrieves picklist values dependent on a record type: public static List<String> getPicklistValuesByRecordType(String objectType, String recordTypeId, String ...
3
votes
1answer
58 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
1answer
401 views

Apex equivalent of PHP sha1() and some more encoding methods

I got a PHP script to generate an encoded URL. I need to translate this script into Apex code to generate the same URL. However, the PHP encode functions seem to work differently from Apex. The ...
1
vote
2answers
984 views

Set SameSite for Cookie in Apex

As exaplained in https://web.dev/samesite-cookies-explained/, Chrome will enable SameSite=lax by default if SameSite is not specified. In Apex, we can set Cookie using, Cookie ck = new Cookie('...
1
vote
1answer
371 views

OpportunityTeamMember and OpportunitySplit in Test Class

I am facing an issue while writing a test class for Opportunity trigger handler class. We have enabled and Opportunity Team member and Opportunity Split process in our org. In the split process, 100% ...
0
votes
0answers
16 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
1answer
490 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
3answers
384 views

lightning:select selected value is not set

I am very new to Aura component and Salesforce, I am trying to have a drop down which allow the user to pick from the list. the values of the list come from sobject. I looked into many online examples ...
1
vote
1answer
527 views

Get ActivityId From SingleEmailMessage

When sending a SingleEmailMessage from apex to a Contact, activities are automatically created for that Contact. I also want to log an activity on records that are related to this email. I can't use a ...
0
votes
0answers
49 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
1answer
368 views

Displaying related object data dynamically on visualforce page

I need to display related object records dynamically on VF page but getting only last object records from list of sobject which I am using in ape class.Here is my code: Apex code: public class ...
0
votes
1answer
823 views

Workbench: Aggregate query does not support queryMore()

I'm using the workbenc to select records having more than one certain related record. SELECT Count(Id),Person__c FROM Work_Relationship__c group by Person__c having count(Id) > 1. But I have the ...
1
vote
1answer
497 views

How to dynamic fetch value from controller and display in vf page

I want to autopopulate continents on countries selected. In this above code i have hardcoded values. Now i have an object Geography__c and two fields Name(Countries) and GeoGroup__C(Continents). I am ...
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 ...
2
votes
1answer
631 views

Formula Expression is required on the action attributes

I am using an action function which seems to work, but I also need a javascript callback. When I specify the oncomplete attribute with a javascript invocation, I get an error: Formula Expression ...
7
votes
3answers
919 views

@testSetup method and System.CalloutException: You have uncommitted work pending

Apologies ahead of time for the lengthy post, but I'm receiving the following error when attempting to run the test method below. The error occurs when the upsertProject method is called. System....
0
votes
2answers
367 views

How to make a Salesforce file private using Apex

My requirement is to make a Salesforce file private using Apex. I tried to update the PublishStatus field (on ContentDocument), but this field is not writable. Any idea?
1
vote
1answer
257 views

Community Error When Deploying Via MetadataApi

I created a community in the target org which has the same name as the community in the source org. I retrieved and deployed the metadata from the source org to the target org using Metadata API ...
1
vote
1answer
44 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
18 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(...
5
votes
2answers
520 views

Is there any way to manipulate folder permissions from apex code?

Is there any way to manipulate folder permissions from apex code.Let’s say some folders are not visible to some user or group but based on some other conditional changes now they need access to those ...
0
votes
1answer
56 views

Querying for Perm Set

I would like to query to see if a user has a permission set. I want to return the response as Boolean value. Current Code: public static Boolean returnUserPermIds(){ List<...
1
vote
2answers
47 views

How to loop trough map and get record by field value

I have a map<Id,String> subMap this is the id of a record where the string is a name of a Future_record__c yet to be made after a callout. How do I loop through the subMap and get the ...
0
votes
0answers
9 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
21 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 2 3 4 5 567