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
3
votes
1answer
2k views

passing values from VF page to component controller..?

VF Page component class Not getting value of soID.query works if i pass hard coded ID.Please someone tell me where i am wrong..**The constructor gets called first, before any variables are set. I ...
-5
votes
1answer
5k views

Error: Compile Error: Non-void method might not return a value or might have statement after a return statement [closed]

I am trying to upload a data file to salesforce on my custom object. This is similar to gmail upload. Here i have attached the code regarding this but i am getting error. I am getting this error. ...
11
votes
2answers
5k views

Catching Limit Exception: “Attempted to schedule too many concurrent batch jobs”

I've got a Visualforce page that allows the user to fire a batch job manually, using this action method: public void FireBatch() { try { Database.ExecuteBatch(new AutobotBatch()); ...
2
votes
4answers
671 views

Ensuring a all controllers invoke a method

I want to apply this fix to an IE 10 problem. The thing is you could argue this fix should be applied to all controllers. I was thinking of having a base controller putting it in that and then all ...
3
votes
2answers
2k views

System.JSONException with object-specific recent items

I'm trying to display recent items for custom objects in a visualforce page, however deserializing the object-specific recent items json results in a System.JSONException. Apex: public class ...
21
votes
1answer
3k views

Difference between returning null and ApexPages.currentPage()

How is returning null different from returning ApexPages.currentPage() as a result of a controller action?
6
votes
2answers
153 views

Wrong key type in Map not discovered during compile-time. Is Apex really type-safe?

This bug makes me shiver a bit ;) I expected Apex to be a type-safe language, that would warn me during compile-time when I do this: // Create a map with keys of type STRING Map<String, String> ...
9
votes
1answer
1k views

Is a TDD approach feasable on Force.com?

I recently tried to do TDD (test driven development) on Force.com and hit a limit that seems to contradict my understanding of how Salesforce.com wants us as developers to work. What I just did was ...
4
votes
1answer
1k views

PageLayouts and Fieldsets in APEX

We've repeatedly tried to figure out ways to display a Pagelayout and/or FieldSet settings in our custom VF pages without having to rely on the standard controller. For example to display a fieldset ...
2
votes
2answers
2k views

Apex Unit Tests - Approach!

Hello Folks, I think all of my questions cover the approach more than the technical detail or aspect. Here is another one, this one relates to force.com unit tests!** I know there have been ...
3
votes
1answer
975 views

Localization for guest users

I want to make site localization for guests. How can I do it? I am wondering how to set guest's language for all pages.
0
votes
1answer
501 views

Inserting Account and custom object record at the same time?

Hi i need to create a record in both Account and custom object"customlead" at the same. I tried this DataLoader but at a time we can select only one object. I need to select both how this could de ...
10
votes
3answers
8k views

How to atomically increment a custom field?

We are creating custom IDs for Accounts by incrementing an integer field in a custom class. The issue is that if two or more new Accounts are created in close sequence/simultaneously the following ...
4
votes
1answer
269 views

serverUrl for Apex Web Service

When using the enterprise WSDL, we use the dynamic serverUrl that's returned from the login for subsequent calls using the ent wsdl. What do others do for custom Apex services for the endpoint? I ...
1
vote
2answers
766 views

opening an internal site from salesforce via custom links

I'm trying to open a internal folder on one of our servers from Salesforce by way of clicking on the custom links in the left nav. I have it working-ish , but am getting a blank IE pop-up. the ...
2
votes
1answer
2k views

SOQL Query in Batch Apex start() times out even with multiple filter statements

In my SOQL query in my Apex Batch start() methods I query and order SELECT TextField__c FROM MasterDetailChildWith4MillionRecords__c WHERE Active__c = 'Yes' AND Revenue__c != 0 AND Lookup__c = '...
4
votes
1answer
6k views

Get values of custom fields of a custom object using DescribeResult

I have a custom object Custom__c and I am accessing its fields by using Public Custom__c custom1 {get;set;} Map<String, Schema.SObjectField> map = Schema.SObjectType.Custom1__c.fields.getMap();...
13
votes
3answers
11k views

