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.

learn more… | top users | synonyms (1)

0
votes
0answers
5 views

How to access custom Rest API endpoint from a visualforce page?

I'm trying to POST to a Custom Apex Rest API endpoint using jQuery and $.ajax from a visualforce page. It's returning a 302 redirect and sending me to a different domain (I'm testing this on a ...
0
votes
1answer
14 views

How to force a url to open through IE 11 from custom button

I came cross the below issue and I hope you can suggest if there is any possible way to this. https://developer.salesforce.com/forums?id=906F0000000kBTGIA2 Please look over it and let me know if you ...
0
votes
2answers
19 views

display object data in tabular form in visual force

i have an object (id, name, isvalid(default 0)) , there is 10 record in this object i am trying to display all records (name) in visualforce page , in apex class i got all the records. but facing ...
0
votes
2answers
18 views

Use controller extension attribute in Javascript

I am trying to get the id of contacts from accounts using Javascript.But seems like something is not right in the code, which has to alert the ids one by one. Here is my visualforce and extension ...
0
votes
1answer
15 views

Visualforce Wrapper Object bound Lookup Input:Field Not Setting

I currently have a wrapper object that contains a Contact that will be bound to an input:Field in order to create a lookup for an Account. Currently the lookup field functions just fine, BUT then when ...
0
votes
1answer
28 views

Need to upload photo for a User from Apex Rest and show it on Visualforce page [on hold]

My approach was to create an Attachement with parent-Id as the User's ID for whom a picture attachement have been created. But unfortuneately, User record can't have an attachement. However, User ...
1
vote
2answers
28 views

Getting Issues while creating User

I am trying to create an User but I am getting error as follows: 18:46:26:307 FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, portal ...
1
vote
1answer
25 views

Compare two fields

I have 2 object A,B A has 2 field id, name B has 3 field id, name, ismatching(default 0) Scenario is >> if I insert value in B , it should be compare B.name to A.name , if match is true then ...
0
votes
1answer
19 views

Test class for the zenkraft process class

I have created the test class for the zenkraft process, but when I run this test class it stops the code coverage after the following line i.e batchId = ...
1
vote
1answer
31 views

Set a dynamic value/label on a command button

I have a command button within a visualforce component and I would like to allow the label on the command button to be dynamically passed through the component, for example: Component Attribute ...
1
vote
1answer
17 views

How to write a test class for scheduled apex that sends a report monthly as a .csv

Looking for some help/advice in writing a test class. The class I need to test is an apex class to schedule a report that needs to be sent to an external email address once a month as a .csv ...
2
votes
2answers
14 views

apex:inputHidden will not rerender but apex:outputpanel does?

On my page I have an apex:inputhidden with a value linking to the APEX controller. It looks like this: <apex:inputhidden value="{!conferenceId}" id="hiddenConference" /> Then I have an ...
3
votes
1answer
19 views

Can't get Custom Object ParentID for Attachment save

I'm uploading an attachment via "sforce" following the example here: Upload attachment in VisualForce without reloading the whole page However I'm having problems getting a value for ParentId. I ...
1
vote
2answers
31 views

How to pass multiple value to url parameter

I am creating a custom button on a custom object A. The custom object A has multiple accounts related to it. Custom object A has a lookup relation to Account. In the button logic I am using Button or ...
7
votes
0answers
29 views

Can variables with inline get/set not be @AuraEnabled?

I have an existing class that works with a REST API from a managed package. This class represents the payload that the REST API accepts in implementations, so it has a number of variables that use ...
1
vote
1answer
34 views

Cross-Object SOQL without Relationships?

I have 3 objects. A conversation object for conversations between the user and a lead/account/contact. A tag object to allow the user to categorize conversations. And a conversation-tag object which ...
-3
votes
0answers
17 views

how to delete the permission sets from multiple users using apex [on hold]

public class RemovePset { public List<user> u{set;get;} public Id Pid{set;get;} public set<Id> ids=new Set<Id>(); public void remove(){ u=[select id, name ...
0
votes
0answers
14 views

Ability to preview the record before `SAVE` [on hold]

How can I add the functionality that user have ability to preview the record before SAVEs? Any ideas? I'm not sure if the Salesforce provide out of the box standard functionality instead of me ...
0
votes
0answers
12 views

How to get Html template to pdf [on hold]

Blob body; try { body = pdf.getContentAsPdf(); System.debug('Body==='+ body); } catch (VisualforceException e) { body = Blob.toPdf(templateId.Id); } Messaging.EmailFileAttachment attach = new ...
4
votes
0answers
18 views

Is there any way to revoke “refresh token” for a connected app automatically as soon user changes password?

We have a requirement for revoking refresh token if a user changes password. In our use-case a business user may be logged into multiple devices with the same user id and are using Hybrid App based on ...
1
vote
0answers
15 views

Converting Lead Duplicate Error

I am converting leads through apex using the LeadConvertClass methods. But sometimes the converted lead information already exists on the system under a contact record, which gives me the following ...
0
votes
1answer
23 views

Where is p/process/Submit in salesforce

I'm trying to modify a javascript button so that is send a message to more people. I came across this line of code ...
-8
votes
0answers
34 views

how to perform insert and upsert query for custom object [on hold]

public class actionSupportController { public List<PCS_Household__c> lstQuery{get;set;} public List<PCS_Household__c> OnlstQuery{get;set;} public ...
1
vote
1answer
16 views

Method does not exist, is not static, or does not return the expected search results

Hi I'm doing the challenge for SOSL Queries and here is what I have accomplished so far. public class ContactAndLeadSearch { public static List < List < SObject >> searchList(String ...
-4
votes
2answers
39 views

Test Code For My Class

// Class Code public class SendMassMailDealsheet { public List < Dealsheet__c > dealsheetIdList {get;set;} public set < ID > dealsheetId {get;set;} public ...
0
votes
1answer
24 views

how to use map/set for getting the value by the key name

I am not familiar with the data collections and want the solution. requirement is like: I want to have object name in the where statement for query like: select id , Name from Documents__c where ...
-1
votes
0answers
22 views

according to the picklist value selected datas to be display

i am having a junction object "Petinformation"and "household" and I am having picklist values. according to the picklist value Pet_Id will be display.
1
vote
3answers
66 views

Field History Tracking Values - Querying values based on date

SELECT Id, Name,(Select OldValue, NewValue From Histories) FROM CustomObject__c I understand that I can get the sequence of the values changed for that particular field . Is it possible to get the ...
2
votes
2answers
25 views

How do I create a post to my Opportunity feed via REST API

How can I create post to an Opportunity's feed via the REST API?
0
votes
1answer
22 views

Achieving Cookie Dependent REST API session

I am working on a application where hitting a button in Salesforce user interface must redirect you to some third party web application session. Below is some sample code that I use to connect: ...
0
votes
0answers
15 views

Feed Tracking replicated as an Apex Trigger [duplicate]

Does anyone have an example of Feed Tracking as an Apex Trigger?
0
votes
0answers
23 views

How to take out an account from one list and push it to another

people. I have to change a custom option field of Account with drag and drop. So I made 3 account list(for level1, level2 and level3) bound to 3 tables in the visualforce and make it draggable and ...
1
vote
2answers
29 views

Trouble passing variable from Apex to VF Page

I'm trying to pass a simple string to a vf page, but can't seem to. What am I doing wrong? APEX public class ControllerJSGeo{ public String pId; public String testString {get;set;} ...
0
votes
0answers
26 views

Visualforce Line chart not populating

I need to plot values vs week. I don't see any errors. But just the data is not populated ? public class ChartController { // Return a list of data points for a chart public List<Data> ...
2
votes
1answer
13 views

Batch Job with Custom Iterable throwing error First error: Invalid conversion from runtime type CustomIterable to System.Iterable

I get the error First error: Invalid conversion from runtime type CustomIterable to System.Iterable when trying to use a customer iterable in a batch job. My custom iterable class: global class ...
3
votes
1answer
40 views

Overriding standard object to Visualforce page

I'm trying to override the standard page to a custom visualforce page and as you see in the screen shot I do not see the page that I have created, what I'm missing? ...
3
votes
1answer
32 views

Regex problems in Apex

I'm especially terrible with Regex, but reworked one I found online to suit my needs, but it keeps throwing the "no viable alternative at character '\'" error. This pattern works when tested in ...
1
vote
1answer
21 views

How to use Custom Links in VFP or Controller

I have created Custom Linksso that I can use either in Visualforce page or apex controller but I'm trying to figure out how to call this custom links?
1
vote
1answer
38 views

Failed apex test class preventing deployment

I am receiving the following error message when trying to deploy a couple of unrelated classes and triggers. Does anybody have advice for me on how I can pass it, or should I get in touch with our ...
4
votes
1answer
38 views

Less resource expensive way to perform this scheduled task

I need to schedule anually a batch, on January 1st every year. This batch has to process all accounts to update a checkbox field. I'm trying to decide what is less expensive for the platform, so I can ...
3
votes
1answer
34 views

How to get Date of a particular day in a week?

I have a date field called CloseDate in Opportunity Object and the Date of Opportunity set it as 05/26/2016. I want a formula field or any logic to get the Date of the Saturday of same week(In the ...
2
votes
1answer
16 views

Is there way to add ahref along with Title

Is that possible to have a href inside the apex:pageBlock title? I'm trying to do something like this but its not working: <apex:pageBlock title="Upload Link - {!'<a ...
4
votes
1answer
140 views

Possible to declare static constants in an inner class?

I want to define an outer class with two inner classes, the inner classes containing specific constants related to each of them. For example: public class Stuff{ public class Letters{ ...
0
votes
1answer
36 views

Trigger, count related records

Here is the case I am working with now: There is a Custom_Object__c linked to Case object via lookup field (Custom_Object__c is a parent). After a new case is created, Case_Count__c field should be ...
-5
votes
0answers
16 views

send the Test class for below [on hold]

public class TemplateAssignment { public static void afterInsertprg(List < Account > account) { List < CEmailTemplate__c > CEmailTemplate = new List < CEmailTemplate__c > ...
1
vote
1answer
24 views

Mock class not working with Dynamic & Unique end-point

i am fetching some remote data into my salesforce and i am using "oauth_signature" in my end-Point URL for remote web services so my API URL is unique for every API request. my all functionality is ...
1
vote
1answer
14 views

Test Class to cover AsyncApexClass

public with sharing class BatchJobsComponentController { public List<BatchJob> batchJobs; public Integer numberOfJobs {get; set;} public Set<String> selectedClassSet; ...
0
votes
1answer
19 views

Controller method doesn't rerender pageBlock

My aim is showing the pageBlock named iconGallery, when the user click on the commandLink "Show Gallery". If I put the "loadImage" method's code inside Constructor, everything goes perfect. So I ...
-5
votes
0answers
23 views

Unable to create Set Test class of custom setting? [duplicate]

My Apex Class.. public class MaxmindSettings { public String APIKey{get;set;} public String firstRating{get;set;} public String secondRating{get;set;} public String ...
0
votes
1answer
32 views

how to call visualforce page from trigger?

I need to show a popup based on condition like in Contact object if Relationship(custom field) value is 'primary' is changing his address then a popup should be visible which shows all contacts of ...