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

“errors”:“code”:32,“message”:“Could not authenticate you.”}]} getting error in Developer console but able to call api in Postman [closed]

I was trying to upload image with status with twitter api with apex and visualforce page but i am getting error in developer console liken 10:25:20:784 USER_DEBUG [202]|DEBUG|{"errors":[{&...
0
votes
1answer
37 views

AWS SDK for SalesForce

We are attempting to use an installed package to access Amazon S3 - AWS SDK This package created an Apex Class: S3 Our Named Credential was created using the information specified in the link above, ...
0
votes
0answers
25 views

Custom “view all” button on Lightning component similar to related list view all

Created a lightning component to display list of records and would like to open the component in new window to show all the values. But when opening the component in new tab, the data is not ...
16
votes
2answers
54k views

How to pass javascript value to controller..?

I want to pass the java-script value to controller.I am using repeat on VF page. VF page <apex:repeat value="{!listAdj}" var="Adj" id="hrs"> <td><div class="requiredInput"&...
0
votes
0answers
22 views

Conga Output File Name Issue populated via Apex

I have a conga pdf generated via the conga composer. The issue is that when the file name contains Sample&Company in the invoice record in Salesforce, it clips the rest of the characters after the ...
1
vote
1answer
785 views

How can i open a pop up box with event information when event url is clicked in the Full calendar?

I used jquery full calendar and this pageload() on document.ready with list of events in calendar. Here is my Controller: <apex:page controller="NetworkCalendar" standardStylesheets="false" ...
1
vote
2answers
106 views

When Contact is created

public class AnnualRevenueValidation { public static void annualRevenue(List<Account> newAccList) { for(Account acc : newAccList){ if(acc.AnnualRevenue >=...
-2
votes
1answer
26 views

Invocable Test Class

I'm trying to write test class for one of the Invocable class that calls another class, though the test passes but i don't think it is actually testing the code. Struggling to call list in test class ...
0
votes
1answer
25 views

Retrieve a list of Accounts via REST

I am using Postman to get all account records from salesforce. The below code is working for only one record @HttpGet global static Account doGet() { RestRequest req = RestContext....
0
votes
0answers
35 views

Populate a form field from APEX [closed]

I have a custom form field in the Account object UI. Lets call it time now I have a class, that is triggered every time an update of the UI is performed eg(name change, phone number entered, address ...
0
votes
0answers
18 views

Test Apex sending mail with .getContent() [duplicate]

I'm trying to write a testMethod to cover a method that is using .getContent(). Here is a sample of code i want to cover global class ExportReport { @future(callout = true) public static void ...
0
votes
1answer
14 views

Before Update Trigger Not updating the User “Title” field

I have created a before updated trigger and I am trying to update the title of the user. After saving the record, the title does not get populated although when I debug the value it actually hold it. ...
0
votes
0answers
19 views

Value provided is invalid for action parameter 'fileContent' of type 'Blob'

So, I'm trying to pass a csv file to apex, with a lightning input type file and a button with an onclick that calls to the apex method, receiving a blob variable: @AuraEnabled public static String ...
0
votes
0answers
9 views

Test class for sdoc job? [duplicate]

trigger SendWelcomeLetter on Account (after insert) { List<SDOC__SDJob__c> jobList = new List<SDOC__SDJob__c> {}; for(Account acct : Trigger.New) { SDOC__SDJob__c job = ...
0
votes
0answers
20 views

Partner connection code for two factor authentication [closed]

Enabled the Multi-Factor Authentication Login Requirements for API Access. I need to write the code to get the partner connection. Could you help me with this
0
votes
1answer
563 views

Change Record Ownership in Visual Force Page

Hello I would like to know if there is a way to change record ownership in a Visualforce Page. Currently this is part of the code of my VFP extension private final Account acc {get;set;} public ...
0
votes
0answers
35 views

store list of up to 10000 records for lookup from apex code

for an automated pricing method in apex I would need to access a list with 10000 zip codes, with each zip code having a specific value assigned. What is the best approach to store and access? Do you ...
1
vote
1answer
1k views

Email to Case (Using thread Id)

I am working on email to case. My requirement is whenever a user is sending mail from outside to salesforce generated email address, case should be created and reply back to user with case id in ...
1
vote
2answers
10k views

Field Update on Button click Using JavaScript

My field is not getting updated for Owner Id on Case Object {!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} var caseObj = new sforce.SObject("Case"); ...
-1
votes
1answer
21 views

How to write a trigger to update account field on the basis of their contacts records [closed]

I have a custom field preferred_language__c on account and on contact having custom field preferred_language__c . If the account having 5 contacts so if contacts having same language then update that ...
5
votes
1answer
566 views

question on crontrigger and possible state values

Whenever a scheduled Apex Job is submitted, an entry is made in the CronTrigger table. What I see is, when this job is completed successfully, I see the State changed to "DELETED". Based on the SOAP ...
13
votes
1answer
165 views

Interface method can be implemented as static

Assume we have some simple interface: public interface IExecutable { void execute(); } and some class that implements the interface: public class Executor implements IExecutable { public ...
0
votes
0answers
34 views

Partner Community [closed]

I have enabled a Partner Community. I enabled Partner under Account and Contact. I can log in to Experience as User and Log in to Portal as User. What is the difference between the above 2? I can ...
0
votes
1answer
609 views

How to create a Visualforce page to edit multiple records that are of different sObject types?

I have a table that displays a list of Surveys In addition, I have a button that goes to a creates a new survey, survey Questions, survey Referral links, all of which is on a single VF page. Each ...
1
vote
2answers
559 views

Retrieving status from bulk job load?

Is there any way to get the status of the bulk job load using job id for each job via apex?
1
vote
1answer
33 views

How do I add a QuoteDocument as an Email Attachment

Hey team I'm attempting to auto send a Quote via Email out to a client, but having issues attaching the QuoteDocement to an email via Apex. When the code runs I get a blank PDF. Thoughts on the below ...
0
votes
0answers
36 views

Community User auto email quote PDF

I'm trying to generate and auto-send a quote to a community User when they Close Won an Opportunity. I have a Flow that calls my apex class. I've debugged while logged in as the user and the error I'm ...
-2
votes
0answers
15 views

Recommended way to filter rows on visualforce page [closed]

I'm looking to filter the rows of child records returned on a visualforce page. I've seen several ways to go about this (apex, javascript, jquery). The most straight forward, and the method I used, ...
28
votes
3answers
75k views

Iterating over a map (Apex)

I have a map written in Apex. Map<Id, Set<String>> emailDiseaseMap = new Map <Id, Set<String>> (); The map contains an ID and then a set of email addresses. I am trying to ...
1
vote
1answer
978 views

dynamic datatable

I want to create a datatable with opportunity information. I add a picture that shows how the table should look like. I have the information for the table ( below is my class code), but I don't know ...
0
votes
1answer
27 views

Salesforce Platform license user access to ContentDocument object records

Can users with the Salesforce Platform license access Files, ContentDocument/ContentDocumentLink/ContentVersion, using Apex? I created a class using without sharing to query for ContentDocument ...
1
vote
1answer
2k views

Show only 'today' and future dates in calendar picker. No dates in past

I am having a Date field myDatefield__c. I'm accessing it in VF page. So, is there any way, so that I can disable the old dates. For example: If I click on the date field, when calender pop up will ...
1
vote
1answer
54 views

How to iterate over all the queried out fields of a single record

I need to iterate over all the fields that I query for a record and check all of those that are custom field checkboxes and see if any are true. The part that I'm not sure how to do is how to iterate ...
-3
votes
1answer
63 views

“First error: Apex CPU time limit exceeded” in Batch Apex

I have a batch apex that is facing the error "First error: Apex CPU time limit exceeded". This batch is collecting account records based on some conditions and then trying to group them ...
0
votes
0answers
46 views

How to avoid hardcoding the URL in Apex class

I wrote this code looking at references and documentation. However, I want to prevent hardcoding of the URl . Also, the email that I receive goes to my company's junk mail box. What best practice can ...
0
votes
1answer
24 views

Execute Overriden method when Base Class is executed - Salesforce Apex

I have the following scenario, where i have overriden the base class method. When i am testing it, the parent class's Initial code is what gets executed. What should be done to get the overriden code ...
0
votes
1answer
36 views

Salesforce Apex Best Practice

this is my first ever question so I'm unsure how to word it whilst following any guidelines... but here it goes. I'm creating a trigger so that when a new candidate is created (custom object) it will ...
0
votes
1answer
30 views

Create API in Salesforce

In order for an API communication to be created in Salesforce, is there anything that needs to be created in addition to a ConnectedApp and a class with the annotation below?
-2
votes
1answer
39 views

HOW TO Avoid three or more nested LOOPS [duplicate]

for(String objectName : jsonMap.keySet()){ // List<map<String,String>> listObjects=jsonMap.get(objectName); List<Map <String, String>> ...
0
votes
1answer
21 views

MALFORMED_QUERY: duplicate alias: Email

Gentelmen I know you have more than free time for challenges like this I have downloaded all metadata for reports and rep types I have found one specific fields that is in there Now I need to get all ...
1
vote
2answers
1k views

how to create an incident in serviceNow from salesforce(Case)?

I'm trying to integrate salesforce and serviceNow. If I create a new case in salesforce, that should be saved as incident in serviceNow. Here I developed some code but I'm stuck at mapping the ...
0
votes
1answer
22 views

Is it possible to distinguish in a trigger if a create new record is started from a related list or from the object

I have a requirement to pre-fill some fields when a record is created from a related list. These requirements are different when created from the object itself. Is there a way that I can capture this ...
0
votes
1answer
700 views

Cannot Create Entity Subscription to Portal User

I am trying to create entity subscription for a Portal User(Isportalenabled = true) to an opportunity, but I'm ending up with the following error on insert of entity subscription. 11:40:06:128 ...
0
votes
2answers
39 views

Implementing hashCode() with more than two variables

How do I implement hashCode() for a custom class with more than 2 variables? From the docs, the example only has two values used: return (31 * x) ^ y; I'm working with user data such as first name, ...
0
votes
2answers
36 views

How can I convert existing Leads into Contact, Account, Opportunity Objects

public class LeadConvert { public void convertToAccount(){ account acc=new account(); contact con=new contact(); opportunity opp=new opportunity(); list<contact&...
0
votes
1answer
2k views

How to display picklist values based on Lookup value on VF page?

I created a custom VF page to create custom object record. I have a Account lookup on page. So whenever a user selects value from the lookup I would like to show dynamic picklist options on VF page ...
0
votes
1answer
23 views

Visualforce rendered if list is empty

I'd like to render a VF component if a list is empty, but the VF page is giving an error of "Unknown property 'CheckOpps.opportunity'. How to correct this error? I am building the list in a ...
6
votes
2answers
1k views

How to Reproduce the Concurrent Requests Limit?

I'm trying to write code that will reproduce the Concurrent Requests limit (10 requests longer than 5 seconds, described here: https://developer.salesforce.com/blogs/engineering/2013/05/force-com-...
0
votes
0answers
25 views

Error EntityInfo of EntityObject cannot be set to null

I get the following error message: EntityInfo of EntityObject cannot be set to null when my apex test gets to this code: Datacloud.FindDuplicatesResult[] results = new List<Datacloud....
1
vote
1answer
31 views

How to count the members of a queue in Flow

In a flow I have the Queue Id, I want to count the number of users in that queue in the flow. Is it possible?