Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
17 views

How to implement button on a Contact page that calls an Apex code providing that contact's Id (Lightning) [on hold]

I would like to create a button on top next to 'new case', 'new note' etc And by clicking it sends the contact's id of the current page to a function in an apex class. So far, all the solutions I ...
2
votes
1answer
21 views

Showing error using SLDS Has Error on Apex:Inputfield with Aria-describedby

I am using the SLDS in visualforce page and trying to display error next to the component by following this. But aria-describedby does not work with <Apex:inputfield> and throws error. Here's ...
0
votes
0answers
19 views

AccountTeam Member is not getting Read/Write access on Account?(Updated)

I had posted the similar question earlier: AccountTeam Member is not getting Read/Write access on Account? Below is same code: private void UpdateAccountTeam(Map<Id, SObject> newItems, Map<...
-4
votes
0answers
27 views

I wnat to upload CSV File in custom object [on hold]

I want upload a csv file but i got error from catch block. Please find error and tell me where i am wrong in the code. Apex Code - Class Name - RentLimitProcess :- public class RentLimitProcess { ...
0
votes
2answers
32 views

How to test this return value in catch exception

I'm new to test classes, can anyone give me a help on this? Here's the class: global class CallTimerController { @AuraEnabled global static Integer getMaxCallDuration(){ Id pId = ...
0
votes
1answer
19 views

rendered issue with actionsupport

I'm trying to rendered a commandLink base on a variable inside the controller. When I use the rendred like below, its everytime get "false" value, and I cant see it (rendered=false) My variable's ...
3
votes
0answers
23 views

How can you create a Location Object for your TestDataFactory?

This is what I have done: public static List<Schema.Location> createLocations(Integer numLoc) { List<Schema.Location> lList = new List<Schema.Location>(); for (...
0
votes
1answer
28 views

Dynamic initialization of custom visualforce components [duplicate]

Visualforce has initialization of visualforce components in apex. For example MyCustomComponent component: ApexPages.Component customComponent = new Component.c.MyCustomComponent(); Is that possible ...
-2
votes
0answers
28 views

Apex Json to xml [on hold]

I have a requirement in which I have to convert a JSON to XML and then pass the XML into the request body for a callout purpose. Help would be appreciated. String Json='{"Payload_type_info":["Payload"...
2
votes
0answers
21 views

Site.createPortalUser() takes approx 20-25 seconds for first user registration of the day? Why?

We have a Lightning Community and enabled Self Registration. The issue is weird. It takes approx 20-25 seconds for the very first User registration of the day and all user registrations onwards take ...
0
votes
1answer
32 views

The value stored in a variable of static method has to be use in the another static method

@AuraEnabled public static SysConct_Provider_detail__c getRecord() { //string detail1 ; SysConct_Provider_detail__c detail=new SysConct_Provider_detail__c(); detail.Name=''; detail....
-3
votes
2answers
37 views

Getting Batchable size is too big error

Here my heap size is exceeded. Heap size is 20182515 enforced is 6000000 global class CloneRAEDBatch implements Database.Batchable<sObject>{ Public List<...
0
votes
1answer
25 views

Test class for a scheduled batch is not firing the batch

I have tried the class in a sandbox and works fine (i.e. it updates all of the accounts based on the attached event records). The test class refuses to fire the batch class and I get 0% coverage. ...
2
votes
1answer
34 views

How to pass in a list of Strings to an Apex Action in new Flow Builder?

I have a simple screen flow, which takes in a case Cancel Reason, and if that reason is Other, will get allow a user to specify the other reason via text entry. We have an Apex server method called ...
-1
votes
1answer
58 views

Assigning a Set<String> to a string value

I tried separating the trigger and class, but now I am unable to populate the account field, ProductsOwned__C with the set of string elements, mapTemp. I am looking to make edits on the asset(s), take ...
1
vote
1answer
22 views

How to control the page size of the PDF generated from Visualforce page

Background I am generating a PDF using this visualforce page: <apex:page controller="ExampleController" renderAs="pdf" applyBodyTag="false"> <head> <style> ...
0
votes
0answers
16 views

Help writing a test class for apex class I want to deploy to prod [duplicate]

Public Class controller_SoqlQuery { public List<AggregateResult> medOppsCount{get;set;} public List<AggregateResult> nonMedOppsCount{get;set;} public List<AggregateResult&...
1
vote
1answer
26 views

Code Coverage during sfdx force:mdapi:deploy

I am trying to do a sfdx force:mdapi:deploy to my production org. I am just migrating one class file, however when I do that I keep getting code coverage failures on custom classes that are already in ...
6
votes
1answer
158 views

Should I use Javascript Classes or Apex Classes in Lightning Web Components? [on hold]

I am working on designing a timesheet Lightning Web Component for my company. Internally, we use a sObject that tracks individual sessions, which then gets rolled up one way to generate payroll, and ...
0
votes
1answer
48 views

Authentication Token with apex

I want generate a token, give this token to third-party application, and this app can authentificate into salesforce and call the web service. I want to create an authentication token, call a third ...
1
vote
1answer
33 views

Deploy from Sandbox to Production Org SFDX

I created an SFDX project with manifest in VSCODE, authorized my sandbox org and retrieved source from manifest on the default package.xml. At this point I had the base setup with classes, triggers, ...
0
votes
0answers
26 views

best practice to find the duplicate contact using apex trigger (not using duplicate rules)

I am using the below handler class in contact trigger to find the duplicate contacts, it checks only the lastName now if I want to check more than 2 or 3 filed then the only option I have is to create ...
0
votes
0answers
24 views

Salesforce Integration with SendGrid [on hold]

I am curious about how to integrate Salesforce with SendGrid to send Mass emails from the personal Email IDs of our Users. There is no proper documentation available in the internet and Zapier didn't ...
0
votes
0answers
24 views

Any alternatives to using Iframe or methods to get my current one functioning?

This is the Visualforce page that I have being displayed. <apex:page lightningStylesheets="false" showHeader="false" standardController="account"> <apex:form > <apex:detail id="...
1
vote
2answers
80 views

Using String Object or Field Names instead of literals. Using object prefixes

Is there any benefit of getting sobject type using Schema.getGlobalDescribe().get('Lead'); instead of Lead.sObjectType; Also what is the benefit of using 3 char prefixes of known IDs like Id ...
0
votes
2answers
37 views

make other record checkbox inactive when a recod is having active on insert/update

trigger CM_season_Indicator on CM_Season__c (before insert, before update) { List<CM_Season__c> SeasonObjList = new List<CM_Season__c>(); Set<Id> SeasonObjIds = new Set<Id>();...
0
votes
1answer
68 views

SOSL No Result in Apex (Not Test Mode)

I want to query matching Accounts based NRIC Passport No AND Service Agent looking up to custom object Agent__c with a set of Ids (for bulkification) and i'm using: FIND '999999' IN ALL FIELDS ...
0
votes
0answers
21 views

Unable to find soap 1.1 address

When attempting to generate Apex from a 3rd party WSDL, I'm getting below error. I noticed this has soap12:binding, I tried to change this to soap11. I still get the error message, and fails to ...
1
vote
0answers
25 views

Im not able to see “Authorize an Org” in my command palette

I have installed the Cli and Salesforce Extension pack. Why can I not see "Authorize an org" in my command pallet?
10
votes
2answers
242 views

How do you clear the ApexPages.getMessages() collection in a test?

The longtime frustration of not being able to clear the messages in tests is marked as a delivered idea in Summer '18 here Add support for clearing PageMessages via Apex. A failing of that forum is ...
0
votes
1answer
29 views

SLDS Spinner with backdrop on VF Page on Button click [duplicate]

I am trying to add a spinner with a backdrop as the loading screen but the spinner is not working when the action function is invoking. Action function is able to call the apex method but not invoking ...
3
votes
0answers
34 views

Get available record types for any user (not just current one) in apex code

We need to fetch in apex code list of available record types for a user provided by its id. We've already figured out how to do the same for current user (e.g. using DescribeSObjectResult....
0
votes
1answer
22 views

How to parse JSON in apex from lightning component

Following is the JSON structure. I want to deserialize this data structure in APEX to Update the Records, sobject is dynamic not every time 'Contact', I am confused how deserialize this data ...
0
votes
0answers
12 views

is it possible to use add attachment in New Task(Quick Action) Component in Lightning?

I have created a New Task(Quick Action) Functionality in lightning. if I click on New task Button, Standard Task creation page is popping up but attachment related List is not coming in lightning ...
1
vote
0answers
14 views

List View Column using Metadata Api

I want to get List View Columns using Metadata available for ListViews. I have the Id and FullName of List Views but I want to get Column and Filter values using Id or Fullname. I am currently using ...
0
votes
1answer
20 views

Using autonumber field type as externalId to make an upsert & store values in a Map from soql by external id

I know that those questions asked a few times here - but I saw that it little old (Greater than 3 years) and\or it doesn't have the "best answer" so I hope something changed about it. 1) Is there a ...
1
vote
1answer
17 views

Cannot set Apex Image in Visualforce while generating PDF

I have been struggling with this issue from last few days and cannot figure this out. Im trying to dynamically set Document Id in my Visualforce PDF controller but cannot get this to work. If I set ...
1
vote
3answers
65 views

Contact trigger to limit an account to not have more than 2 contacts

Yesterday I got rejected from a job interview because the interviewer asked me to write a trigger to limit the number of contacts per account and I wrote exactly the below but he said this won't work ...
1
vote
1answer
17 views

APEX: URL not valid when queried

I'm getting the url from a custom setting, but for some reason I cannot understand, the url is not read properly. I've a sample code to demonstrate the issue. When is use the 'expected' variable in ...
0
votes
1answer
15 views

SOSL Multiple Search Words

Trying to search multiple terms in SOSL in APEX. I tried this singular, of course works: [FIND 'searchOne' IN ALL FIELDS RETURNING ACCOUNT] But these don't work: [FIND 'searchOne' OR 'searchTwo' ......
-1
votes
0answers
14 views

Sending Email with Attachment Assosiate Email id [on hold]

public class CER_Reimbursement_SendemailController { public String caseId {get;set;} public list<CER_Expense_Reimbursement__c> CER_Expense_Reimbursement {get;set;} Public ...
0
votes
0answers
25 views

Delete sharing of record with “All Internal Users” for Survey in Apex

Whenever I create a Survey record, it is automatically shared with "All Internal Users". This is not letting me share the records according to Sharing settings. Instead of manually deleting that row, ...
0
votes
1answer
33 views

can we used soql query in triggers

I just want to ask you all of you. can we use soql query in triggers? when I was searching in google and found that in one article "SOSL is not used in Triggers". while soql is used in triggers.
0
votes
1answer
15 views

Send email add the attachement and all the records

Error System.QueryException: List has no rows for assignment to SObject Error is in expression '{!sendEmailFunction}' in page sendemailcontroller: Class.SendemailController....
0
votes
1answer
37 views

testing upsert campaign members gives error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

Testing my apex controller in my dev org runs fine. However, testing the same file in another dev org gives error INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] Here is the controller ...
0
votes
1answer
24 views

No response from server when calling apex controller?

I have a lightning component which calls the client side controller, which then calls the server side controller. The server side controller is linked to a method i have in one of my classes. ...
1
vote
1answer
28 views

How is JSONParser object structured / stored? [on hold]

I am exploring the JSONParser methods and trying to understand how its objects are structured and stored in Salesforce database. Here is my JSON string - String input = '{"name":"paulo","age":42, "car"...
-1
votes
1answer
25 views

Call method from apex class in lighting component [closed]

I have a lighting component and a controller. What is the easiest way to make a call to a method i have in one of my apex classes and then using the return value to update the current record with that ...
0
votes
0answers
16 views

How to store and use named credentials with OAuth

I have read this Where to Store Token Auth? and as far as I understand this, the best way for an OAuth based auth. is to use the named credentials. But I do not get the point how this work. In my ...
5
votes
0answers
37 views

Issue with receiving HTTP with Content-Type:application/x-www-form-urlencoded

I've faced a strange issue during my development related to the API. My goal was to create a web service that will receive POST requests from different sources. First service: It passes all the ...