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
1
vote
2answers
204 views

SQL date constants constants in memory

I am able to run a query with a where clause Opportunity.CloseDate = LAST_N_DAYS:7 However, I have a custom date attribute for custom object. When I try to set this value in memory: digest....
0
votes
1answer
3k views

How to grant Custom Object Read Write Permission to Standard User?

I have created a custom object and I need that Standard user profile to use that object. However, I can't see the read write permission on that object. How can i achieve that functionality?
1
vote
3answers
2k views

Attempt to de-reference a null object with Attachment

I am trying to add a attachment to a record. Their may or may not be attachment. So that i have created a attachment in the controller if the attachment is null but i am getting null point exception. ...
28
votes
1answer
377 views

Strange Allowed Apex Syntax

Found some crazy apex syntax and I have no clue what it does. public Account<List<String<Contact>>> whatIsWrongWithApex; Is this a defect? Should this do something? Compiler not ...
1
vote
3answers
1k views

Finding opportunities closed in last week

I am looking to get all opportunities closed in last week. I know System.today() is a neat way to get the current date but just wondering is there any other neat way to get all opportunities closed ...
1
vote
1answer
2k views

How to get the updated values after an APEX call from Javascript

I am currently calling an APEX method (in a controller) with variables from Javascript. I would like to reflect the changes made in the controller in the page. I am using an apex:actionFunction to ...
0
votes
2answers
1k views

Getting error while declaring a constant in Interface

public interface Constants{ String TEST = 'test'; } I am getting below error - Error: Compile Error: expecting a left parentheses, found '=' at line 2 column 16 Can someone explain why am ...
0
votes
1answer
4k views

How to display HeaderValue on vf Page

<apex:tab label="Opportunity" id="TabTWO" style="font-weight:bold;width:200px;"> <apex:pageblock title="Opportunities"> <apex:pageblocksection &...
2
votes
2answers
1k views

Substracting Business Hours not working properly

