• Marc C.
  • 110 Points
  • Member since 2012

  • Chatter
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
  • 42

We are experiencing difficulty re-using code which involves @future methods. If a method is not marked @future and does DML it cannot be called before a callout. If we mark it as @future it cannot be called from some other @future method. We end up duplicating methods and having pairs of doThis() and doThis_future() or with optional boolean useFuture parameters. Is there a better way?




public static void method1() {

   // Do some future async DML



// method1() can be called before callouts

// method1() cannot be called from other @future methods

// nor anywhere in a chain starting with a @future method

We would like to callout to another system each time a contact person is created. This 3rd party system returns a value which we want to write into the contact person record. If we callout "after update" then, when we write the returned value, we re-trigger our own trigger again -> infinite circle.



1) We callout "before update"

2) We use fields on the contact to check whether the callout should run

3) We use some global static variable to flag whether the callout should run


Neither of these options is very satisfying for various reasons.


Is there any way to know that a trigger was called directly from the UI and not from some Apex code (e.g. the code inside the trigger)?

It is possible to select fields from different objects in one SOQL query (like a JOIN). Example:


SELECT Id, Name, CloseDate, Account.Name, SAPID__c, StageName  FROM Opportunity LIMIT 10


But how does one get these results in apex code? I have not found out how to declare the result set:


List<whichType> = [SELECT Id, Name, CloseDate, Account.Name, SAPID__c, StageName  FROM Opportunity LIMIT 10];

  • September 28, 2012
  • Like
  • 0

We created a new custom object which I want everyone to be able to see. Under Security -> Sharing it is set (by default?) to Public Read/Write. I have not applied any additional security and assume this is the Org-Wide Default.


The problem is, when a normal user calls up the list page (via a link) it returns an "Insufficient Priveleges" message. The link is just: my.salesforce.com/a0F (is this an invalid way to link? Must I create pages and tabs??)


The fields appear as visible but under each profile's field-level security. However, in the "Custom Record Type Settings" for that object nothing is checked. Do I need to go through each profile and check "View All"?

I've just read about a dozen posts on this issue but none of the solutions work for me. Parameters simply are not passed when the commandButton or commandLink is inside a pageBlockTable. The exact same commandLink code works outside the table (see below).


  <apex:form >
<apex:pageBlock >
<apex:commandlink value="Connect(123)" action="{!selected}"> <apex:param name="customer" value="123"/> </apex:commandlink>  
<apex:pageBlockTable value="{!matches}" var="i" id="theTable" styleClass="tableClass">
<apex:column >
<apex:commandlink value="Connect(333)" action="{!selected}">
<apex:param name="customer" value="333"/>

If you click the top link, the selected action is fired with the customer parameter set to 123.


If you click the link inside the column of the pageBlockTable no action is fired.

Consider the following apex class:
global class TestRest {
   global static string doGet() {
      return '{"a":"b"}';

This should produce:
which is valid JSON. If you do system.debug it comes out exactly as expected.
But when you actually call the service via HTTP it produces literally:
which isn't valid JSON at all.
I'm sure this is a bug because it's somehow encoding the result as a Java string which no JSON parser can understand.

There are several fields of the standard object Asset which do not appear in the data model. In particular the picklist ProductFamily. It doesn't appear in DataLoader and when I use the Force.com explorer it's just not there. Also Product2, ProductCode, ProductDescription just aren't there. Again, when I edit an asset - not there!


When I go to "Asset Field-Level Security for profile System Administrator" the field is ticked readonly and I can't change it even though I am the system administrator. If it's readonly and even I can't change it's value what's the point??


Dude, where's my field?

I have a custom visual force page which lists records from an external system related to the sales force account. These records are retrieved via web service callout in the constructor of my custom controller apex class. Now, if the web service fails (e.g. timeout, network failure) I want to log this failure within sales force.


Idea 1: Log the error to the debug log with System.debug(). Problem: I have to ensure that debug logging is enabled for all my 100's of users. As far as I can see, nothing is logged if I don't do this. Even if I enable logging it's not very easy to work with and sales force limits the data size.


Idead 2: Create a custom object called SystemEvent and do an insert with some useful information such as the time, user and reason. Problem: the framework does not allow me to do an insert (System.LimitException: DML currently not allowed) when my page is called (either constructor or getSomethings methods). I could add an action but then I need a button and the user has to click "Load" to see any data.


So now I'm stuck between a rock and a hard place.

1) Is there a better way to log such events?

2) Why does force.com impose such a limit on me? Trust me guys. I can use the DMS responsibly - is there any way around this?