need to process an excel file with apex

I have a need to process an excel file with apex. Once a user uploads an excel. Once they click the upload button it should store probably in contentversion (libraries) or documents and once it is ...
21
votes
2answers
887 views

@Future at risk for race conditions?

Question If I invoke an @future method from a trigger that is performing a calculation based on data that is being committed in the trigger am I at a risk for a race condition? Background We're ...
1
vote
0answers
27 views

Display text on hover over Custom Console Component [duplicate]

I have a Custom Console Component(displayed in console) which when clicked on opens a vf page. I want to display text "Test" whenever user points its mouse over this component. How can i do this? This ...
3
votes
2answers
106 views

How to ensure something only happens once in a request?

If I have a page which include multiple components which means that multiple back end controllers get invoked on page load. How do I ensure that a piece of business functionality only happens once? ...
3
votes
1answer
2k views

Too many SOQL queries: 101 in apex class. How to count results?

List<tempcon1> listoftemp; CheckContactController chk = new CheckContactController(); public List<tempcon1> getconValues() { listoftemp = new List<tempcon1>(); for (...
4
votes
2answers
10k views

Call apex method and JavaScript from html button

I have a custom search page for use in Customer Portal. VF Page: <form name="frmSearch"> <input type="text" name="keyword" id="keyword" value="{!portalSearchModel.searchTerm}" ...
9
votes
3answers
14k views

Make Validation Rule bypass if TRIGGER is run?

Is there a way to make a Validation Rule BYPASS via it's logic when a Trigger is doing it's job? I've already tried various methods including setting a hidden field on the object in the Trigger (can'...
1
vote
2answers
289 views

Opportunity Dependent Fields

I have 2 controlling fields new_field and stage, and both have thier own dependant fields. When the user clicks on one of those dependancies, they want both sets of dependant fields in a single ...
6
votes
1answer
3k views

userinfo.getuseremail() returns noreply@salesforce.com in salesforce

I have created a package in salesforce that will make an http callout request with user's email id to get data for that email and add the data to some custom object. But when I tried using UserInfo....
6
votes
2answers
1k views

Why are the results returned using a subquery different than when querying Tasks directly?

I am running the code below in a Task trigger. The subquery on Account returns 0 rows, but the direct Task query returns 1 row; there should be 1 row. Can someone explain why this could be happening....
1
vote
1answer
664 views

Question on Salesforce rollbacks on dml operation

I encountered a weird issue which i wanted to get feedback from you guys. Currently we have 2 sandboxes where we are doing development currently. We are experiencing an odd behavior where none of the ...
2
votes
1answer
3k views

Replace text in Rich text area field with trigger

We're using the "Solutions" standard object as our knowledge base, with "Solution details" standard field is a Rich Text Area field (32000 characters). The field structure looks like this: Purpose (...
3
votes
1answer
3k views

Using RegEx Pattern Match to create DateTime fields in trigger

How do I write code with the correct syntax to run a pattern grouping match within a string, then replace the pattern groups found in the result so that they follow a desired pattern? I've never done ...
6
votes
1answer
6k views

Issues with Database.upsert statement

I am using a Database.upsert statement to upsert a custom object record in apex. In my method, i do an upsert and i am printing the id and the errors. I am getting an id on the result and also the ...
1
vote
2answers
14k views

Error: Compile Error: Illegal assignment from String to SOBJECT:Account

I have created a custom field in custom object, in that i am getting the value and when clicked custom button "convert" which is create a new contact. But when converting i am getting this error. ...
3
votes
0answers
3k views

XLS Read and Automatic CSV conversion

We have a requirement to read contents (rows) from an XLS file and upload (the file as an attachment) the same once the read and insert into custom Objects are complete. My observation after ...
2
votes
1answer
6k views

SObject row was retrieved via SOQL without querying the requested field: CustomLead__c.CompanyName__

I have created custom convert button on custom object which is to create account, contact & opportunity.Here i have attached the Apex code and visual force page code. After I click "convert" I am ...
7
votes
1answer
6k views

Is anyone using classes in anonymous apex?

I can't find anyone writing about this, but this works when executed anonymously: public class foo { public void bar() { system.debug('\n\n#### FOO BAR ####\n\n'); } } foo f = new foo(...
4
votes
1answer
3k views

How to create related record upon saving new custom object record?

I'm making a Visualforce page where a new Customer__c record is created. Customer__c has a lookup field (recordContact__r) which refers to another custom object: Contact__c. While the main object ...
2
votes
1answer
245 views

Code Coverage - Blue versus Red

I have various ranges of code that never show as "covered" in Apex Tests. Here are two examples. Could someone give me some guidance on them? How would I cover them? One: ((Just the Database....
4
votes
1answer
1k views

Cyclic Trigger Calls

I am trying to stop a cyclic situation between two triggers. Trigger B is the primary - it runs when an Opp is edited (to put some data on the ACCOUNT). Trigger A was written so that if the Account ...
2
votes
2answers
332 views

Call an Opportunity Trigger from an Account Trigger (looping through all Opps)

This seems like a "relatively simple" venture to me, but at my experience level, I'm highly challenged to get it done. I've touched on a variation of it before. I have a lengthy Trigger (appx 500 ...
0
votes
1answer
5k views

Test Code:Error: Compile Error: Invalid type: CustomLead_c at line 9 column 14

I am receiving "Error: Compile Error:Invalid typr; CustomLead_c at line 9 column 14". Can any pls tell me how to fix this error. *Code:* public class LeadConversion { public PageReference ...
4
votes
1answer
2k views

Number format string being displayed on Visualforce page

Our application Ring My Bell displays a message using a public double property in the controller which is displayed in a message using <apex:outputText>: <apex:outputText value="{!person} ...
2
votes
1answer
2k views

Best way to implement a singleton class in Apex

I am trying to create a singleton class for one of my apex classes and i am running into challenges. I created some static variables to control the instances but still i am running into multiple ...
3
votes
1answer
5k views

VF Pages as Tabs with in a Main VF Page (Including Multiple VF Pages)

I am looking at a robust & scalable approach to include multiple (~10) VF Pages as Tabs into the Main VF Page. Each of these will have its own controllers (heterogeneous controllers overall). What ...
-1
votes
2answers
2k views

Value of variable set after the constructor completes its execution [duplicate]

Here is the situation: I am passing a value from my component to its controller <apex:component controller="MyController"> <apex:attribute name="someObj" assignTo="{!receivedObject}" ...
1
vote
3answers
2k views

How can I create a parent and several children with a button?

Here is the code as it stands right now : public class MyControllerOppAndCBC { public void CreateOpportunityWithChildren(Id accountId) { // Query the countries related to this account List&...
1
vote
3answers
10k views

Want to display the apex page link on VF using object id

I am displaying a link on my VF page as follows: <apex:pageBlockTable value="{!rightObjectList}" var="rightObject"> <apex:column headerValue="{!selectedObjectType}"> &...
2
votes
1answer
485 views

Test methods for the Soql in the extension class

I am stuck with writing the test methods for the following class. I did start with the test methods but need help to get the records using the soql. Any help in finishing the test method is greatly ...
0
votes
1answer
2k views

Custom Controller Case Attachment

I'm new to SF and trying to write a custom case controller that adds an attachment to a case. I've simplified my apex code below. I'm guessing I need to do a.OwnerId = UserInfo.getUserId(); to get ...
4
votes
1answer
2k views

URL hacking for visualforce pages?

I'm stuck on one part of my project. The requirements are: On the tasks related list on the contact page layout,create a list btn (not sure if you can do that on tasks) which creates a new task ...
2
votes
1answer
173 views

Where is the API documentation for Apex InboundEmail?

I want to know all the API's in Messaging.InboundEnvelope and Messaging.InboundEmail I google and all I get is tutorials. I want the API's. I want to see if I can get the sent date of the email.

1
636 637
638
639 640
649