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

Only receiving Single Result when querying HashtagDefinition

I have this query List tagOptions = [SELECT Name FROM HashtagDefinition]; List<String> tagNameOptions = new List<String>(); for(HashtagDefinition htd : tagOptions){ ...
41
votes
6answers
10k views

Is it possible to test apex that relies on field history tracking?

I have some code that relies on field history tracking by querying the History for a custom object. This works fine, but it appears that the history records aren't created during the test so none of ...
5
votes
5answers
3k views

Importing UPS Street Address WSDL into Apex

Have anybody been able to successfully use the UPS Street Address Validation WSDL in Apex? I'm getting the following error message when I use the wsdl2apex: "Unsupported WSDL. Found more than one ...
7
votes
1answer
1k views

Send bulk financial force emails

I am trying to automate the sending of sales invoices generated through financial force. I would like a one click process which fetches the outstanding invoices, bulk emails them and then marks them ...
3
votes
2answers
1k views

Managed package can't access class defined in subscriber org via Type.forName

I'm in the process of making a managed package extensible via an Apex plugins pattern. Basically there is an interface defined in the managed package that the subscriber Orgs can implement and then ...
9
votes
2answers
2k views

Determine if a Type implements an interface

I've created an interface within a managed package that installers can implement (much like the example here and Making your managed package extensible with Apex Plugins). Clients can then configure ...
10
votes
2answers
2k views

Why do we provide security access to apex classes

I have a visualforce page 'TestPage' which has access to all the profiles in my organization(say A,B and C). This page has a controller 'TestController'. This controller has access only to two ...
8
votes
1answer
10k views

Creating a user with DML

I have the following Apex code: User mike = new User(); mike.Username= 'mike.white@company.com'; mike.Email = 'mike.white@company.com'; mike.Lastname = 'mike'; mike.Firstname = 'white'; mike.Alias = '...
0
votes
1answer
1k views

sendemail method not working

In a commandbutton I have an action called save and in that method in have sendemail method with condition in this way... public void save(){ // my code here if(member.name=='MyName'){ ...
51
votes
3answers
18k views

Lead Conversion Trigger Order of Execution

I've got a project where I'm looking to tweak the standard lead conversion process. Triggers and lead conversion has always been funky in past projects so I was hoping to start the design off by ...
38
votes
2answers
661 views

Similar queries: Better to query twice or process via Apex?

I'm building a Visualforce page in which I want to display two similar (almost identical) lists of the same sObject -- one for objects with an Open status and one for Closed objects. I can think of ...
7
votes
1answer
3k views

Salesforce timezone issue

Hi guys we have a problem with DST (Daylight Saving time) We show the time in a Visual Force interface according to the time zone of the logged in user. However in the Salesforce objects we are ...
-2
votes
1answer
429 views

How to get an Id of another object

I have a Soql Query where I need to get an id of another object. Here is the query list<object1__c> odj = [select field1__c from object1__c where object2__c=:dataid]; If it was in the same ...
8
votes
3answers
4k views

Getting remaining licenses of customer portal using apex

When a new portal user is created, can we check the number of used and total portal licenses?
5
votes
4answers
5k views

Create CSV file bigger than 15 MB from within Force application (no dataloader, etc.)

I need to export data to XML/Excel or CSV from Salesforce.com Checking the current limits I just see those options and limitation: Render file via Visualforce page with special Mime-Type <- LIMITS ...
22
votes
4answers
25k views

What are the possible options for UserType?

The Salesforce docs describe the UserInfo.getUserType() call, which returns the same options as user.UserType. But I can't figure out where to find a list of the possible return values. Please ...
2
votes
2answers
2k views

Basic Example of a Lookup?

I'm am having a ridiculous time finding basic Trigger examples (background: no official training, have books, have experience elsewhere, figuring this out on my own). I am trying to write an insanely ...
3
votes
2answers
704 views

Load data into custom object from RSS

Can I load the data into a custom object using a RSS feed provided by an external vendor? Is there any kind of parser/a method that will consume the RSS and let me fetch data from external service? ...
1
vote
2answers
20k views

no viable alternative at character ' ' What does this mean?

There is a method in a class which i am trying to call from developer console. Here is the definition of the class public static void ruleEngine(String rule, Date eventdate, String area, Boolean ...
1
vote
1answer
2k views

Errors trying to send email via Apex class

I have a contact information section on a VF page. In this section, 'Email' is a field, and in another section I have a custom template. When I submit the page(via a Save button) I need to get the ...
6
votes
1answer
2k views

AJAX communication on visualforce > Internet Explorer 8/9 issues

I have a Salesforce app and the developers are struggling to get it to work with IE8/9. It works fine on chrome, firefox and safari but there appears to be an issue related to the APEX communication ...
5
votes
2answers
427 views

Help reaching 100% coverage

I have a relatively simple class to add contact roles to an Opportunity after conversion. However, I cannot reach 100% code coverage and I really can't figure it out. Here's my code: Trigger: ...
2
votes
3answers
5k views

Company Information in apex

I want company's locale info in apex code. How can I get that? Basically, I want company's default timezone and default language.
4
votes
2answers
661 views

Configure Installed Package from APEX

I have a 3rd party managed package installed. From the admin menu I can go to Installed Packages and then click Configure next to the app's name. The app has exposed several interesting settings. One ...
4
votes
2answers
2k views

Code Caching Issue?

I have a sites page, and it seems to work fine from a functional perspective. It has a custom controller that retrieves some data from a custom object and the Contact object, displays the data to the ...
1
vote
1answer
152 views

Entering into else part only

My problem is when ever I save a value for the second time it is taking the first value also....When I put system debug I observed that it is entering only into the else part....it is not entering ...
5
votes
1answer
4k views

How to update Account object when related AccountPartner is updated/inserted/deleted/undeleted?

I am working on an org with Person Accounts enabled, but I think that my problem applies to regular non-person Accounts as well. I am tasked with writing a trigger to cross-populate spouse ...
31
votes
2answers
17k views

How to access profile permissions via API

If I know the name of a certain profile, I would like to obtain CRUD permission settings for each object in the profile using Apex. I see that there is an sObject called Profile, but this only ...
7
votes
2answers
2k views

test method always fails. why isn't the soql returning any records?

I've been running a chatter tutorial and ran across something I don't understand. First off here's the link to the tutorial . The following code is straight out of the tutorial and works, except for ...
6
votes
2answers
999 views

Is there a way to disable System.assert assertions?

Is there a way to stop System.assert calls from executing throughout an org by a setting or programmatically? I did not see anything in the Apex System class docs and the docs explicitly state that ...
2
votes
1answer
1k views

Test for delete success within Trigger context

I have a trigger use case that goes as follows: 1. On a junction object that joins two records of the same sObject type. 2. Junction object records reflects one direction of relationship (parent-to-...
0
votes
1answer
515 views

Regex NullObject in Trigger if run from Dataloader else works fine

Fellow developers, I have a call to an email validation function in my before insert in my trigger, which basically puts the email blank if its not valid (according to the regex) public static ...
4
votes
2answers
2k views

SOQL inline query vs dynamic query

I just wanted to know weather to use inline query or dynamic query as my daily practice. I know in some cases we have to use dynamic query. But as routine practice which one to use. Any thoughts?
38
votes
3answers
3k views

How can I capture a system.limitexception stopping my emails being sent

In Salseforce governor limits, it states that every org is allowed to send single emails to 1000 external addresses every 24 hours. On very rare occasions, an org I work with has exceeded this limit ...
3
votes
2answers
2k views

is it possible to assign all subquery results to a list of subquery objects?

If i have a query like: SELECT id, (SELECT id FROM Detail_Object__r) FROM Master_Object__c WHERE id IN: trigger.newmap.keyset() Is it possible to assign the results to a list of type ...
6
votes
3answers
12k views

Getting the value of an inputField on the page

I have a visualforce page with quite a few apex:inputField elements on it. When the value of one of the inputfields is changed, I want to put that value into an output text area elsewhere on the page....
8
votes
7answers
6k views

How to connect Salesforce to Salesforce in Apex

Is it possible to connect Salesforce to Salesforce in Apex. I want to bring sample records from Full Copy sandbox to config sandbox and I need to do this as I refresh config sandbox. I think if we ...
6
votes
2answers
3k views

System.LimitException: Too many fields describes: 101

For the sake of my programming around this with a makeshift fix: Is this implying that I am trying to write to more than 100 fields at a time across multiple records..? Or even one record? I can't ...
13
votes
5answers
4k views

What are the best practices for managing changing picklist values in managed packages?

One of the issues that we always see when creating new releases of our managed package is that new or changed picklist values don't deploy when someone upgrades our app using a new release that we ...
1
vote
2answers
647 views

Failure in pkb_Controller when running the unit tests on SalesForce

We are attempting to deploy some code into a production SalesForce instance. But deployement fail because already installed third party packages are failing the unit test requirements. We get the ...
9
votes
2answers
3k views

SObjectException “SObject row was retrieved via SOQL without querying the requested field” not being thrown

Usually if apex code attempts to access an sObject field that wasn't retrieved via SOQL I get an exception like: System.SObjectException: SObject row was retrieved via SOQL without querying the ...
1
vote
2answers
919 views

Avoiding Duplicates in Loop (inside other loops)

I have a complicated trigger (a labor of love for over 2 years now). I've recently discovered one of the problems in it. It ends up with duplicate entries in "updateList" to apply to SF (recently ...
1
vote
1answer
2k views

VF Value Element in an List/Array

If I have multiple input fields on my page, can I assign their value to elements in a list/array?? Is this even possible and I don't understand the syntax? Example: Page <apex:page controller="...
4
votes
2answers
482 views

Determine from Apex (or API) whether Google Apps integration is enabled

Is there any way to determine from Apex (or through the API if not in Apex) whether a Salesforce org has the Google Apps integration enabled? If so, is there any way to access from Apex/API some of ...
1
vote
1answer
4k views

Time-based Trigger to update all records

If I want to "touch" (save, update) all records once a morning in an object (let's use Account as the example, though it would more likely be in a Custom object), how would someone go about that? To ...
5
votes
1answer
2k views

Can we use Dynamic Apex to Share a Record?

One of the most common use cases not supported by sharing rules is when we have a lookup field to the user object and whomever is selected in the lookup field will automatically get read/write access ...
3
votes
2answers
1k views

OpportunityLineItemschedule deletion problem?

We are using the custom product scheduling in our organization. When I am deleting the existing schedules its also updating the OpprtunityLineitem's quanity, salesprice and unitprice to '0'. Where as ...
2
votes
1answer
1k views

Send chatter files with REST

When I upload a file from the directory (and save it as an attachment) and send it with REST webservices, it works great, but when I get a file from Salesforce (from chatter for example) it doesn't ...
2
votes
1answer
590 views

How to get values of a field from another field

I'm having a field of picklist say field1 and a field NetAmount in page1....In page2 Whenever i change the value of picklist corresponding NetAmount Should display... My page and class Field1 &...
1
vote
1answer
508 views

How do we identify if an opportunity or Lead has a pending or overdue task

I need to know if an opportunity or Lead has any pending or Overdue tasks? I can search for opportunity or Lead in WhatId of task and get all the records for this ID. How do i know if a task is ...