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
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
580 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
vote
1answer
557 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
112 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 ...
7
votes
2answers
811 views

Incorrect line reference from NullPointerException

Firstly, this has happened to me in the past, I raised Salesforce support case 07939141, and it appeared to be resolved (with no notes on what was done to fix it other than that it now works). Now it ...
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 ...
0
votes
1answer
136 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
7answers
4k views

Is it possible to create a reusable inline Visualforce page?

I'm working on a Visualforce page that (forgetting about page layouts for a moment) takes in a Record Id (from one of a variety of objects), does some querying for Content based on that Record Id, and ...
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
233 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
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 ...
0
votes
2answers
683 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
5k 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 ...
2
votes
1answer
206 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 ...
1
vote
1answer
16k 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
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 ...
-5
votes
3answers
3k 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 = [...
1
vote
1answer
2k 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, ...
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 { ...
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
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 ...
5
votes
1answer
3k 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 ...
4
votes
1answer
698 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 ...
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 ...
4
votes
2answers
687 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 ...
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:...
8
votes
3answers
3k views

ANY documentation on writing reusable code?

I just spent several hours with google etc. trying to find some documentation and I have come up empty handed. My code right now has a fair percentage of duplication and I would like to fix that by ...
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. ...
1
vote
1answer
430 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
619 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 ...
2
votes
4answers
9k 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
544 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 ...
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, ...
0
votes
3answers
6k views

How to make the check box true even if it is not ticked in visual force page

How to make the check box true even if it is not ticked in visual force page, I mean the picture with tick mark. but its not working, is ther any other way Edit: <apex:page controller="...
0
votes
2answers
4k views

Initial term of field expression must be a concrete SObject:

list<Temp_Invoice__c> tempInvoice = [select id,First_Name__c,Last_Name__c,Email__c from Temp_Invoice__c limit 1]; tempInvoice.First_Name__c = billing.billingfirstname; getting error as ...
0
votes
2answers
102 views

sending ids to controller and saving..?

<apex:commandlink action="{!removeline}" onclick="if(confirm('Are you sure?')) " reRender="thePB" target="_top" > <img src="{!$Resource.Red_Cross}" alt="Remove" title="Remove" /> <...
1
vote
1answer
1k views

How to get values from class to trigger

I'm having a class with a picklistfield (field1) and in that I'm getting values as string field1; Public string getfield1(){return field1;} public void setTemplate(string field1){this.field1 = ...
15
votes
2answers
768 views

Opportunity Management

This is my first post here on the StackExchange and hoping someone can help. I have been tasked with finding a way to prevent users from moving to 70% or greater probability in an opportunity when ...
1
vote
2answers
77 views

Why is this on Opportunity not completing?

I have a trigger for an Opportunity: trigger SolutionEngineer on Opportunity (after insert, after update) { List<Trial__c> trialList = [select id, Opportunity_Name__c, Solutions_Engineer__c ...
8
votes
3answers
574 views

Control Fields vs Heap “Mock” Fields for Branching Trigger Behavior

I've seen solutions that talk about adding control fields to allow for clever trigger branching in problems like this. I know that works, but it annoys me (feels architecturally wrong) to create such ...
2
votes
2answers
8k views

How can I get a complete list of fields for a standard object?

I am new to Apex, but it is apparent to me that most (if not all) standard objects probably have an ID field. However, this field does not appear in the reference for the standard objects in the Soap ...

1
643 644
645
646 647
649