Hi I tried subtracting Business hours. But somehow it is not working properly. Below is the code snippet that I used. date mydate = date.parse('11/13/2012'); Datetime dt =datetime.newInstanceGMT(...
7
votes
1answer
3k views

Conditionally Render Component In Visualforce Page

I would like to conditionally render a component in a VisualForce page based on a custom field. I was hoping to do something like this: <apex:page standardController="myObject__c"> <c:...
0
votes
1answer
3k views

System.TypeException: Invalid integer: 12/06/2012

date inn = integer.valueof(trans.stdate.trim()) + integer.valueof(payment.Net__c); Getting the following error System.TypeException: Invalid integer: 12/06/2012 Here trans.stdate is of string Type.&...
2
votes
1answer
921 views

APEX getType() 'Entering Managed Package' on custom fields

I am trying to use the APEX method: .getType() field metadata like so: Schema.DescribeFieldResult campaignTypeFieldMeta = null; Map<String,Schema.SObjectField> mapFields = Campaign.sObjectType....
1
vote
1answer
570 views

Passing disbaled input fields values to apex controller

I have a JavaScript function that fills some apex:inputfields and make them disabled so the user cannot change their values. But it seems that values aren't passed to the controller after an action (...
3
votes
1answer
2k views

How to fetch namespace prefix and salesforce instance using javascript?

i am using Custom button & links in List view of Object and on click of button i am executing javascript to redirected to new page and its works fine in my DE but when i install that package in ...
0
votes
2answers
1k views

Image to next page with id passing

I want to display images from a static resource on visual force page. By clicking on the image the page need to redirect to another page with id passing on url and image should representing the ...
1
vote
1answer
759 views

When does an activity get logged in openactivities or ActivityHistory?

In Test class I am trying to create an event and see this event is getting logged in Open Activities or Activity History Account a = new Account(name ='Test Account'); insert a; Task t = ...
1
vote
2answers
949 views

Inbound Email Test Error - 'Invalid type: EmailDemoReceive'

I've successfully set up an inbound email to load a particular set of data, however when writing the test case i'm getting the invalid type error on the following line: EmailDemoReceive edr = new ...
17
votes
4answers
6k views

SOQL - query a query

We're in the process of converting an Access DB to Salesforce, a lot of our reports are built from querys of querys. For example, we want to produce a report that shows some fields from the parent ...
11
votes
2answers
2k views

How do you Apex Unit Test Object(CRUD)/Field(FLS) Permissions in an Org Portable manner?

Specifically, how might one get an org portable Apex Unit Test User that DOES NOT have READ access to Accounts? Creating a Test Permission Set that DOES NOT have READ access to ACCOUNTS and assigning ...
2
votes
2answers
2k views

Caching Expensive Results

I'm building a custom interface in Visualforce that uses dependent picklists. Since Apex doesn't expose information about dependent picklist values, I've had to resort to building that information on ...
0
votes
1answer
420 views

Why does my Apex Chatter trigger title show up as “User name to User Name”?

I created an apex trigger that posts a new feeditem to a user's feed every time the opportunity status gets changed to "Closed Won". It works fine except for the fact that the post title says "John ...
0
votes
1answer
1k views

Trigger on OpportunityTeamMember has an error

Since there is no out of the box solution to send email notifications to users when they are added/removed from an Opportunity team, I wrote a trigger. So far I have code to handle the addition. This ...
0
votes
1answer
503 views

Strange VF & custom controller behaviour

I have a VF that is used to return reults based on criteria selected by the user, the page consists on inputTexts and Checkboxes and a button that then refreshes the data. If i fill in inputTexts ...
1
vote
2answers
665 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 ...
1
vote
1answer
2k views

Opportunity Team email notification - Is Trigger the only way?

I have another situation that I need to write a trigger for and I am wondering if there is an out of the box solution I can use. Basically when a team member is added or deleted from an Opportunity ...
7
votes
1answer
2k views

Assign sharing reasons from Dynamically from APEX

Was wondering if there is way to assign the Sharing Reason aka Rowcause Dynamically. Well tried to implement using this "Schema.MyCustomObject__Share.rowCause.My_Sharing_Reason__c" but here I have to ...
7
votes
2answers
2k views

Not getting how FieldSet works in Salesforce

Please have a look at these 2 code snippets: (1) <apex:page id="pageId" standardcontroller="My_Object__c"> <apex:form id="formId"> <apex:pageblock id="pbId"> <...
2
votes
3answers
4k views

apex variables used in javascript of VF is not getting updated with latest values

i am currently using a inline VF page to perform an update on an Sobject. The inline Vf page a picklist field and a button which will update the sobject with the values entered in the picklist. Now, ...
2
votes
3answers
10k views

How to get the opportunity owner name instead of owner ID

I am posting to chatter using an apex trigger whenever the opportunity stage changes to a certain value. The problem I'm having is that I'm trying to concatenate the opportunity owner name with some ...
1
vote
1answer
901 views

Metadata API-based deploys hang in “queued status” since 30.11 (cs7 & cs8 sandbox) [closed]

Is anybody else experiencing this? Several sandboxes in our Unlimited Edition seem to be having issues with deployments today (tested from Eclipse IDE and Migration Tool). The deploys just hang in ...
4
votes
1answer
898 views

Generic Controller class?

I have a custom Visualforce extension which accesses information stored in custom settings and exposes it as variables which can be referenced from Visualforce. I'd like to be able to use this ...
1
vote
1answer
1k views

Getting Test failure for page parameters

Getting error message when I'm running the test don't know what's wrong with this code this is the error msg: System.StringException: Invalid id: recordtype.id Stack Trace: Class.LeadEventCreation....
10
votes
2answers
3k views

Comparing floating-point values

In Apex, can Decimals be compared directly. For example: dec1 > dec2 or dec1 == dec2 In other languages I sometimes run into issues with fractions such that 1/3 and 0.33 are not going to be equal. ...
4
votes
1answer
5k views

Is it possible to combine these aggregate SOQL queries?

I'm using a few aggregate SOQL queries to mimic a rollup summary on an object that I don't necessarily want in a master-detail relationship. They are part of a trigger that fires when one of the ...
1
vote
1answer
719 views

using google maps without a controller

I want to display all of my accounts and leads on a google map in a visualforce page. Problem is that I have the Sales Cloud professorial edition which allows me to write vf pages but not classes. Can ...
4
votes
2answers
157 views

Deploy from expired Project to new devloper org using eclipse

I went on the Dev 501 apex training course a while back, but at the time i forgot to transfer the org we used on the course to a new development environment. As a result my training org has now ...
2
votes
2answers
3k views

Different attachment in same VF page

Hi i have a VF page with 5 input File attachment. I want 5 different attachment on the each of them. eg: Their are 2 more fields. 1. Name, 2. Job, 3. Resume . So like this their are 5 fields. If 1st ...
1
vote
1answer
523 views

Visualforce page throws error if refreshed after a while

I have built a customer portal using Force.com sites. All of the UI is custom built using VF pages with apex controllers. I am displaying some records using pagination with the standard set controller....
7
votes
2answers
23k views

Calling a Apex controller method using JavaScript in VF page

Hi can anybody guide me how to call a method in controller from a VF page.
1
vote
2answers
392 views

Where can I find the official APEX language and system class reference?

Specifically, I want to look up what parameters the constructor of the Cookie class takes. The most official looking thing I could find was in the salesforce developers docs, but the constructor is ...
0
votes
2answers
2k views

Action Function on Outputtext

I have 5 inputtext I want to add the value of all the inputtext to a outputtext. I dont want any action to be done on the button click. I need when the value of the 1st and 2nd inputtext is entered ...
3
votes
2answers
2k views

Javascript Remoting (Return cached result without re-query)

I started writing some code using apex functions and then I thought let's try it out with Javascript remoting. Remoting method was called from my VF page and all worked fine, until I tried to use ...
-1
votes
1answer
614 views

Test Coverage For Page parameters is not covering

public with sharing class LeadEventCreation { public PageReference doSave() { insert objL; objL.recordTypeId = apexpages.currentPage().getparameters().get('id');// these lines are ...
0
votes
1answer
1k views

Identify all accounts with no activity for 60 days excluding emails send through mass email

I am trying to figure out a best way to identify accounts with no activity for last x days. Account has a field called LastactivityDate which has the date when the activity was last logged. But i ...
4
votes
3answers
9k views

Field's validation rules in a Visualforce page

Is there a way to re-use the validation rules applied to some fields in Salesforce to a Visualforce page automaticaly? I have a CustomController right now supporting the saving process of a field, ...
5
votes
1answer
11k views

How does <apex:detail> work? Can we show layout for a new record?

Can we use <apex:detail> to get the layout of standard object on a VF page. <apex:page standardcontroller ="Event"> <apex:detail subject="{!Event.Id}"/> </apex:page> I can ...
6
votes
1answer
576 views

Is there a way to share APEX code between two managed packages?

As a Salesforce ISV, we are currently facing the following situation: We have one managed package available as an application on AppExchange and we would like to propose a 'premium' version of our ...
4
votes
1answer
6k views

How can I retrieve values that was posted to a Visualforce page?

In a page controller, I can get hold of values that was passed to the page via GET (the URL query string parameters) like this: String theId = ApexPages.currentPage().getParameters().get('id'); How ...
2
votes
2answers
2k views

Help understanding code behind a Visualforce page

I am newbie to salesforce so i am getting little problem to understand the code. so anyone of you may please explain the below code :- <apex:page standardController="Account" recordSetVar="...
2
votes
2answers
3k views

Selecting the “What” field in a Task using an SOQL request

I'm looking for a way to do a SOQL request to get a Task record, but I keep ending up with this error: Error: Compile Error: No such column 'What' on entity 'Task'. If you are attempting to use a ...

1
638 639
640
641 642
645