I have a VF page that was written by a former coworker.  It uses the URLFOR action for a "New" button.


<apex:pageBlock >
                <apex:pageBlockButtons >
                    <apex:commandButton value="New" action="{!URLFOR($Action.Case.NewCase)}" />

This is to create a new case in our Partner Portal, but I'd like to default the Contact on the Case to be the Partner User creating the case (like standard behavior on the Customer Portal).  Is there a way to do that here?  I'm trying to get by since our developer left, so any assistance is appreciated.


I have a trigger that I just deployed a month ago which had 100% code coverage under Winter 12.  Our Sandbox switched to Spring 13 and now it is showing 0% coverage.  I have rerun the tests and it varies from telling me 2/4 failed to 4/4 failed but always due to the sections where it is a system assert.  Nothing in the code changed except editing a little bit of the adderror line for the text it shows to the user.  Other classes/triggers seem to be having the same issues.  Is anyone else encountering this with Spring 13?




It looks like the Code Coverage pages for my apex code now includes blank lines and commented out rows as "Un-covered" and highlights them in red.


Is anybody else noticing this? Is it a bug?


With thanks,


I have a visualforcepage which is included in a layoutpage.

Viewlayout of this object has an override with another visual force page.


When I  call a pagereference methode from "inline" visualforcepage an try to leave the Iframe and load current objectpage again, salesforce creates a new URL with parameter inline=1.

By this parameter, Header and Sidebar is invisible. 



<apex:commandlink styleClass="btn newButton" style="text-decoration: none; margin: 2px !important;" value="Click" action="{!executeAction}" target="_parent">
pageRef = Page.NAME;
//pageRef = new ApexPages.StandardController(OBJECT).view();


 Is there a possibility to avoid getting parameter inline=1?


I tried:

  • new parameter inline=0
  • URL as a string
  • new redirect visualforce page


without success...




Hopefully easy question.


I'm trying to create PDF page and trying to format it nicely.


I have datatable with columns to list items I want to show.

Since I want to line up all lable and data field nicely, I've put 4 columns (label, data, label, data).


The question is how can I get the label of the field?

I've tyied <apex:outuputlabel value="{!Opportunity.Account.Name.label}"/>

also tried <apex:outuputtext value="{!Opportunity.Account.Name.label}"/>


 but didn't work.


    <apex:dataTable value="{!Opportunity}" var="o" columns="4" columnsWidth="150px, 220px, 150px,220px" >
    <apex:column >
    <apex:outputlabel value="{!o.Account.Name.label}" />
    <apex:column >
    <apex:outputText value="{!o.Account.Name}" />



  • August 18, 2011
  • Like
  • 0



     I have a requirement where in the default values have to be set for the Standard Field of Opportunity i.e. Opportunity Name, could any one suggest a solution for this. 



Thanks & Regards




I have two lists in my class. One(list1) has names of the donors of last year.Another(List2) has the names of the donors of this year. I need to find the donors who donated last year but not this year. For this I need to subtract the names of list2 from list1.


how to do that? I searched in apex pdf doc but did not find any info. Please help me.



i was hoping to use a hierarchical custom settings object to store user preferences for an app. This would require the user to create and edit their custom setting record.


From what i have read this would require every user to have the "Customize Application" permission to create and edit their own custom setting record. Obviously we cannot do that.


Is there some way to get around this with a vfpage & apex? So the user can goto a vfpage and create/edit the custom settings object record so they can manage their preferences?

I have installed an application called CaseHistory from appExchange and wanted to modify the relevant VisualForce page - CaseHistory.page.


I attempted to use the title attribute of the <apex:page> tag as follows:

<apex:page showHeader="false" controller="CaseHistoryController" title="Case: {!aCase.CaseNumber}">


However, I keep seeing the title as "Page Editor - /apex/CaseHistory". I changed my user setting to NOT be in Developer mode but I still don't see the page title changed to what I was trying to set in the code above (Case: caseNumber).


Any ideas on how to resolve this?


Thanks in advance,


When I try to install Chatter SmartFollow, I get the following test errors:




1. Apex Classes(01pS000000011bd) chatterfollowbatchcaller.testchatterFollowBatchCaller()

System.Exception: Assertion Failed

Class.chatterFollowBatchCaller.testchatterFollowBatchCaller: line 174, column 3 External entry point


2. Apex Classes(01pS000000011bg) chatterfollowrules.testFollowEveryone()

System.Exception: Too many query rows: 501

