• colemab
  • 1485 Points
  • Member since 2011

  • Chatter
  • 53
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
  • 472



We have designed a visualforce page for a custom object using a standard SF controller. This standard controller just selects records and displays certain field values for these records along with checkboxes. We are planning on having an error recycle error process as in when a user selects a record and clicks a button the errors in the record are processed. I will be using a controller extension to perform this additional logic.


The issue that we may face with this process is multiple users may have the capability to perform simultaneous updates on the same record. Is there a Salesforce standard method that I can use which prevents users say: User A in performing any updates on Record A when Record A is already being processed by User B.


Any suggestions or feedback will greatly help me out.


Hi there,


I made a code to create a task when another task have fotos_encontradas__c == 'NÃO'.

The code works fine, but whatid is not the same.


How I made my task open in same whatid?



trigger CriarTarefa_Pendencia_Duomind_Enviar_novamente_as_foto on Task (after update) {

    List<Task> task = new List<Task>();
    for (Task newTask: Trigger.New)
        if (newtask.fotos_encontradas__c == 'NÃO' && newtask.subject == 'Pendência Duomind' && newtask.status <> 'Concluído'){
                 task.add (new Task(
                     Subject = 'Pendência Duomind - Enviar novamente as fotos',
                     Status = 'Não iniciado',
                     ActivityDate = Date.today(),
                     OwnerId = '005U0000000EtIH'));   
   insert task;

Thanks ! 

Hi there,


I created a half VF, cause I could't finish the page.

I have more than 500 lines and an error appears to me "String_too_long".


But I have to build this page and I was thinking in use <apex:include>. I created another page, put this code and I could create.


I tried this:


<apex:page standardcontroler= "case">
	<apex:include pageName="TESTE"/>
            <apex:pageBlockSection columns="2" title="Dados do Formando" rendered="{!case.motivo__c == 'Impressão de foto'}">
                <apex:inputfield value="{!case.AccountID}" required="true"/>
                <apex:inputfield value="{!case.Descricao_da_foto__c}" required="true"/>


No errors appears to me, but when I click in "Preview" I can't see my page.


Someone have any clue about this?

If I don't have to use <apex:include> don't have any problem, I just want to build my entire VF.



Everton Gomes

Hello....I'm new to VF and I need any one to help me how I can generate a visual force page which displays Accounts and Related Contacts using only one query.

  • January 07, 2013
  • Like
  • 0

Let me first describe the requirement -


I have a managed package that contains an Object called Student. I have to create a many-to-many relationship with another object. I have a junction object for this.

Just imagine, that this package can get installed into different orgs, and the many-to-many relationship can happen with some object called Class or Teacher or Exam (depending on the requirement of the org.)


I am creating the second master-detail relationship of the junction object when I have installed the package in the org, and I am storing the API name of the second master-detail relationship in a Custom Settings. (Custom settings also belong to my package)


The Student-Teacher or Student-Exam, assignment is happening from a VF page(also belonging to the package). So I need to dynamically select the field API name of the second master-detail, assign value to it and save it.


Is there any way to create a Dynamic Insert DML? 


Hi Friends,


I'm having a scenario where I need to download all the attachment for a particular custom object as a single zip file on click of a button. Here I categorize attachment based on attachment description field.

Consider there are categories such as A, B & C. Under category A, there are 5 attachments (which means these 5 attachment will have description as A) When I click on a button, I need to download all the 5 attachments belonging to A category as a single zip file. Can you guide me??


Thanks & Regards,


  • November 28, 2012
  • Like
  • 0

Hi everybody:


I am trying to write a visualforce and let the customer to upload an image. The code is:


VF code:

<label>Optional: Upload Image</label><apex:inputFile value="{!body}" fileName="{!fileName}" styleclass="apexinput"/>
<apex:CommandButton value="Save" action="{!Upload}"/>

 Apex Controller:


    public Document doc{get;set;}
    public Blob body{get;set;}
    public String fileName{get;set;}

public pageReference Upload(){
//relative code
doc.body = body;
doc.Name = fileName;
insert doc;

 Why am I getting the  "Authorization Required " error everytime? Please Help. Thank you all.


I created a tabbed VF page for a custom object to replace the standard layout that we had. I used this piece of code to call all the related lists I needed.


 <apex:tab label="History" name="History" id="tabHistory">
        <apex:relatedList subject="{!Clients__c}" list="OpenActivities"/>


The trouble I'm having is I don't know (nor ca I guess) the correct name for the standard History Object that appears in every page. Can anyone tell me what I should be putting in the list
part of the code?


Thanks in advance.



I am very new to Salesforce but have Java and Python Web programming experience and have got the problem in the subject line.


My apex controller code is:


public class TimesheetEntry {
    public List<SelectOption> options;
    public TimesheetEntry() {

    public List<SelectOption> getAccountItems() {
        List<SelectOption> options = new List<SelectOption>();
        for (Account account: [SELECT name, id FROM Account]) {
            options.add(new SelectOption(account.name));
        return options;


for some reason it is complaining about the line:


options.add(new SelectOption(account.name));

 I have seen a number of forum posts where the reason for the error was that what was sent to SelectOption was not a string but in this case account.name is a string. I have also tried type casting but that has not worked.


I would be most grateful for any pointers.


Many thanks.


I have an Apex program that loops through database records, makes a web service call for each, and stores the result in the record. The web services uses a token which expires after 24 hours, so a record may make up to 3 web service calls -- 1 to fail, 1 to get the token, and 1 to succeed.


From my understanding SalesForce limits web service calls to 10 per database transaction so as a brute-force method, I am doing an update for each record like this:


// initialize wrapper, scope
AccountWrapper wrapper = new AccountWrapper();
List<Account> scope = [SELECT Id, Name, BillingStreet, BillingCity, BillingState, BillingPostalCode FROM Account LIMIT 10];

// get districts
for (Account account: scope) {
wrapper.getDistrict(account, this.api);
update scope; // update scope to stay at or under Transaction Web Services governor limit


The Http web service requests are in wrapper.getDistrict. When I run this, I get a CalloutException:


recSystem.CalloutException You have uncommitted work pending. Please commit or rollback before calling out


My guess is that the update scope is not committing the transaction. How do I do a commit, or is there a better approach?

  I have a custom object  Position__c everyday new positions will add to the object .I have 6 users. i want to send the position details that are created recently (today) to all the users in a single email.how can i achieve this.any help appreciated.





I am new to dev work and learning Apex code.  I wrote a trigger that prevents us from needing to create several workflow field updates.  It evaluates a few variables on a record and returns the proper Account Type.  In the IDE the code passed the syntax check but when I went to try it out on an Account Record in the sandbox my trigger threw an exception as follows:


Error: Invalid Data.
Review all error messages below to correct your data. Apex trigger AccountTypeUpdate caused an unexpected exception, contact your administrator: AccountTypeUpdate: execution of AfterUpdate caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old: Trigger.AccountTypeUpdate: line 16, column 1


What can I do to fix this error?  Here is the trigger code:



trigger AccountTypeUpdate on Account (after update) {
    List<Account> acctTypeUpdate = new List<Account>();
        for(Account a : Trigger.new){
            //Series of conditional statements that check for the Site ID Status and returns the proper value for the Type field
            if(a.SiteIDStatus__c =='Live' & a.ParentId == null){
            a.Type = 'Client - Parent';
                if(a.SiteIDStatus__c =='Live' & a.ParentId != null){
                a.Type = 'Client - LOB';
                    if(a.SiteIDStatus__c !='Expired'){
                    a.Type = 'Client - Cancelled';
                    } else {
                        a.Type = 'Prospect';
        update a;

Does Mailing Country have to be a part of the address, is it possible to remove?

  • October 16, 2012
  • Like
  • 0

Is it possible to hide the Parent Account field?

  • October 16, 2012
  • Like
  • 0

Does anyone here have any direction on how to get a true/false value to display as a checkmark and x ?  Any help would be great! 



Please let me know how would I give read/edit permissions to a custom object for standard "Marketing User" profile. Under profiles the read, edit, delete.. boxes are uneditable to give access.


But I see that some of other custom objects have read,edit,delete permissions checked on same "Marketing User" profile, not sure how they were checked.


Can some one please help me on this?




  • October 04, 2012
  • Like
  • 0

Hi All,

i am new to testclasses i dont know how to write test classes exactly...but i am tried but i am geting 80% code coverage only..but i need 100% can any one help this please??




public with sharing class accounts_based_on_months
   public String selected_month { get; set; }
   public list<account>acc;
   public list<account>accounts;

   public PageReference getrecords()
        string dat='';
         accounts=new list<account>();
        acc=new list<account>();
        acc=[select id,Createddate,name,phone from account];
        for(account a:acc)
            if(selected_month ==dat)
       return null;

   public list<account> getAccounts()
           return accounts;




  • October 01, 2012
  • Like
  • 0


Hi every one i want fix the page header as logo size for every page after the header i need to display the table header for every page if the records are excceded. and how to do the page nation in pdf. please help me immidiatly.

hi everbody,

i know there are a lot of posts on child relationship name, but I still wasn't able to solve my problem:
I want to update my test-page to removing a unwanted related list from "Opportunitys". I want to remove "Contact Roles".

I tryed the following code:

<apex:page standardController="Opportunity">
<b>Hello {!$User.FirstName}!</b> <br/><br/>
<apex:detail relatedList="false" />
<apex:relatedList list="ContactRole" />   


But I get this error:

'ContactRole' is not a valid child relationship name for entity Opportunity
Any Idea??




I need help with the following setScale, not sure why it's not working. I need to be able to set certain number fields with trailing 0. In this case I need a trailing 4 decimal places even if it's 0


quantity__c is Number(18, 0) (I had it set to 14,4..nothing changed)


m.quantity__c = (m.quantity__c).setScale(4);


The value would appear as ie. 10.0


If m.quantity__c was a string field I believe the setScale(4) works but i dont want to create unnecessary fields..

As you may know, forms that have inputfile tags can't use status indicators.  Also, buttons that submit forms where files are uploaded can't have javascript that runs onclick AND have apex methods called. 


So, how do you have a button that gets disabled upon click while files upload?  I ask because if a user isn't patient and clicks submit a 2nd time, they will get an error and have to start over.


Thanks for any ideas or examples.

I have seen code on how to download attachments in Java but does anyone know how to download an existing VF page that is being rendered as PDF?





I have a custom object named budget__c that has a M:D relationship with the account object.  I have multiple accounts that are in a hierarchical relation ship such as:   Corporate->Division->Region->State->Office


The levels in the hierarchy are limited to just the 5 listed.


I want to write a trigger on the budget object to update the total budget on the effected accounts.  So basically, whenever the office budget gets changed, this change is seen at all levels above it.


Here is my poorly written first attempt.  Please note this code has a query in a loop - any advice on how to keep it out of the loop would be great.  Also, this code calculates the amount on the child and parent (i.e. grand parent and great grand parent records don't calculate changes to the grand child record).


trigger UpsertDelBudget on Budget__c (after delete, after insert, after update) {
		This trigger will be used to:
		1. Update a 'roll up summary' field based on the account
		   hiearchy.  This will allow the division for example to show
		   the budgets of the offices in that division based on hiearchy.
	system.debug('>>>> UpsertDelBudget Trigger Start');
	set<Id> AccountIDsInUpdate = new Set<Id>();
	set<Id> ParentAccountIDsInUpdate = new Set<Id>();
	set<Id> GrandParentAccountIDsInUpdate = new Set<Id>();
	// Build set of Account ID's in this update
	if (trigger.isInsert || trigger.isUpdate) {
		system.debug('>>>> Insert or Update operation');
		for(Budget__c B:Trigger.new)
				system.debug('>>>> Adding Account ID: ' + B.Budget_Account__c); 
				if (B.Budget_Parent_ID__c != null) {
				}	// check for null parent id
			} // end for loop
	} // end if (trigger.isInsert || trigger.isUpdate) {
	if (trigger.isDelete) {
		system.debug('>>>> Delete operation');
		for(Budget__c B:Trigger.old)
				system.debug('>>>> Adding Account ID: ' + B.Budget_Account__c);

				if (B.Budget_Parent_ID__c != null) {
				}	// check for null parent id	
			} // end for loop
	} // end if (trigger.isDelete) {

	// This loop will add grand parent ID's first run
	// then keep going up until no more parents (great grand, grand, etc) are found
	do {	
		system.debug('>>>> In Do Loop');
		// Adding grand parent IDs 
		for(Account A:
					[SELECT ID, Name, ParentID 
					FROM Account 
					WHERE ID IN :ParentAccountIDsInUpdate 
			system.debug('>>>> Adding ID ' + A.ParentID);
			system.debug('>>>> Adding Name = ' + A.Name);
		} // end for loop
		if (GrandParentAccountIDsInUpdate.isEmpty() == false) {
			system.debug('>>>> Grandparents have parents - going again!');
		} else {
			system.debug('>>>> No more parents - exiting loop!');
			break; // exit the loop
	} while (true); // seemingly infinite loop!
    // ---------------------------------------------------------------
	// build a map of Account id's and calculated totals for budgets 
		Map<Id, Double> CurrentAccountTotalBudgetMap = new Map<Id, Double>();

	for(Id A:AccountIDsInUpdate) {	
		system.debug('>>> Current ID ' + a);
		// Use Group by in SOQL statement to have a single ID with a single sum
		for(AggregateResult d: 
				SELECT SUM(Current_Year_Budget__c) Total
				FROM Account WHERE ParentID = :A OR ID =:A 
			//system.debug('>>>> Current Name = ' + d.get('Name'));
			system.debug('>>>> Current Total ' + d.get('Total'));
		} // end for loop to find totals
	} // end of loop thru account IDs
	// ---------------------------------------------------------------

	system.debug('>>>> Final AccountIDsInUpdate.size ' + AccountIDsInUpdate.size() ) ;

	// Get sum value from map and create list to update
		List<Account> AccountsToUpdate = new List<Account>();
		// now loop thru the payments
		for(Account a: [SELECT Id, Name, Total_Current_Year_Budget__c, Current_Year_Budget__c
						   FROM Account
						   WHERE Id IN :AccountIDsInUpdate]) 
			System.debug('>>>> ------------ <<<<<');
			System.debug('>>>> Name ' + a.name);
			// 1D. set the totals on the payments
			Double BudgetSum = CurrentAccountTotalBudgetMap.get(a.Id);
			if (BudgetSum != null) {
				a.Total_Current_Year_Budget__c = BudgetSum;
			} else {
				a.Total_Current_Year_Budget__c = 0;
			} // check for null values
	    } // end loop thru payments
	// Update the totals in one DML call
	update AccountsToUpdate;	
	system.debug('>>>> UpsertDelBudget Trigger END');
} // end class


 Any advice in fixing the two above mentioned flaws would be much appricated.


I have a list of external ID's that I would like to update.


Is there anyway in excel connector to query just that list of external ids?  For example 123, 456, 789 ?



I have a list of external ID's that I would like to update.


Is there anyway in excel connector to query just that list of external ids?  For example 123, 456, 789 ?





I have some code setup to send a confirmation email upon creation of lead (via the controller extension and not via a trigger).   I use the setTargetObjectID method to map this to the lead so that the template can be populated from the lead data.


However, I don't want to email the contact on the lead.  Instead I want to send the email to a custom email field on the lead.


The documentation (see the page here) seems to indicate this is possible when it says:

"All emails must have a recipient value in at least one of the following:

toAddresses, ccAddresses, bccAddresses, targetObjectId, targetObjectIds"


I set the toaddress in the code and it works as long as I don't use the setTargetObjectID and setTemplateID methods (i.e. I hard code the email).


The error I get when I try to use the object and template (even though I am setting the toaddress before and after) is:

"VF_PAGE_MESSAGE Error: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, no email found for id ".


So it seems to require me to send the email to the email address on the lead object - even though I have set the address explicetly.  Has anyone discovered a work around for this issue?


Here is an edited for public consumption copy of the relevant code:



Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 
String[] toAddresses = new String[ {CurrentLead.Email_Confirmation_Address__c};


EmailTemplate et = [SELECT Id FROM EmailTemplate WHERE DeveloperName = 'LeadConfirmation' LIMIT 1];				 


Messaging.SingleEmailMessage[] EmailsToSend = new Messaging.SingleEmailMessage[] { email };


Thanks for any help!

Standard loops with inline SOQL look something like this:


for(Item_Detail__c S : [SELECT Amount__c, Name, Id FROM Item_Detail__c
WHERE Item__c in :ItemsSet]) {
// code inside the loop goes here


Due to the lack of a Select * in SOQL, I would like to generate the select part of the query but at the end append the :ItemsSet part.


This will allow me to build a query on all fields but have the where condition dependant on the set and be able to loop thru the results of the query.


Does anyone have an example of how to do this?



  • September 09, 2011
  • Like
  • 0

For those wishing to modify the data loader, here are the steps to getting it to compile:


1.  Already have eclipse up and running.  You probably have this already for SFDC development so I will skip the details on this one.

2. Download the latest Java JDK (NOT the JRE, the JDK).  Latest for me was 1.7

3. Download the latest source code for apexdataloader from sourceforge.  Latest version for me was 19.

    EDIT: Here is the link to version 19


4. Extract the zip file to C:\apexdataloader\

5. Open eclipse and hit file-> New Project.

6. Select "Java project from existing ant bundle"

7. Browse to C:\apexdataloader\build\ and select build.xml

8. Close the project in eclipse

9. locate your .classpath file in the project workspace directory in windows explorer (this varies based on where your home dir is).

10. Edit this file and add this line:

<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.7.0/jre/lib/jce.jar"/>

11. Re-open the project in eclipse.


*EDIT*: I think the main can be found at: com.salesforce.dataloader.process.DataLoaderRunner


You should now be able to compile w/o errors (will get some warnings).


Just sharing in case this caused someone else trouble.


In my case, I am working on modifying the data loader to honor the scale / decimal setting for currency fields.

  • September 07, 2011
  • Like
  • 0

After much frustration with (the general lack of) sales force support, I thought it would be fun to start a thread with funny quotes you have gotten from the support reps. 


"We do not consider poor designs a defect.  Any changes to existing designs are enhancements."  - SFDC Rep on 8/24/2011 explaining why they wouldn't fix a design defect / poor design, wouldn't offer a work around, and why I should post it in the idea exchange (never to be seen again).



So I have a VF form that has file attachments.  Then I have a controller extension that uploads those files (with a catch/try/final for the insert) and then sends an email.   All of this has been working fine.  


Recently, I added a new page that renders as PDF (which works fine).   I added code to get this page's content and attach it to an email.   Now the getcontent call in the apex code throws the following exception:


System.VisualforceException: j_id0:GoodRootsApplicationForm:Main:DetailRequestInfo:j_id101:ProjectBudgetfile:inputFile:file


If I don't attach a file in the form, all of this works just fine (i.e. the pdf is correctly created and attached to the email that is sent).   I am using the finally block to set the file attachment to a new attachment (for view state purposes) after the insert occurs.


What does this error mean?  Does anyone else have a form with file upload that sends an email with a pdf attachment?


Thanks for any views and/or replies.

You simply cannot use ssl on public sites unless a user has been authenticated (SFDC user or portal user).

I confirmed this with salesforce support today.   Log out of your SF session if you are in one (or use a different browser) and then goto the HTTPS addrress of your secure public site.    You will notice that it redirects you to a NON secure (i.e. non SSL) page.   Support told me that was how it was designed and that I should use portals for this function.


Can anyoneelse confirm this in their system?



A month ago, I opened a ticket with SFDC support for inconsistent behavior with command links in pageblocktables.   They have confirmed the issue but still don't have a resolution.


So, I was wondering if this effected anyone else.    Anyone else seen a command link fail to call a method in some situations but call that same method just fine in other siutations on the same page?


I want to clarify that the command link code is the same in the VF page as it is in a page block table.  However, some times individual rows in the table call the command link upon click but others do not.





I have created a VF page that will go on a public site that is meant for user to enter data into the system.  This is working fine but I noticed that URL hacking is possible (read only due to FLS on the public user profile for the site) if a user appends the id to the url (for example, VFPage?id=00AB0000001abcD).


Ideally, I would like to simply set FLS to edit with no view.  Since create FLS requires view FLS, how can one prevent url hacking in this manner?   How can we prevent the controller extension from processing data from the url?







Previously, I created a VF page on a public site and everything works.  I updated added new fields to the form in the sandbox and migrated to production.  In production, I set the field level security (FLS) for the new fields and double checked object security for the public / site user (under the sites public access settings).


However, the fields still do not display on the page for non authenticated users.  Of course they show for me once logged in.   Any ideas as to whatelse (besides object and/or field level security) could be wrong?





Hi All,


I'm getting the following error: System.LimitException: Too many SOQL queries: 101. I didn't think my query was inside a loop so I'm unsure how to fix the problem. Your help is greatly appreciated!


trigger setContactAndAccountIdOnOrder on Lead (after update) {

    Map<String,Id> Ids = new Map<String,Id>(); 

    for(Lead lead : Trigger.new) {
        if (lead.IsConverted) {
    List<Order__c> orders = [select Id, Person_Id__c, Contact__c, Account__c from Order__c WHERE Person_Id__c IN :Ids.keySet()];
        for (Order__c o : orders) { 
            Id personId = Ids.get(o.Person_Id__c);
            Lead ld = trigger.newMap.get(personId);
            o.Contact__c = ld.ConvertedContactId;
            o.Account__c = ld.ConvertedAccountId;
        update orders;        


  • April 25, 2013
  • Like
  • 0

 Is it possible in Salesforce to compress the size of image uploaded (say from 4-5 mb to 1mb) with the help of javascripts/jquery libs or any other approach?It has to be done in bulk.



 I have a small doubt,


1) I am building a site for a exam which is internal to the orgn , How to restrict the site based on organisation ip,


2) The site should to be visible only to specific ip (within orgn)


Please tell me how to do it


Thanks in advance

Hi, i need to display the account billing address in google map when click the the custom button" Map" on my Account tab. kindly reply me to resolve this issue.

Code which i am presently using to show the one account billing address but my requirement is to show all the account billing address which is near to that particular Account. Hereis the code kindly check it and help me to resolve this issue.


VF Code:


<apex:page standardController="Account">
<apex:pageBlock >
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript"> 
$(document).ready(function() {
  var myOptions = {
    zoom: 20,
    mapTypeId: google.maps.MapTypeId.HYBRID,
    mapTypeControl: true
  var map;
  var marker;
  var geocoder = new google.maps.Geocoder();
  var address = "{!Account.Project_Street_Address__c}, " + "{!Account.Project_City__c}, " + "{!Account.Project_Zipcode__c}";
  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Account.Name}</b>"
  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);
        //center map
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Name}"
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
        google.maps.event.addListener(infowindow, 'closeclick', function() {
    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s address could not be found, please make sure the address is correct.");
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
#map {
  font-family: Arial;
  line-height:normal !important;
<div id="map"></div> 




Hi Gusy,


inlineEdit in the pageblock is not working in sandbox, but the same code is working in dev org.

Any idea.




  • April 05, 2013
  • Like
  • 0

Hi Everyone,


I created a VF form which will i save  field in my custom object   I'm using this page in the site here while i'm clicking the Save! button it is showing me the Authorization required page.I checked all the permissions to object ,fields,Apex class, VF all are correct.Here is my code


Controler :


public class CreateNewCandidateToVerify{
private final ApexPages.standardController controller;
private final Candidate_to_Verify__c obj;
public Attachment attachment {get; set;}

public CreateNewCandidateToVerify(ApexPages.StandardController stdController) {
this.controller = stdController;
this.obj = (Candidate_to_Verify__c)stdController.getRecord();
attachment = new Attachment();

public PageReference zapis(){
String val = ApexPages.currentPage().getParameters().get('recruitment');
Recruitment__c rec = [
FROM Recruitment__c
WHERE id = :val
obj.Recruitment__c = rec.id;
insert obj;
Candidate_to_Verify__c added = [
FROM Candidate_to_Verify__c
WHERE Name__c = :obj.Name__c
AND Surname__c = :obj.Surname__c
AND Phone__c = :obj.Phone__c
AND E_mail__c = :obj.E_mail__c
attachment.ParentId = added.id;
insert attachment;
catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment. You can send your CV by e-mail: e-mail adress'));
return null;
//obj = new Candidate_to_Verify__c();
//attachment = new Attachment();
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Thanks for Application'));
return null;



VF Page 


<apex:page standardStylesheets="false" showHeader="false" sidebar="false" standardController="Candidate_to_verify__c" extensions="CreateNewCandidateToVerify">


<h1>Welcome in HR App</h1>
<apex:form >
<apex:pageBlock id="tst2">
<apex:pageMessages />
<apex:pageBlockSection columns="1">

<h3>Personal Data</h3>

<apex:inputField value="{!Candidate_to_verify__c.Name__c}"/>
<apex:inputField value="{!Candidate_to_verify__c.Surname__c}"/>
<h3>Contact Data</h3>
<apex:inputField value="{!Candidate_to_verify__c.Phone__c}"/>
<apex:inputField value="{!Candidate_to_verify__c.E_mail__c}"/>

<h1>Attach your CV</h1>
<apex:pageBlockSection showHeader="false" columns="2" id="block1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="File Name" for="fileName"/>
<apex:inputText value="{!attachment.name}" id="fileName"/>

<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>

<apex:pageBlockSectionItem >
<apex:outputLabel value="Description" for="description"/>
<apex:inputTextarea value="{!attachment.description}" id="description"/>

<apex:pageBlockSection >
<apex:commandButton action="{!zapis}" value="Save!">
<apex:param value="{!$CurrentPage.parameters.recruitment}" assignTo="{!Candidate_to_Verify__c.Recruitment__c}"/>
<apex:commandButton action="{!cancel}" value="Cancel!"/>




  • April 04, 2013
  • Like
  • 0



I'm just starting with VisualForce (though I'm familiar with Apex), and I just was wondering about this aspect of VF code (easy solve and kudos for whoever wants on this one!). 


So when I create a "getter" method in apex, I just reference that by omitting the "get" part of the name. like:


public string getSomething


can be referenced by

{!something} . 


I guess this makes it easier to write getter methods, my question is, 

is this a common functionality within other programming languages? Or is it just for Salesforce?

Or what is the reason behind omitting the "get" part of the method, why does SalesForce not require it? 


I don't know why something so easy has me confused. Myabe it's a dumb question but if you can understand at all why I'm confused and want to help me out I'll appreciate it!!



I have a puzzling problem where an outputlink is not rendering as a hyperlink to an VF page and nothing happens when I click on it, even though it appears that the html is rendering correctly.


See the outputlink in the VF column "Work" below::


<apex:page controller="MyWorkController">


    <apex:pageblock >

        <apex:pageblocktable value="{!WorkTable}"  var="w">

            <apex:column headervalue="Next Action">

                <apex:outputText value="{0,date,MM'/'dd'/'yyyy}" style="{!w.NextActionStyle}">

                              <apex:param value="{!w.NextActionDate}"/>



             <apex:column headervalue="Due Date">

                <apex:outputText value="{0,date,MM'/'dd'/'yyyy}" style="{!w.DueStyle}">

                              <apex:param value="{!w.DueDate}"/>



            <apex:column headervalue="Type">

                    <apex:outputtext value="{!w.WorkItemType}"/>



            <apex:column headervalue="Work">

                <apex:outputlink value="/{!w.WorkItemID}"/>









Here is the html.


colspan="1"><a href="https://na14.salesforce.com/a0Kd00000036RrYEAU"></a>

                       Seattle P2 Audit</td>


and this link works if I copy and paste it into the browser (I’m using Firefox)


The VF page cell is just rendered as if it were just an outputtext field.

Any ideas?



We have designed a visualforce page for a custom object using a standard SF controller. This standard controller just selects records and displays certain field values for these records along with checkboxes. We are planning on having an error recycle error process as in when a user selects a record and clicks a button the errors in the record are processed. I will be using a controller extension to perform this additional logic.


The issue that we may face with this process is multiple users may have the capability to perform simultaneous updates on the same record. Is there a Salesforce standard method that I can use which prevents users say: User A in performing any updates on Record A when Record A is already being processed by User B.


Any suggestions or feedback will greatly help me out.


I've done quite a bit of research on the forums on how to include a "simple" Google Map example, and have tried many of them. With all , I seem to end up in the same place as a lot of others end up based on the forum comments - the map never actually comes up. I have a valid API key that I substitute, and still nothing comes up - just a blank VF page. Does anyone have a real working example that I could review and modify?


 I just want to display a set of locations on the map. In my case, location is a custom object with country, state,city and zip (not a standard account record). If I can just get something basic working (i.e. actually see a map), I can then modify it to also set the marker colors based on some properties of the location - it's for a dashboard.


Any help would be greatly appreciated (something in API V3 would be best, but at least an example that works). I thought this was going to be simple...

Hello everyone,


We are trying to use the new API Salesforce made available during Winter '13: Test.setMock.

We followed the documentation, but encountered the following issue that we were unable to resolve: a System.CalloutException, complaining that we had "uncommitted work pending".


Of course we do, our testmethod starts by setting up some Test Data that's necessary for the test to work, and that includes inserting and updating data.

In an actual execution, there would be no data creation, as the data would already be present. Actually doing the callout doesn't raise the Uncomitted work pending exception, so the Test Data really is at fault.


We did use Test.startTest() and Test.stopTest() to differentiate Test Data creation from Test Execution but this (as expected) didn't work.

We also tried some hacks, including the System.runAs(new User( Id = UserInfo.getUserId()){} that had, in the past, allowed us to circumvent "Mixed DML operations". This didn't work either.


We considered using the Test.loadData method, but we're inserting related objects and couldn't figure out a clean enough way to make it work (maybe we should try using ExternalID's?).



For the moment, our workaround is to modify the class generated from the WSDL, adding a if (Test.isRunningTest()) {} else {}, but that means we have to modify the autogenerated code, which is suboptimal.



Did anyone try to use this new API and run into the same issue? How did you solve it?



I have made opportunity stage name as custom settings field (hierarchy type). (name:Opp_Stg_Mappings__c)


I need to query on open opportunities and I did the below way.


[select Id, ownerId from Opportunity where  stageName  != Opp_Stg_Mappings__c.getOrgDefaults().X100_Stage_Name__c];


I am getting error message

"Error: Compile Error: unexpected token: 'Opp_Stg_Mappings__c.getOrgDefaults' ".


Please let me know how do I resolve this issue.






  • May 14, 2012
  • Like
  • 0

I would like to create Public calendar resources programatically. Is this possible via the API? How are resources stored in the db, which table?


For example I would like to create:

Room 1 - Active

Room 2 - Active

Room 3 - Active, etc...


Any help with this is greatly appreciated.


  • August 15, 2011
  • Like
  • 0