Questions tagged [controller-extension]

A controller extension is an Apex class that extends the functionality of a standard or custom controller.

Filter by
Sorted by
Tagged with
28
votes
2answers
497 views

How to write the superduper (=proper and stable) Custom Save method

Custom Save actions in Apex are tricky! Here are my requirements which I was unable to fulfill without harming the stability of my code: Save for New and Edit (works with record with and without Id) ...
20
votes
3answers
14k views

Multiple controller extensions communication

I have a Visualforce page with two controller extensions. Is there any way to get a reference to one of the extensions in the other one?
17
votes
3answers
5k views

Knowing if a future call is allowed

I'm having an issue where we have some code that can be called anywhere and then it makes an @future call to log a message to an external system. The problem is if this method is called (either ...
16
votes
1answer
12k views

How to override Save method in standard controller extension?

I am wriiting a extension on Case object. There I want to write a save method with my own logic and want this save method should override the standard Save method. So my code goes like below: ...
13
votes
2answers
19k views

SObject row was retrieved via SOQL without querying the requested field in controller extension

I have written this controller extension: public with sharing class PopupController { ApexPages.Standardcontroller cont; public Request_Change_Reseller__c req{get;set;} public ...
13
votes
3answers
8k views

'Map key null not found in map' when using apex:pageBlockTable

I have a simple controller extension with has a method which returns a Map<String, Map<String, Boolean>. public class UserExtension { private final User theUser; public ...
11
votes
2answers
1k views

Do I have to prevent Dirty Updates myself when overriding Save in a controller extension?

The standard behavior (tested on Opportunities) is that Salesforce seems to handle dirty updates / save conflicts as expected: User A opens Opportunity X User B opens Opportunity X User A modifies ...
7
votes
2answers
24k views

How to set record type of records while saving the records?

I have a vf page and its extensions,I am trying to save the multiple lists of a object against a particular recordtype.But i am unable to fetch the record the record type and then assign to the same ...
7
votes
3answers
52k views

Using PageReference to redirect after new record insert

Continuing from my previous post. I want to redirect the user to a custom vf detail page when they create a new Service Order from my custom page order page (force_NewOrder). I have created a ...
7
votes
1answer
2k views

Unable to access controller class properties from extension class

I am creating a new opportunity wizard to ensure that specific data is always entered when our sales reps create a new opportunity. As part of this effort, I've also over-written the lookup window for ...
6
votes
1answer
5k views

Controller Class Inheritance vs Multiple Controller Extensions

From reading the docs and dev forums, it seems that having multiple controller extensions can offer the ability to override methods, and keep class size/structure simple. Because these are things ...
6
votes
1answer
894 views

Can there be a Shared Extension across Multiple Overridden Visualforce Pages?

I would like to know if its possible to share a common extension class across multiple Visualforce Pages which use different standard Controllers. For Eg., I've VF_A Page which overrides default ...
6
votes
1answer
195 views

Queues, Email Notifications, Standard Controller Extensions. Oh My!

Created a controller extension for the standard case controler. we set the OwnerId using custom save logic, but it doesn't seem to matter what i do, Queue Notifications are never sent out to members. ...
6
votes
2answers
1k views

Test ControllerExt for Flow

I am trying to get coverage up for the following controller extension which I am using with Flow public class ClosedLoopMarketingFlowExtension { private final Contact cont; private ...
6
votes
1answer
1k views

SObject row was retrieved via SOQL without querying the requested field. Transaction_Survey__c.Transaction_Score_Other_Reason__c

I'm getting this error in a Visualforce page I'm working on. I understand that this error comes up when you try to reference a field you haven't queried, but the problem is, I have it referenced on ...
5
votes
3answers
415 views

Controller extension design pattern help needed

Objective I'm trying to create a series of inline charts to be displayed on the detail of a record using either Visualforce Charting or Highcharts. The charts do need to be dynamically rerendered ...
5
votes
2answers
270 views

Multiple Extension problem

I am working on Visualforce page which using standardController and has multiple extension. <ape:page StandardController = 'CustomObject__c' extension = 'ClassA,ClassB'> {!obj.field__c}...
4
votes
1answer
2k views

How to instantiate a class in custom controller from within controller extension?

This should be simple. I have a custom controller like so public class MyClass { . . . public class MyType{ String a; Integer b; List<Account> c; } ...
4
votes
1answer
6k views

How to get the object reference from a standard controller save()?

See the following VF Page controller extension: public with sharing class IssueController { public Issue__c obj {get;set;} private ApexPages.StandardController stdController; public ...
4
votes
1answer
128 views

Can you output map values in visualforce inline using a string key?

Can you output a value from a map in a custom extension without or it being in a table? Tried the below and did not work. example extension: public without sharing class Example { public List<...
4
votes
3answers
8k views

Build a String for Database.query

for an exstention controller of a VF page, I need to build a query to retrieve all the lead with a Company name similar to a variable. My variable name is compagnia: Now I'm trying to build the query ...
4
votes
1answer
5k views

custom controller with extension

What are some use cases in having a custom controller with extensions? Does it make sense to have something like this? EDIT2 Edited out the error I was receiving - apparently in my extension I was ...
4
votes
1answer
414 views

Unknown property

Why am I getting the following error? Unknown property Controller Extension public class CrewWorkDetailController{ public final Installation__c installation ; public ...
4
votes
1answer
3k views

Can you access parent object fields in a 'New' page override without using SOQL?

I have two objects, Parent__c and Child__c, Child__c has a lookup field to Parent__c calledParentId__c. I have overridden the New and Edit pages for Child__c using a Visualforce page with the ...
4
votes
1answer
1k views

How to call controller extesion action from VF component

This question is similar to How to call a standard controller action of a VF page from a VF component, but there are two differences I see: I'm not using a standard controller the <apex:form> ...
4
votes
3answers
139 views

Please advice is this a good design for my VFP rendered in PDF

i have a VFP that rendered in PDF format for my Quote. And due to the limitation whereby long text doesnt word-wrap in my table , i decided to loop through my long text content and put a line break ...
4
votes
1answer
140 views

Challenging (but fun) problem: Consolidate address validation webservice code for use within Visualforce Componet used by different Objects

Salesforce Kahunas, I need help understanding if the following is possible, and then help consolidating the code pieces into the appropriate spots. I had a requirement to use a WebService for ...
4
votes
2answers
1k views

How to test New behavior of a custom controller extension

I have a Parent__c and Child__c object with Child records using a custom Controller Extension and Visualforce page for EDIT and NEW. Testing this controller extension for existing Child__c records is ...
4
votes
3answers
3k views

Showing visualforce pages to Communities users, but standard Salesforce pages to all other users, without writing a dozen controller extensions!

I'm building a Communities site with several custom objects that Communities users should access through Visualforce pages. All other Salesforce users should access these objects through the standard ...
4
votes
0answers
338 views

Can't access Flow.Interview Class within Apex Controller

I am trying to override a Salesforce standard button on the case page layout (Clone As Child Button) - which will create a related child case with some of the fields from the parent copied over. ...
4
votes
0answers
225 views

How to test controller extension for 'New' record use case?

I'm trying to create a test class for a null record. I have a vf page, and extension, that acts as a form for creating a new record. In my extension constructor I have the following code public ...
4
votes
2answers
178 views

controller extension not found

I created a controller extension for the Contact object. I don't know if it will work or not, because I can not test it. Salesforce is acting like my controller extension does not exist. Error: ...
3
votes
2answers
24k views

How to Write Test Class for Standard Controller Along With Extensions

Hi Everyone I'm finding it difficult to write test class for this class Class public class SendEmailReceipt{ public Payment_Receipts__c Rec; public string em{get;set;} public id ...
3
votes
1answer
5k views

Error message: SObject row was retrieved via SOQL without querying the requested field?

I receive the following error: SObject row was retrieved via SOQL without querying the requested field: Installation__c.Name Controller extension on custom object: public class ...
3
votes
1answer
445 views

4 level, nested for-loop. Bulkified?

I have the following code that works for me. My main concern is the nested for-loops I have toward the end of the code. I'm in the sandbox and don't have enough records to bulk test. I figured I'd ...
3
votes
1answer
11k views

Creating New record using Standard Controller and Extension

I have created a page using standard controller and extension. This page should create a record if no id passed and shuold update a record when id passed. Following is the controller public ...
3
votes
2answers
964 views

Launching Flow using VF page

I'm attempting to run a flow from my first VF page. I was able to construct my code using the concepts I learned in another StackExchange post. I can get the flow to run just fine using the VF page ...
3
votes
1answer
6k views

How to call methods from multiple extensions in visual force page

i have created visualforce page with multiple extension. For ex: for controller one(cntrl1) i have created method(methd1) and for controller two (cntrlr2) i have created same method(methd1). Now on ...
3
votes
1answer
483 views

SObject row was retrieved via SOQL without querying- Using Dynamic References

I am referring to a code from salesforce documentation https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_sample_standard.htm where it is shown how to build a list ...
3
votes
3answers
4k views

Standard Controller OR Custom Controller

When and how to decide whether to go with Standard Controller OR Custom Controller? I have created so many vf pages,classes, extensions but still I'm not sure to include standard controller or custom ...
3
votes
1answer
775 views

How can I test create an instance of a VisualForce Controller Extension for testing?

Typical of custom controller extensions, my extension has a signature public MyVFCtrlExt (ApexPages.StandardController standardController) I'm currently trying to figure out how to write unit tests ...
3
votes
1answer
1k views

Easy way to find out which field has changed in custom save() in Controller Extension

For some reasons I had to implement a ControllerExtension with a custom save methods which delegates the actual DML to a batch. I only want to fire this batch if any (or specific) fields have been ...
3
votes
1answer
5k views

VF Pages as Tabs with in a Main VF Page (Including Multiple VF Pages)

I am looking at a robust & scalable approach to include multiple (~10) VF Pages as Tabs into the Main VF Page. Each of these will have its own controllers (heterogeneous controllers overall). What ...
3
votes
2answers
66 views

Problems with getParameters testing

I have written a very simple controller extension to show some data from a related list in a Visualforce pdf. public with sharing class adviceRelList { public adviceRelList(ApexPages....
3
votes
2answers
272 views

Can a single VF page override both a standard action and a list action?

To minimize the complexity and number of distinct pages in my org I would like to use a single VF page to override both the standard Delete action and create a Delete list view action that allows a ...
3
votes
1answer
136 views

User Role with IF Statement

I am trying to populate a field in a Visualforce page for custom object using a controller extension. I would like to populate the field with one value if the User Role of the person creating the ...
3
votes
2answers
1k views

Saving Opportunity and related Contact from single Visualforce page

I have created a visualforce page that displays both opportunity and contact fields that I want users to be able to edit and save. I am using the opporutnity standard controller and added the ...
3
votes
1answer
23k views

Get current logged in users data in VF page and extension

I want to display the currently logged in users in my VF page. Calling the following is not allowed: <apex:outputField label="Raised by" value="{!$User.Id}"/> I would like to know how else I ...
3
votes
1answer
76 views

Can I send a user to a standard layout edit page at the end of a wizard?

I want to do something that's been asked about before, but I am going to give some more reasoning in case I'm missing a better solution. I am developing a package. As part of this package, there's a ...
3
votes
2answers
8k views

Visualforce Page Unknown Constructor Error

I have a Visualforce page that is referencing a controller extension, but I am getting an Unknown Constructor error, which appears to indicate that the controller doesn't exist (but it does). I have ...

1
2 3 4 5
9