Class.chatterFollowRules.testFollowEveryone: line 646, column 48 External entry point


Validation Errors While Saving Record(s)


There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "00DS00000007M8X: APEX_TEST_FAILED [01pS000000011bd: chatterfollowbatchcaller.testchatterFollowBatchCaller(): System.Exception: Assertion Failed

Class.chatterFollowBatchCaller.testchatterFollowBatchCaller: line 174, column 3 External entry point, 01pS000000011bg: chatterfollowrules.testFollowEveryone(): System.Exception: Too many query rows: 501

Class.chatterFollowRules.testFollowEveryone: line 646, column 48 External entry point]".


Is anyone else running into this issue?

After editing my apex class from within the Force.com IDE, i clicked "Save" button. Got an error "File saved locally, not to server". How can i get past this errror? Thanks!

I've created a vf page, created a home page custom link, and overridden my tab w/ the vf splash page, but my buttons do nothing.


How do you create a method for "continue" and "Do not show this message again"? 


<apex:page title="About Lead Scoring"> <apex:sectionHeader /> Hi - I'm an about page <apex:form id="theForm" title="form"> <apex:pageBlock > <apex:pageBlockButtons > <apex:commandButton value="Continue" action="{!continue}"/>&nbsp;&nbsp;&nbsp; <apex:commandButton value="Don't Show Me This Again" action="{!????}"/>&nbsp;&nbsp;&nbsp; </apex:pageBlockButtons> </apex:pageBlock> </apex:form></apex:page>



The help isn't very helpful.   I might just give up on the tab so PE users can still use the app despite the tab limits.

Hi Experts,

can i call standard controller's save action in my extension controller...



<apex:page standardcontroller="opportunity" extension="oppoExtesion"> <apex:form> <apex:pageblock> <apex:pageblockbutton> <apex:commandbutton value="Save" action="{!mysave}"/> </apex:pageblockbutton> <apex:inputfield value="{!opportunity.name}"/> <apex:inputfield value="{!opportunity.amount}"/> <apex:inputfield value="{!opportunity.closedate}"/> </apex:pageblock> </apex:form> </apex:page> ********Extension************* public class oppoextension { public pagereference mysave() { my validation check...... //Here i wnat to call standard controller's Save Action to perform the save operation as standard way... save(); } }


i want to experience standard salesforce validation check , field level security , profile base permission 

as well as my custom validation through apex code


so how can i standard controller's Save from my extension's save method...



I have created a custom list button and want to add this to the list view as well as related lists. I was able to add this custom button to the related list, but not to the standard list page. I am going to the object settings and am adding it to the list view layout, but the button is not showing. How do I get this displayed in the List view?



  • June 20, 2009
  • Like
  • 0

I'm trying to test an Apex method that calls an @future method.  I looks like my testing works up until the point where the @future test is called.  The test checks some results from the @future method and it looks like they haven't been executed yet.


Does @future execute asyncronously in test mode?


If so, how does one test @future methods?



Hello.  I want to create a simple custom list button that creates a new record of a specific record type and with some fields already populated with data.  However, I keep getting the record type screen when I click the button.


Here's the entire URL code for the button. I'm not even trying to populate the fields with data right now, just trying to get past the Record Type prompt screen.



{!URLFOR($Action.Investment_Task__c.New, null, [RecordType='012400000009bAQAAY'])}






Hi All,
We are currently facing an issue regarding SMS integration. 
We need to send the SMS automatically when a case is saved/edited. For this we have an apex class which consists  of  HTTPS callouts to access the SMS gateway of Value first 
and a trigger which invokes this apex class when ever a case is saved/edited.
Now, when ever the trigger is fired i'm getting this exception     "System.CalloutException: Callout from triggers are currently not supported"
I think it can be possible by S-Control  but the process should automatic.  
And this is very urgent for our project 
Pls suggest any solution /workaround  for the same.

Any help is appreciable.
  • January 28, 2009
  • Like
  • 0
I want to have a read-only look-up field in my instance of Salesforce. However, whenever I build one, they either seem to be invisible to all, or editable.
I want a Read-Only Look-up field is so I can update it later using some behind-the-scenes APEX coding as part of the sales & contracting process. I just don't want people to be putting information in that field before they're supposed to.
Does anybody know if Salesforce doesn't allow for Read-Only Look-ups? I'd understand why.
Thanks for your help!
How do I get a custom link to open up in the same window it was launched from?  Normally when I click on a custom link, it opens up the code it calls in a completely new salesforce window that is identical to the source window except for the new context in the iframe...