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
0
votes
1answer
134 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
230 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
15k 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
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, ...
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} ...
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
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
662 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
685 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
603 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
534 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
759 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
564 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
7k 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 ...
5
votes
2answers
4k views

Where is the documentation for the CreatedBy object?

Browsing salesforce topics on message boards I came across this code: CaseComment comment = [SELECT CreatedById, CreatedBy.UserName FROM CaseComment]; It looks like CreatedBy is a field of ...
3
votes
2answers
4k views

serverurl and visualforce

How do I get the server URL from a visual force page? I am using conga and when I invoke from a button the code it passes the server URL as: ServerUrl=https%3A%2F%2F***cs9.salesforce.com***%...
0
votes
1answer
136 views

can we set vf page to customobject as relatedlist only in custom portal is that possible to do

can we set vf page to customobject as relatedlist only in custom portal is that possible to do because i have a scenario if the check box is checked are not records should display in organisation ...
0
votes
1answer
142 views

Can we put VF page as related list to Another VF page

Can we put one VF page as related list to Another VF page in customer portal. if it is possible can any one say me how it can be done.
1
vote
3answers
3k views

Trigger Save Error - Variable Does Not Exist

I'm getting an error when saving the following trigger (it's my first). It says that on line 38, the variable gcamount does not exist. This makes me think that the scope of the variables within the if ...
13
votes
3answers
27k views

Handling a Query Zero Results

Let me preface with I have used Apex only a little bit. I have a visual force page that will be hosted on sites publicly. I take the value of the url string and then query a custom field on the ...
1
vote
3answers
2k views

How to write a dynamic code for this code

Hi I designed this vf Page to display records from the bank object with total at the bottom of the Page actually there are two number fields In bank object October,November. In future if other months ...
4
votes
3answers
2k views

Count of Salesforce batches used in the Org

When I look at the "Monitor Bulk Data Load Jobs" link in my salesforce org, I see a count of batches consumed in the last 24 hours. An example is shown below. Your organization has processed **821 ...
0
votes
2answers
1k views

Generate an email alert to the Issue Owner

I have created a custom object(1) in my organization with a check box and a look up field link to the main object(1). I need to create a task when a user, other than the Owner of object(1), creates/...
12
votes
1answer
1k views

Not receiving all Apex Exception emails for Managed Package

We have a Managed Package deployed on several dozen orgs, and appear to be missing a lot of Apex Exception emails. We do receive a number of such emails on a regular basis (so we know it's working ...
0
votes
1answer
275 views

how to get the value of a variable from save method

I'm getting value of billing.billingfirstname in save method.Now I need to pass this value into another method....How can I get it.here is the code @future(callout=true) public static void ...
5
votes
2answers
792 views

Select from PricebookEntry breaks call from Visualforce

For some reason the second query in the constructor makes the Cancel button in my visualforce page not work. Does this have to do with some special quirk in PricebookEntry? If you comment out the ...
6
votes
3answers
812 views

How can I rewrite this method with efficient SOQL queries

public List<phonesterDat> getCompanyData() { List<phonesterDat> var1 = new List<phonesterDat>(); for (Keyword__c keyword : [select kw__c from Keyword__c]) { phonesterDat var = new ...

1
634 635
636
637 638
640