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
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 ...
4
votes
3answers
8k 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, ...
7
votes
1answer
7k views

Convert lead through apex but should not create opportunity

I am doing a lead conversion thorugh apex. When the lead is converted it should only create account and contact and should not create opportunity. There are a few other items that i need to capture ...
0
votes
2answers
871 views

retURL is not working

I have a VF page and it is associated with standard controller. On the page, I am using apex:detail tag to bring all the details. I also want to show few related list, So I used apex:relatedlist. This ...
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
2k 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
vote
1answer
546 views

Has anyone created a VF page which accepts value for a datetime field sepereately as date and time

I am trying to create a VF page which has options to capture the startdatetime and enddatetime. These fields are datetime fields. <apex:inputField value="{!eve.StartDateTime }" id="...
0
votes
1answer
111 views

Is this a good mix: Authenticated Site - Customer Portal License - Opportunities

I have: Parent__c object which parents the opportunity object. Authenticated site for customers to login. Authentication comes via Customer Portal license. One of the pages in the site details the ...
1
vote
1answer
672 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 ...
9
votes
1answer
8k views

How do I insert a custom object?

I have a custom object called Visitor with two custom fields, Name and Identifier. I am trying to add a record with this piece of controller code: public String getResponse() { System.debug('...
0
votes
1answer
132 views

Can we create a control like Account name in the convert lead page?

Can we create a control like account name in the lead conversion page in a VF page? Its like a picklist with lookup. How does salesforce determine if there is already an account is already present? ...
9
votes
2answers
7k views

screen scrape Salesforce with REST GET call from Apex

Consider this code snippet from my answer to rao's question: String requestUrl = '/services/data/v26.0/sobjects/User/describe'; Http http = new Http(); HttpRequest req = new HttpRequest(); req....
0
votes
2answers
2k views

Embedding a page layout into a VF page

Can we have a pagelayout of an object embedded into a Vf page? I have a Vf page which has captures some information, i also want to be able to create a new event in the same page. I could have all ...
1
vote
2answers
1k views

How to write test for following apex code

How to write test for following part of apex code? I am fairly new to sfdc development. public with sharing class ddDashboard { public class phonesterDat{ String type; Integer total; Integer ...
3
votes
2answers
3k views

field mapping of custom fields for lead conversion

While doing a lead conversion using Database.LeadConvert When we do the convert does it also convert the custom fields set using the Lead Custom Field Mapping which is set on the UI? I would think it ...
0
votes
1answer
205 views

How can we attach all the activities on a lead to an account when the lead is converted?

I am trying to convert a lead using Database.LeadConvert lc = new database.LeadConvert(); lc.setLeadId(myLead.id); LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE ...
6
votes
2answers
26k views

use string array in IN clause in dynamic soql

I have an array of strings i'd like to use in the IN clause of a dynamic soql query. if i wasn't building the string at runtime i could simply use (from the SF docs): String[] ss = new String[]{'a', ...
6
votes
3answers
3k views

How can I determine whether a lead conversion was a merge to an existing contact or a new contact?

Looking around the net it appears that the best place to hook into the Lead Conversion process is in a Trigger's After Update event. I have a situation where I have a related object on a lead and ...
1
vote
1answer
1k views

Picklist Value not getting inserted in Save method

My page <apex:pageblocksectionItem > <apex:outputlabel value="Date Format"/> <Apex:selectlist value="{!dateval}" size="1" style="width:100px;"> ...
0
votes
2answers
681 views

Is there any issues in this code i am getting Visualforce Error [closed]

I'm getting an error message when I try to save records. The error message is: URL No Longer Exists You have attempted to reach a URL that no longer exists on salesforce.com. You may have ...
2
votes
2answers
2k views

how to use apex:inputField (lookup type) on public site

I want to use apex:inputField on public site. I have given read/edit permission on both object but when i on lookup, it open standard page as popup but say "Authorization Required".
1
vote
1answer
13k views

Compile Error: Illegal assignment from Decimal to Integer

itemlst.Quantity = templook[i].Quantity__c; Here Quantity is of integer type and Quantity_c is of decimal type.How can I convert Quantity_c into Integer
2
votes
2answers
4k views

How to customize the error message thrown by approval process?

I have requirement where an user should not be able to submit a master record for approval until all the related child records are approved. Submit for approval button on approval history related ...
1
vote
1answer
2k views

if else condition in commandlink value

<apex:commandLink value="ADD" onclick="return divToggle('{!oplist.lineNumber}');"/> I want to apply if else condition ,if UnitPrice is not null then View commandlink should show otherwise Add ...
1
vote
1answer
1k views

Querying for OpportunityShare Rule

I am writing a trigger that looks up to a parent (Lookup) Opportunity from a custom object, and am coming across an interesting problem. I have a sharing rule set up on the Opportunity to grant Edit ...
0
votes
3answers
1k views

Dynamic values in standard picklist

Is it possible to create dynamic values for a picklist from a standard picklist option and not in a VF page ? eg: I want to create a field Close Date as a picklist with Q1/Y1, Q2/Y1, Q3/Y1, Q4/Y1, ...
1
vote
1answer
396 views

How to Populating Similar fields

I am looking for fields to update in one object to other I mean there are similar fields in both the objects Test1 & Test2, Test2 had the look up to Test1 object so if we enter the details in ...
2
votes
1answer
199 views

Need different whatIds in mass email

My understanding is when sending mass email, you can specify the emails by specifying appropriate targetIDs. You can also set the whatIds() but does this mean that every recipient will receive the ...
15
votes
2answers
8k views

Efficient way to find error causing “Save Error: Entity is not org-accessible”

I've ran into this issue once or twice before. The problem manifests itself as this in the Force.com IDE: The way I found the issue was by commenting out large swathes of code, and then saving the ...
0
votes
1answer
2k views

getting only the last value in for loop

my Vf page is <apex:dataTable value="{!templook}" var="item" style="margin-left:60px;" cellpadding="5" cellspacing="6" > <apex:column headervalue="Payment For"> {!payfor} ...
-5
votes
3answers
2k views

Attempt to de-reference a null object [closed]

I am getting above error in following code public List<phonesterDat> getCompanyData() { List<phonesterDat> var1 = new List<phonesterDat>(); List<Account> accounts = [...
4
votes
1answer
1k views

Apex conventversion.VersionData chunk?

We are querying for contentversion data in apex and would like to take the first part of the file data and send chunk by chunk to another webserver. Is there a way to only take 10,000 bytes of the ...
4
votes
1answer
2k views

NullPointerException not occurring within try/catch

I'm writing a testMethod for a custom Exception class. As part of the testMethod I want to deliberately throw another exception to become the inner cause of my custom exception. E.g. public class ...
15
votes
2answers
6k views

How to implement hashCode cleanly?

Being able to write your own equals/hashCode for a custom class seems appealing - see Non-primitive Types in Map Keys and Sets. But with no hashCode method exposed in Apex string or decimal or any of ...
4
votes
1answer
464 views

Why does my assertion not fail when I call it after stopTest()?

I have opportunity code that calls a future method. While testing it, I have run into some odd behaviour. I cannot get my assertion to fail if it occurs after the stopTest() call. In fact, it seems ...
0
votes
2answers
5k views

whats wrong in this code(Error: Invalid field ischecked for SObject Sample_Item__c ) [closed]

I dont know whats wrong in this code im getting this error msg but im not getting the records Error: Invalid field ischecked for SObject Sample_Item__c class public with sharing class sampleitem { ...
4
votes
2answers
4k views

Determine from Apex whether a user's session is invalid

Can anyone think of a way, from within Apex, to tell if a User's session has expired / been invalidated? Our app is very JS Remoting intensive, so it would be nice if we were able to detect, from ...
1
vote
1answer
176 views

Error Unkown Property payfor

I'm having a page(say VF1) and in another page(VF2) I'm getting all the values of page1.Here my problem is in my page1 Im having repeated values and need to save them In my VF1 <apex:...
123
votes
2answers
24k views

How to reduce a large internal view state / what is in the internal view state?

I'm building an account search page that lets users select accounts and then pass them to other pages to perform various actions on them. Unfortunately users are reporting hitting the view state ...
23
votes
1answer
15k views

Do changes to rollup summary fields cause triggers to fire?

If a parent record has a roll up summary field, let's say to calculate the number of line items on an opportunity, if a new line item is added (and hence the value of the rollup field is changed), ...
3
votes
2answers
6k views

Id assignment when creating sObjects in code

I'd like to get straight exactly what is happening when I create an sObject in Force.com code but can't find any information on the specifics. The Id is null until after the DML insert statement. ...
8
votes
2answers
8k views

How should I properly format a Date within an SObject parameter to a RemoteAction method?

I'm having trouble sending Date values from the client with remoted methods. If my RemoteAction method takes a plain Date value, everything works fine with the suggestion of using "toUTCString" which ...
1
vote
1answer
427 views

Custom edit layout

After including an <apex:relatedList list="Contacts"> in a VisualForce page, is it possible to force the usage of different layout to appear when user click on modify / buttons of this ...
0
votes
2answers
528 views

update record(opportunitylineitem) of child opportuity…when parent opportunity record(opportunitylineitem) is updated..?

My scenario: When i insert opportunity line-item on Parent Opportunity...opportunity line-item are also created on child opportunity(same as line-item on Opportunity).If there are 2 child ...
0
votes
1answer
486 views

Campaign and account reports

Is it me or everyone face issues when it comes to reporting on accounts from campaign ? I am trying to see all the accounts related to a campaign I do not see a report where I can pull campaigns ...
2
votes
4answers
8k views

Finding most recent record when multiple records match criteria

I have a custom sObject which has among others the following fields: email__c (email), some_date__c (date), external_id__c (integer) and criteria__c (string). There are multiple records for this ...
0
votes
1answer
2k views

Pipe seperated params in URL

I am passing Id's as pipe seperated params in URL and want to pass the params to salesforce reports e.g String param_ID_url = '701K00000002MtxIAE|701K00000002Mz9IAE'; when I try to pass to the ...
7
votes
2answers
2k views

Read-only and write-only automatic properties

The Force.com Apex Code Developer's Guide documentation for Apex Properties:Using Automatic Properties contains the following: Properties do not require additional code in their get or set accessor ...
5
votes
2answers
13k views

how to rewrite getter setter in different notation

Is it possible to rewrite this: public Assessment__c thisAssessment; public Assessment__c getthisAssessment() { if (assessmentUrlId!=null) { return thisAssessment=[SELECT Id, ...
59
votes
8answers
39k views

Get lists of dependent picklist options in Apex

I have a pair of dependent picklists. In Apex code, how can I determine what options are valid in the dependent field for each option in the controlling field? I've tried using getPicklistValues(), ...