• Ashish_Sharma_DEVSFDC
  • 1027 Points
  • Member since 2014
  • Salesforce Consultant

  • Chatter
  • 31
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 5
  • 347

There is a field called "Display_LastModifiedDate" on Orders. I am trying to retrieve orders with "Display_LastModifiedDate" between 175th -185th days back from today dynamically. I cannot hardcode 175th and 185th dates because if I query it after a week the 175th and 185th dates change. Please guide me.


I am trying to write some SOQL so that I can perform some bulk operations on opportunties. However, whenever I run this SOQL I get an error: "unexpected token: AND"

Here is the SOQL:
String query2 = 'SELECT Id FROM Opportunity WHERE NOT StageName LIKE \'%'+'closed'+'%\' AND division__c = \'IT Solutions\'';

Here is the System.debug output:
SELECT Id FROM Opportunity WHERE NOT StageName LIKE '%closed%' AND division__c = 'IT Solutions'

I am just unsure what is wrong with this SOQL, seems I am escpaing the single quotes correctly... 

Thank you!
Hi Team,

    I have a custom object and it have a encrypted field.
    When I am trying to fetch all records in a visual force page the values like XXXXXXX.
    How can I decode it in apex class?
    I have one more doubt.
    If I enter a value from custom  visual force page how can I encrypt? And How can I decrypt in apex/controller class?

I would like to know how many apex classes are failing in my sandbox.I am using "run all tests" for that. Is there any way, where i can get the exact list of those classes which are failing? PLease help me out.
Dear all, I`m new to apex and I would like to understand how can I add multiple validation rules to this extension. Our org has multiple validation rules and we would like to populate that on VF page. Can someone pls give me an example of how I can use multiple Try/Catch statements in dosave() method below. Whatever I`m trying is failing. Please help!!!

public with sharing class ExampleTP {

    String oppId;
    String ownerId;
    private final Opportunity Oppty;
    public ExampleTP (ApexPages.StandardController stdController) {
        oppId = stdController.getId();
        Oppty = (Opportunity) stdController.getRecord();
        ownerId = oppty.OwnerId;
        if(oppty.StageName == null)
          oppty.StageName = 'Identified Opportunity';
        if(oppty.Probability == null)
            oppty.Probability = 0;

public transient Map<String, Decimal> probabilityStageNameMap;

public PageReference changeStageName() {

if (probabilityStageNameMap == null) {
 probabilityStageNameMap = new Map<String, Decimal>();
for (OpportunityStage oppStage : [Select MasterLabel, DefaultProbability
                                    From OpportunityStage]) {
 probabilityStageNameMap.put(oppStage.MasterLabel, oppStage.DefaultProbability);

 if (probabilityStageNameMap.containsKey(Oppty.StageName)) {
   Oppty.Probability = probabilityStageNameMap.get(Oppty.StageName);

  return null;
  public PageReference doSave()
      if (Oppty.LeadSource == 'Marketing Campaign' && Oppty.CampaignId == null )
    upsert oppty;
     return new PageReference('/' + 'apex/TPDynamicOppNEWLayout?oppId= + Oppty.Id'); 
catch(Exception e)
            Apexpages.addMessage(new Apexpages.message(ApexPages.Severity.Error,'Campaign is required'));
            return null;


I'll post the VF page and the controller below.  Here's the error message I'm getting when trying to save my page:

Error: Unknown property 'String.Name'

VF Page code: 
<apex:page controller="TestPagination">
    <apex:form >
        <apex:pageBlock id="pb">
            <apex:pageBlockTable value="{!Lead}" var="a">
                <apex:column value="{!a.Name}}"/>
                <apex:column value="{!a.company}}"/>
                <apex:column value="{!a.Email}}"/>
                <apex:column value="{!a.Lead status}"/>
                <apex:column value="{!a.Lead source}"/>
            <apex:panelGrid columns="7">
                <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!first}" disabled="{!!hasPrevious}" title="First Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!previous}" disabled="{!!hasPrevious}" title="Previous Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!next}" disabled="{!!hasNext}" title="Next Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!last}" disabled="{!!hasNext}" title="Last Page"/>
                <apex:outputText >{!(pageNumber * size)+1-size}-{!IF((pageNumber * size)>noOfRecords, noOfRecords,(pageNumber * size))} of {!noOfRecords}</apex:outputText>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
                <apex:outputPanel style="color:#4AA02C;font-weight:bold">
                    <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>

Controller code:

public with sharing class TestPagination {

    public String Lead { get; set; }
    Public Integer noOfRecords{get; set;}
    Public Integer size{get;set;}
    public ApexPages.StandardSetController setCon1 {
            if(setCon1 == null){
                size = 10;
                string queryString = 'Select Name, Company, Email, Lead Status, Lead Source from Lead order by Name';
                setCon1 = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
                noOfRecords = setCon1.getResultSize();
            return setCon1;
    Public List<Lead> getLead(){
        List<Lead> accList = new List<Lead>();
        for(Lead a : (List<Lead>)setCon1.getRecords())
        return accList;
    public pageReference refresh() {
        setCon1 = null;
        return null;
    public Boolean hasNext {
        get {
            return setCon1.getHasNext();
    public Boolean hasPrevious {
        get {
            return setCon1.getHasPrevious();
    public Integer pageNumber {
        get {
            return setCon1.getPageNumber();
    public void first() {
    public void last() {
    public void previous() {
    public void next() {

I am new to  apex. Please help me to resolve this error. Thanks in advance
Dear colleagues,

could you please help? I am new to Apex and just struggeling with the "System.LimitException: Too many Email Invocations: 11" error.

I am trying to send an email to the Contact owner upon creation of a task for the contact. That works so far fine, except that I am breaking the governor limt for the number of emails to be sent.

This is my trigger:

trigger Individual_SM_Notification_v2 on Task (after insert) {

//Query for Contact    
//Step 1: Create a Set of all Contacts to query
Set<String> allWhoIds = new Set<String>();
for (Task newTask : Trigger.new){
if (newTask.WhoId != null){
    system.debug('Step 1: ' + newTask.WhoId);

//Step 2:Query the Contact Ids from the WhoIds (from Step 1)
List <Contact> potentialContacts = [Select Id, Name, Owner.Email, Owner.LastName From Contact Where Id In :allWhoIds];
system.debug('List<Contact> Details: ' + potentialContacts);
//Step 3: Create Map to search Contacts by WhoId
Map<String, String>WhoIdToContactMap = new map<String, String>();
for (Contact c : potentialContacts){
WhoIdToContactMap.put(c.Id, c.Owner.Email);

// Create a master list to hold the emails we'll send
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
//Get the matching Contact Owner by the Contact Id
for (task newTask : Trigger.new){
String UserToUpdate = WhoIdToContactMap.get(newTask.WhoId);
System.debug('User to update: ' + UserToUpdate);

// Step 1: Create a new Email
      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();    
// Step 2: Set list of people who should get the email
      List<String> sendTo = new List<String>();
    System.debug('Step 2:' + sendTo);
// Step 3: Set who the email is sent from
      mail.setSenderDisplayName('BCS GMIB Research Team'); 
    system.debug('Step 3:' + mail);

// (Optional) Set list of people who should be CC'ed
      List<String> ccTo = new List<String>();
// Step 4. Set email contents - you can use variables!
mail.setSubject('Research Call Update');
String body = 'Date: ' + newTask.ActivityDate + '<br/>';
body += 'Caller: ' + newTask.Assigned_To_Dupe__c + '<br/>';
body += 'Company Name: ' + newTask.Account_Name_dupe__c + '<br/>';
body += 'Contact Name: ' + newTask.Client_Name__c  + '<br/>';
body += 'Description: ' + newTask.Description + '<br/>';

// Step 5. Add your email to the master list

// Step 6: Send all emails in the master list

This is my test class:

public class TestLastResearchActivity_v2 {
    static testMethod void testLastResearchActivity_v2(){
        Account acc = new Account();
        acc.Name = 'ABC Investments';
        acc.RecordTypeId = '012b0000000UQ0L';
        insert acc;
        Account acctId = [Select Id From Account Where Name = 'ABC Investments'];
        Contact c = new Contact();
        c.LastName = 'Meier';
        c.RecordTypeId = '012b0000000USN6';
        insert c;
        //Lookup Contact Id
        Contact taskContact = [Select ID From Contact Where LastName = 'Meier'];
        //Create a list for the tasks to be updated
        List<Task> taskList = new List<Task>();
        //Tasks Chuyko
        Task t = new Task();
        t.WhatId = acctId.Id;
        t.RecordTypeId = '012b0000000URMt';
        t.OwnerId = '005b0000001R6YS';
        t.Communication_Type__c = 'Conversation';
        t.Whoid = taskContact.Id;
        insert t;
        //Tasks Petropavlovski
        Task t2 = new Task();
        t2.WhatId = acctId.Id;
        t2.RecordTypeId = '012b0000000URMt';
        t2.OwnerId = '005b0000001TATI';
        t2.Communication_Type__c = 'Conversation';
        t2.Whoid = taskContact.Id;
        insert t2;
        //Tasks Tikhomirov
        Task t3 = new Task();
        t3.WhatId = acctId.Id;
        t3.RecordTypeId = '012b0000000URMt';
        t3.OwnerId = '005b0000001TAgR';
        t3.Communication_Type__c = 'Conversation';
        t3.Whoid = taskContact.Id;
        insert t3;
        //Tasks Ibragimov
        Task t4 = new Task();
        t4.WhatId = acctId.Id;
        t4.RecordTypeId = '012b0000000URMt';
        t4.OwnerId = '005b0000001RKOq';
        t4.Communication_Type__c = 'Conversation';
        t4.Whoid = taskContact.Id;
        insert t4;
        //Tasks Naydennova
        Task t5 = new Task();
        t5.WhatId = acctId.Id;
        t5.RecordTypeId = '012b0000000URMt';
        t5.OwnerId = '005b0000001RKOl';
        t5.Communication_Type__c = 'Conversation';
        t5.Whoid = taskContact.Id;
        insert t5;
        //Tasks Goncharov
        Task t6 = new Task();
        t6.WhatId = acctId.Id;
        t6.RecordTypeId = '012b0000000URMt';
        t6.OwnerId = '005b0000001RKOg';
        t6.Communication_Type__c = 'Conversation';
        t6.Whoid = taskContact.Id;
        insert t6;
        //Tasks Tachennikov
        Task t7 = new Task();
        t7.WhatId = acctId.Id;
        t7.RecordTypeId = '012b0000000URMt';
        t7.OwnerId = '005b0000001TAUk';
        t7.Communication_Type__c = 'Conversation';
        t7.Whoid = taskContact.Id;
        insert t7;
        //Tasks Mitchell
        Task t8 = new Task();
        t8.WhatId = acctId.Id;
        t8.RecordTypeId = '012b0000000URMt';
        t8.OwnerId = '005b0000001RKOv';
        t8.Communication_Type__c = 'Conversation';
        t8.Whoid = taskContact.Id;
        insert t8;
        //Tasks Kotok
        Task t9 = new Task();
        t9.WhatId = acctId.Id;
        t9.RecordTypeId = '012b0000000URMt';
        t9.OwnerId = '005b0000001TAb7';
        t9.Communication_Type__c = 'Conversation';
        t9.Whoid = taskContact.Id;
        insert t9;

Thanks in advance for your help!!!
hi i want two compare two values in a loop for ex my code is
for(String sr : uniqueData){
        list<String> dr = sr.split('~',2); 
        agm = dr[0];
        dvr = dr[1];

here in my uniqueData there are 5 Strings . when ever i enter in to loop iam spliting the String and assigning it to two variables. now my question is if two strings in agm ae same i dont want to print it for ex{if i get teja in first iterator. and also teja in second iterator . i dont want that name }.  how can i compare first agm and second agm

I have a usecase where,
I want to build the SQL query in string format.
and get the result in List.

String skill = 'Skill1';
List<ProfileSkillUser> tempResult = [SELECT User.FirstName, User.LastName, ProfileSkill.Name, EFX_Skill_assessment__c FROM ProfileSkillUser WHERE ProfileSkill.Name like :skill];

In future,
String skill = 'Skill1';
String query = "SELECT User.FirstName, User.LastName, ProfileSkill.Name, EFX_Skill_assessment__c FROM ProfileSkillUser WHERE ProfileSkill.Name like :skill";
List<ProfileSkillUser> tempResult = Execute(query);

How can i achieve this ?

I tried to follow two things,
query = "select * from users where user = '" +
      Request.form("user") + "' and password = '" +
      getSaltedHash(Request.form("password")) + "'";

queryResult = Database.executeQuery(query);

Hi there,

I have a flashing .glow style. I am trying to add criteria which will make it only render when the list sizes in question are greater than 5. I have tried long and hard to find a solution to this on the internet. I was wondering if this was even possible?

I am trying to make it so that if the list, for example AccountsEnquiry was greater than 5 it would trigger the .glow style, if not then it would remain normal.

Thank you in advance for anyone that can point me in the right direction.

This is my visualforce page:

<apex:page sidebar="False" docType="html-5.0" controller="VSDashBoard2" tabStyle="account" >  


    $j = jQuery.noConflict();
 var newWin=null;
 function openLookupPopup(AccountID)
  var url="/apex/DestinyAccount?id=" + AccountID;
  if (window.focus)
     return false;

        animation: flashBg 0.9s;  
        -webkit-animation: flashBg 0.9s alternate infinite;  
     @keyframes flashBg  
       from {  
           border: 3px solid #ff6161;  
       to {  
           border: 3px solid #ffd324;  
     @-webkit-keyframes flashBg /* Safari and Chrome */  
       from {  
           border: 3px solid #ff6161;  
       to {  
           border: 3px solid #ffd324;  
           box-shadow: 0px 0px 50px 3px #e14f1c;  
.activeTab {background-color: #892034; color:White;
.inactiveTab { background-color: #00204E; color:white;
.rich-tabhdr-side-border { background-image: none; }
.rich-tabhdr-side-cell { border-top: none; }

   <vs:importvisualstrap />  
   <vs:visualstrapblock >  
  <apex:tabPanel switchType="client" 
id="AccountTabPanel" tabClass="activeTab"
<apex:tab label="Enquiry" name="EnquiryDetails" id="tabdetails" >
 <vs:row >  
       <vs:column type="col-md-6"> 
                <vs:panel title="Accounts Enquiry" type="info">  
                <span style="color:blue" rendered="{!AccountsEnquiry.size > 3}">
           <vs:well style="text-align:center;">  
              <vs:glyph icon="phone-alt" style="font-size:40px"/>&nbsp;<span style="font-size:54px">{!AccountsEnquiry.size}</span>  
              <p class="text-muted">Outstand Enquiry Accounts</p>  
           <apex:dataTable value="{!AccountsEnquiry}" var="AccEnqu" styleClass="table table-condensed table-hover table-bordered" rows="3">  
                         <apex:column headerValue="Name">  
                 <a href="#" onclick="openLookupPopup('{!AccEnqu.Id}'); return false" >{!AccEnqu.name}</a>
             <apex:column value="{!AccEnqu.Account_Status__c }" headerValue="Status"/>  
             <apex:column value="{!AccEnqu.Account_Inquiry_Date__c}" headerValue="Enquired"/>  
             <apex:column value="{!AccEnqu.Office__c}" headerValue="Office"/>  
           <vs:alert rendered="{!AccountsEnquiry.empty}" type="warning" style="text-align:center">  
             <vs:glyph icon="exclamation-sign"/> No records to display  
       <vs:column type="col-md-6">  
  <vs:panel title="Accounts Presentation Booked" type="primary">
   <div class="glow" rendered="{!AccountsPresentation.size!=0}"> 
         <vs:well style="text-align:center;">  
              <vs:glyph icon="book" style="font-size:40px"/>&nbsp;<span style="font-size:54px">{!AccountsPresentation.size}</span>  
              <p class="text-muted">Outstand Enquiry Accounts</p>  
           <apex:dataTable value="{!AccountsPresentation}" var="accPres" styleClass="table table-condensed table-hover table-bordered" >  

             <apex:column headerValue="Name">  
                 <a href="#" onclick="openLookupPopup('{!accPres.Id}'); return false" >{!accPres.name}</a>
             <apex:column value="{!accPres.Account_Status__c}" headerValue="Status"/> 
                          <apex:column value="{!accPres.Account_Inquiry_Date__c}" headerValue="Enquired"/>  
             <apex:column value="{!accPres.Office__c}" headerValue="Office"/>   
           <vs:alert rendered="{!AccountsPresentation.empty}" type="warning" style="text-align:center">  
             <vs:glyph icon="exclamation-sign"/> No records to display  

<apex:tab label="Presentation booked" name="Account Presentation" id="tabDestinyPresentation" >
        <vs:row >  
       <vs:column type="col-md-6">  
       <vs:panel title="Accounts FollowUp" type="primary"> 
     <div class="glow" rendered="{!AccountsFollowUp.empty}">     
 <vs:well style="text-align:center;">  
  <vs:glyph icon="earphone" style="font-size:40px"/>&nbsp;
  <span style="font-size:54px">{!AccountsFollowUp.size}</span>  
              <p class="text-muted">Outstand Enquiry Accounts</p>  

           <apex:dataTable value="{!AccountsFollowUp}" var="AccFol" styleClass="table table-condensed table-hover table-bordered" rows="3">  
             <apex:column headerValue="Name">  
                 <a href="#" onclick="openLookupPopup('{!AccFol.Id}'); return false" >{!AccFol.name}</a>

             <apex:column value="{!AccFol.Account_Status__c}" headerValue="Status"/>  
                          <apex:column value="{!AccFol.Account_Inquiry_Date__c}" headerValue="Enquired"/>  
             <apex:column value="{!AccFol.Office__c}" headerValue="Office"/>  
           <vs:alert rendered="{!AccountsFollowUp.empty}" type="warning" style="text-align:center">  
             <vs:glyph icon="exclamation-sign"/> No records to display  

        <vs:column type="col-md-6">  
       <vs:panel title="Accounts FollowUp" type="primary"> 

 <vs:well style="text-align:center;">  
              <vs:glyph icon="earphone" style="font-size:40px"/>&nbsp;<span style="font-size:54px">{!AccountsFollowUp.size}</span>  
              <p class="text-muted">Outstand Enquiry Accounts</p>  
           <apex:dataTable value="{!AccountsFollowUp}" var="AccFol" styleClass="table table-condensed table-hover table-bordered" rows="3">  
             <apex:column headerValue="Name">  
                 <a href="#" onclick="openLookupPopup('{!AccFol.Id}'); return false" >{!AccFol.name}</a>

             <apex:column value="{!AccFol.Account_Status__c}" headerValue="Status"/>  
                          <apex:column value="{!AccFol.Account_Inquiry_Date__c}" headerValue="Enquired"/>  
             <apex:column value="{!AccFol.Office__c}" headerValue="Office"/>  
           <vs:alert rendered="{!AccountsFollowUp.empty}" type="warning" style="text-align:center">  
             <vs:glyph icon="exclamation-sign"/> No records to display  

     <vs:row >  
       <vs:column type="col-md-6">  
                <vs:panel title="Tasks" type="primary">  
           <vs:well style="text-align:center;">  
              <vs:glyph icon="tasks" style="font-size:40px"/> &nbsp;<span style="font-size:54px">{!Tasks.size}</span>  
              <p class="text-muted">Tasks due for Today</p>  
           <apex:dataTable value="{!Tasks}" var="task" styleClass="table table-condensed table-hover table-bordered" rows="3">  
             <apex:column headerValue="Subject">  
               <apex:outputLink value="/{!task.Id}">{!task.Subject}</apex:outputLink>  
             <apex:column value="{!task.Status}" headerValue="Status"/>  
             <apex:column value="{!task.ActivityDate}" headerValue="Due Date"/>  
           <vs:alert rendered="{!Tasks.empty}" type="success" style="text-align:center">  
             <vs:glyph icon="ok-sign"/> No records to display  
       <vs:column type="col-md-6">  
                <vs:panel title="Events" type="primary">  
           <vs:well style="text-align:center;">  
              <vs:glyph icon="briefcase" style="font-size:40px"/>&nbsp;<span style="font-size:54px">{!Events.size}</span>  
              <p class="text-muted">Future Office Events</p>  
           <apex:dataTable value="{!Events}" var="Event" styleClass="table table-condensed table-hover table-bordered" rows="3">  
             <apex:column headerValue="Event">  
               <apex:outputLink value="/{!Event.Id}">test</apex:outputLink>  
             <apex:column value="{!Event.subject}" headerValue="Subject"/>  
             <apex:column value="{!Event.ActivityDate}" headerValue="Date"/>  
           <vs:alert rendered="{!Events.empty}" type="warning" style="text-align:center">  
             <vs:glyph icon="exclamation-sign"/> No records to display  
   <iframe id="iframeID" src="/01Z90000000AWM8"/>
Irina AristovaFormat date function returns a wrong dateI converted Date time to string in Apex using format function:
DateTime yesterdayDate = Date.today().addDays(-1);
String formattedDate = yesterdayDate.format('MM/dd/yyyy');

The result is:
USER_DEBUG|[24]|DEBUG|2015-05-05 00:00:00
I expected to be the same date: 05/05/2015, but it returned 05/04/2015 which is one day earlier
I need to convert date to a string but I am not able because it's returning the wrong date

The user object for me it's set up to:
Time Zone is (GMT-04:00) Eastern Daylight Time (America/New_York)
Locale: Enflish(United States)
Default Time Zone for company is the same as mine: (GMT-04:00) Eastern Daylight Time (America/New_York)


I have a list which adds the list to another list.

In one use case, tempResult gets 1 row at a time.
searchResult will have 5 rows

public with sharing class Controller {

    public List<ProfileSkillUser> searchResult{get;set;}

    public Controller() {
        List<ProfileSkillUser> tempResult;
        searchResult = new List<ProfileSkillUser>();
        for(integer i=0; i<5; i++){
            tempResult = new List<ProfileSkillUser>();
            tempResult = [SELECT User.FirstName, User.LastName, ProfileSkill.Name
                              FROM ProfileSkillUser WHERE ProfileSkill.Name =:i ORDER BY UserId ];

this is doing a OR kind of operand.

I now need to make a AND kind of operand.
 I am not able to insert records itno custom object. See the below code.
(My Requirement is when i click on custom button need to insert values in another object)


var callout = "" + sforce.apex.execute("MyWebservice","myFunction",

    if (callout == 'OK') { 
    alert("Webservice call was ok."); 

else { 
    alert("Webservice call failed!"); 

global without sharing class MyWebservice {

    WebService static String myFunction(String param1,string param2) {

        if (String.isNotBlank(param1)) {

            try {
          Segment2__c Segment= new Segment2__c();
            Segment.Event__c= param1;
            Segment.Member_Name__c= param2;
             insert Segment;        
               return 'OK';    
            catch (Exception e) {
                return 'ERROR';
        else {
            return 'ERROR';

I am calling myFunction from script I am getting responce OK But record is not inserting in the object.

Any one please respond quickly 

Thanks in advance. 
Hi ,

I have a question related to the "after update trigger" execution order when a DML update is performed on the same object. :
Lets says there are two contacts C1 and C2 and I need to update the field F2 on C2 based on some values in F1 on C1.

I check logic in first FOR loop and update F1 on C1 (upon a update trigger) then check few other logic and update F2 on C2 .

I know its not best practice to use after trigger for updating same object on which the trigger is invoked but in my case I dont have an option. Also, all i need to understand, how would after tirgger behave if there are 2 update statements for an object in the after update trigger of the same object.

So if update DML operation happens on C1(contact) first then will it  retrigger the "after update trigger" before continuing to the rest of the code  or will it continue on the second for loop and run the DML update operation on C2(contact) before recurrsively calling the same trigger again due to after update event? 

the pusedo code for the same is something like below:

trigger trg_contact_update on contact (before update) {

for  ( contact c : trigger.new ){
  doing some thing ...
    contactMap.add( c.id, c);

map< id, contact> c1Contact = new map<id,contact> ([select id , F1 where id in :contactMap.keys()]) 
for ( contact c1: c1Contact) {
  //do something
 String oldF1value = c1.F1;
c1.F1 = ' ';

if( c1List.size()> 0)
update c1List; 

for ( contact c2: c2Contact) {
  //do something
if(c1.F1 = ' ')
c2.F2 = oldF1value ;

if( c2List.size()> 0)
​update c2List; 

Please do not check for logic or issues in the above code, my intention is to understand how "after update trigger " behave in the case when there are 2 update DML operation. Please share your thoughts on the same.
Hi All,

User-added image

I need to uplaod more than 100 contacts and Accounts like the above CSV file format,
here 2 accounts and 13 contacts iam uploading and also duplicate not allowed for Contacts as well as Account
this is working fine when iam uploading 30 records,
But i am getting following error while uploading more than 30 records

System.LimitException: Too many SOQL queries: 101

below the code i used:
public PageReference UploadAction() {
               //Read the CSV Rows using split method
            filelines = nameFile.split('\n');        
    for (Integer i=1;i<filelines.size();i++)
                String[] inputvalues = new String[]{};
                  inputvalues = filelines[i].split(',');   
                 Contact cnt= new Contact();
                 Account Ac=new Account();
                  List<Account> al= new List<Account>();
                 cnt.FirstName= inputvalues[0];
                 cnt.LastName= inputvalues[1];
                al=[Select id,Name from Account Where name=:Ac.Name];                 
                 insert Ac;
                 List<Account> Acl= new List<Account>();
                 Acl=[Select id, name from Account Where name=:Ac.Name];
                cnt.Email= inputvalues[3];
                cnt.Phone= inputvalues[4];    
                List<contact> cl= new List<contact>();
                cl=[select id, email from contact where email=:inputvalues[3] and account.name=:inputvalues[2]];
                 cnt.AccountName__C=  inputvalues[2];
            System.Debug('-------------count value----'+ Count);
    insert contactInsert;
        return null;

  • April 29, 2015
  • Like
  • 0

I am working through the Apex Workbook for Spring 15.

I have followed each step but seem to get the below error message when executing the request:

Line: 1, Column: 19
Constructor not defined: [Fridge].<Constructor>(String, Integer)

I have the following code within the Class:

public class Fridge {
private String modelNumber;
private Integer numberInStock;

    public void updateStock (integer justSold) {
        numberInStock = numberInStock - justSold;
    public void setModelNumber (String theModelNumber){
        modelNumber = theModelNumber;
    public String getModelNumber (){
        return modelNumber;
 public Fridge() {
 modelNumber = 'XX-XX';
 numberInStock = 0;
 public Fridge(String theModelNumber, Integer theNumberInStock) {
 ModelNumber = theModelNumber;
 numberInStock = theNumberInStock;

Can anyone help me out please?


I have a VF page which lists a repeating block of data (a custom object). I can add a new object or delete one. When I add a new one the page displays the newly added object on return from the remote call. When I delete an object however, it does not seem to refresh the page and remove the deleted one.

How do I get it to refresh the page after having deleted something on the page?

This is what my page looks like. When I click on the 'Remove Call Cycle Event' button it runs the Javascript below the image, which calls the @RemoteAction in my controller. What do I need to do for it to remove the block I clicked the button on?
User-added image
In my VF page:
            jCC$(".remCCA").click(function() {
                var ccaId = this.id;
                if(ccaId != ''){
                    CallCycleController.RemoveCallCycleActivity(ccaId, function(result, event){
                        var foo = result;
                        alert('CallCycle Activity has been deleted');
                return false;

In my Controller:
  public static void RemoveCallCycleActivity(string remId){
    CallCycleActivity__c delCCA = [Select Id, ActivityId__c From CallCycleActivity__c Where Id=:remId];
    delete delCCA; 

I hope this is an easy one. I was trying deploy a change set and ran in to the following error when trying to validate:

TEST_MassTaskController.myUnitTest(), Details: System.Exception: Assertion Failed: Same value: null Class.TEST_MassTaskController.myUnitTest: line 110, column 1

Here is the test code:

private class TEST_MassTaskController {

    static testMethod void myUnitTest() {
        //Create Accounts
        Account account1 = new Account();
        account1.Name = 'Test_Account_01';
        insert account1;
        Account account2 = new Account();
        account2.Name = 'Test_Account_02';
        insert account2;        
        //Create Contacts
        Contact contact1 = new Contact();
        contact1.LastName = 'Test_Contact_01';
        insert contact1;
        Contact contact2 = new Contact();
        contact2.LastName = 'Test_Contact_01';
        insert contact2;
        //Get a profile from SFDC
        Profile profile = [select Id from Profile limit 1];
        //Create a user
        User user = new User();
        user.Username = 'Test_user_name@test.com';
        user.LastName = 'Test_last_name';
        user.ProfileId = profile.Id;
        user.Alias = 'tst';
        user.Email = 'Test_email@email.com';
        user.CommunityNickname = 'Test_nick_name';
        user.TimeZoneSidKey = 'GMT';
        user.LocaleSidKey = 'en_US';
        user.LanguageLocaleKey = 'en_US';
        user.EmailEncodingKey = 'ISO-8859-1';
        insert user;
        //Simulate the page for What Id
        PageReference pPageReference = Page.Mass_Task_Action;
        MassTaskController controler = new MassTaskController();
        System.assertEquals(controler.showWhoId, true);

        //Simulate the page for Who Id
        pPageReference = Page.Mass_Task_Action;
        controler = new MassTaskController();
        System.assertEquals(controler.showWhoId, false);
        Pagereference pageRef = controler.save();
        System.assertEquals(pageRef, null);
        controler.task.OwnerId = user.Id;
        controler.task.Subject = 'Test_Subject';
        controler.task.Status = 'Completed';
        controler.task.Priority = 'High';
        //Set the reminder
        controler.task.IsReminderSet = true;
        controler.contact.Birthdate = Date.today();
        controler.reminderTime = '23:30';
        //Send Email notification
        controler.sendNotificationEmailCheckBox = true;
        pageRef = controler.save();
110   System.assertNotEquals(pageRef, null);

I have searched these boards all day today and found no one referencing the System.assertNotEquals. Can anyone explain what that is stating? Also, can you help me to determine where I am missing something? Let me know if you need the Apex Class this is referencing.


Hi All, 

I have a rather neat controller with a visual force page that is called on button press to collect a signature. The end result is a file called "Signature.png" and is attached to the Notes and Attachments section on the contact object.

My question is: How can I have a visualforce page within the contact layout which would display the signature picture?

Reason is : to create a pdf of the contact page with their signature at the bottom

Currently my Controlelr for creating the signature attachment:
public with sharing class ehsSignatureExtensionController {

private final Contact ehs;

public ehsSignatureExtensionController(ApexPages.StandardController controller) {
    ehs = (Contact)controller.getRecord();

@RemoteAction public static RemoteSaveResult saveSignature(Id ehsId, String signatureBody) {
    Attachment a = new Attachment(ParentId=ehsId, name='Signature.png', ContentType='image/png', Body=EncodingUtil.base64Decode(signatureBody));
    Database.saveResult result = Database.insert(a,false);
    RemoteSaveResult newResult = new RemoteSaveResult();
    newResult.success = result.isSuccess();
    newResult.attachmentId = a.Id;
    newResult.errorMessage = result.isSuccess()?'':result.getErrors()[0].getMessage();
    return newResult;

public class RemoteSaveResult {
    public Boolean success;
    public Id attachmentId;
    public String errorMessage;

public pageReference cancel(){
    pageReference page = new PageReference('/'+ehs.id);
    return page;

My VF Page:
<apex:page docType="html-5.0" standardController="Contact" extensions="ehsSignatureExtensionController" sidebar="false" showHeader="false">

<script>var $j = jQuery.noConflict();</script>
<apex:stylesheet value="{!URLFOR($Resource.jquerymobile,'/jquerymobile/jquery.mobile-1.3.2.min.css')}"/>

<apex:includeScript value="{!URLFOR($Resource.jquerymobile,'/jquerymobile/jquery.mobile-1.3.2.min.js')}"/>

<canvas id="signatureCanvas" width="400" height="250" style="border: 1px solid black;"/>  
<apex:includeScript value="/soap/ajax/28.0/connection.js"/>


sforce.connection.sessionId = "{!$Api.Session_Id}";
var canvas = document.getElementById("signatureCanvas");
var context = canvas.getContext("2d");
var mouseButton = 0;
var lastX = lastY = null;
var ehsId = '{!Contact.Id}';

function saveSignature() {

    var image = canvas.toDataURL().split(',')[1];

function handleResult(result,event) {
    if(result.success) {
    } else {
        alert('Error: '+result.errorMessage);

function handleEvent(event) {
    if(event.type==="mousedown"||event.type==="touchstart") {
        mouseButton = event.which || 1;
        lastX = lastY = null;
    if(event.type==="touchcancel" || event.type==="touchcancel" || event.type==="mouseup") {
        mouseButton = 0;
        lastX = lastY = null;
    if((event.type==="touchmove" || event.type==="mousemove") && mouseButton) {
        var newX, newY;
        var canvasX = 0, canvasY = 0, obj = event.srcElement || event.target;
        do {
            canvasX += obj.offsetLeft;
            canvasY += obj.offsetTop;
        } while(obj = obj.offsetParent);
        if(event.targetTouches && event.targetTouches.length) {
            newX = event.targetTouches[0].clientX - (canvasX/2);
            newY = event.targetTouches[0].clientY - (canvasY/2);
        } else {
            newX = event.offsetX;
            newY = event.offsetY;
        if(!lastX && !lastY) {
            lastX = newX;
            lastY = newY;
        } else {
            lastX = newX;
            lastY = newY;
    if(event.type=="touchmove" || event.type==="mousedrag" || (event.type==="selectstart" && (event.srcElement||event.target)===canvas)) {
        return false;



<apex:form >
    <apex:commandButton value="Save Signature" onclick="saveSignature();return false;" styleClass="button"/>
    <apex:commandButton action="{!cancel}" value="Exit"/>


My button on the contact page:

var id = '{!Contact.Id}'; 
var url = "/apex/Signature?id=" + id + '&src=page'; 
var features = 'directories=no,menubar=no,titlebar=no,toolbar=no,width=450,height=460'; 
win = window.open(url,'', features); 

I am using JQuery Mobile standard library. 
Im using salesforce java  api-core 1.0.3 and im trying to clear a field using the sObject apis.
I tried to use setField with null or empty string or to use removeField with no success.
What is the way to clear a custom field value using java APIS?
Can we deploy managed package directly to sandbox using eclipse or some other tool ?
Hi Friends ,

I am using visualforce map components ,its not displaying business names over map . Here is my vf page .
<apex:page standardController="OffersToContacts__c">
    <apex:pageBlock >
        <apex:pageblockSection >
            <apex:map width="1250px"  zoomLevel="16" height="700px" mapType="roadmap" center="{latitude: {!OffersToContacts__c.Offer__r.Venue__r.Geo_Location__Latitude__s}, longitude: {!OffersToContacts__c.Offer__r.Venue__r.Geo_Location__Longitude__s}}">
                <apex:mapMarker position="{latitude: {!OffersToContacts__c.Offer__r.Venue__r.Geo_Location__Latitude__s}, longitude: {!OffersToContacts__c.Offer__r.Venue__r.Geo_Location__Longitude__s}}" icon="{! URLFOR($Resource.VenueLocImage,'images.png') }" />
                <apex:mapMarker position="{latitude: {!OffersToContacts__c.Location__Latitude__s}, longitude: {!OffersToContacts__c.Location__Longitude__s}}" />
Any help would be  much appreciated !
Greetings !!
I am Ashish Sharma , I am a certified salesforce developer /consultant .
I am in salesforce ecosystem from last 4 years .
My services are below.
  1. Design Solution on force.com
  2. Develop visualforce  pages ,apex classes ,apex triggers ,Integrations and any customizations.such as reports/dashboards initial sales ,service setup etc .
  3. Support to existing implementations on adhoc and hourly basis .
My Salesforce Certifications are follows.
  1. Certified developer 401
  2. Certified App builder
  3. Certified ADM 201
  4. Certified sales cloud
I have worked on nearly 5 end to end enterprise applications and nearly 200 small projects/tasks in 4 years of duration.
I have worked on many integration projects where one of them is salesforce to citrix integration .
I would love to discuss opportunity to work with you .
Here are my profile links
LinkedIn : https://ae.linkedin.com/in/ashish-sharma-3b3b4a55
Salesforce Blog : http://ashishsharmadevsfdc.blogspot.ae/
Salesforce Discussion Boards : https://developer.salesforce.com/forums/ForumsProfile?userId=005F0000004uUXfIAM&communityId=09aF00000004HMGIA2
Please let me know if we can futher discuss your requirements.
Email :ashish.sharma.devsfdc@gmail.com
Skype : ashish.extentor
I am previewing my lighting component ov vf page ,below is the code for same.
<apex:page standardController="Opportunity" standardStylesheets="false" showHeader="false" sidebar="false">
    <!-- Include a JavaScript file in your Visualforce page -->
    <apex:includeScript value="/lightning/lightning.out.js" />
    <div id="lightning" />

    //Tell your Visualforce page to use ExposeVF Lightning app
        var opportunityId = "{!$CurrentPage.parameters.id}";
        $Lightning.use("c:HelloComponentApp", function() {
            // Write a function that creates the component on the page
          {"opportunityId" : opportunityId},
          function(cmp) {
            // do some stuff


I am recieving below error.
Something has gone wrong. info.$component$.$isValid$ is not a function. Please try again.

Any help would be appreciated .
Hi All,

Is there any way to get information of subscribed reports by all users in Apex code?

Any suggestion would be appreciated.

We are looking for someone who can provide part-time \ occasional support and development for Apex and Marketing Cloud.

The company is London based with approx. 200 users internationally using Sales and Marketing Cloud with a large proportion of platform licenses.

There is a full time Salesforce administrator in post and myself providing part-tme (mainly remote) freelance resource for administration, click-based development and requirement gathering. There is an existing Rest API interface for the website, existing Apex code and a new Marketing Cloud implementation which we need assistance with on an ongoing basis, with someone undertaking a few days a month. 

If this would be of interest, please respond with contact information so I can provide further details.

Our company just acquired another company that uses Salesforce.  Each organization has 11 users (22 total users).  Both users from both accounts will need to be merged into one.  We need help in transitioning all of the information without losing any key pieces, emails, accounts, notes, contracts, etc. 

Please note your experience with this procedure, what I need to expect in terms of how much time it will take, and how much we can expect to pay for this service.  Thank you!

We are a comprehensive Benefits company looking for a Salesforce Developer to help build out and complete our migration from legacy systems.
The primary goals include:
Migrate existing GoldMine, Pension Portal and Call Center functions into Salesforce
Help migrate existing GoldMine, Pension Portal and Call Center Data into Salesforce
Data integration with existing Relius solution
Build custom Reports & Dashboards

We are looking for a fresh, eager, and passionate Salesforce developer to support a growing family of companies in the Philadelphia area. We are flexible when it comes to your location. Local or remote will work. This is a project based job, and we are looking for someone with the following skills:
  • An understanding of all major functional areas of Salesforce.com
  • Including reports and dashboards.
  • Data imports (using data loader or other tools).
  • General problem-solving skills in Salesforce.com
  • Project exposure including configuration, integration, implementation and customization
  • Salesforce Developer Certification would be advantageous
Be an implementer: you’ll perform hands-on technical implementation, with a focus on delivering functional solutions on the Salesforce.com platform.
Be an owner: you’ll customize and implement profiles, roles, security settings, sharing rules, applications, custom objects, custom fields, page layouts, workflow, validation rules, approvals, etc.
Be a support system: you’ll address support issues and work collaboratively with our CRM Systems Manager and development teams.
Be a builder: you’ll design, document, and implement projects that leverage the Salesforce.com toolset and specific initiatives to improve data hygiene and security.
Be a documenter: you’ll document best practices in release management, SFDC data management, and ongoing improvements to Funding Circle’s CRM environment.
Be a teacher: be generous with your time and expertise to teach stakeholders and our fellow Funding Circlers how to answer their own questions with tools you build.
Our ideal teammate has:
4+ years of experience with enterprise Salesforce implementations, testing & support.
experience with 3rd party applications (Docusign/Conga).
experience with Apex, VisualForce, SOQL/SOSL, Javascript, HTML, and CSS.
Salesforce.com Administrator Certification, Salesforce Developer (Dev 401) Certification.
a self-starter mentality with an enthusiasm to work in a fast-paced, team oriented start-up environment and the ability to maintain poise under pressure.

There is a field called "Display_LastModifiedDate" on Orders. I am trying to retrieve orders with "Display_LastModifiedDate" between 175th -185th days back from today dynamically. I cannot hardcode 175th and 185th dates because if I query it after a week the 175th and 185th dates change. Please guide me.


I am trying to write some SOQL so that I can perform some bulk operations on opportunties. However, whenever I run this SOQL I get an error: "unexpected token: AND"

Here is the SOQL:
String query2 = 'SELECT Id FROM Opportunity WHERE NOT StageName LIKE \'%'+'closed'+'%\' AND division__c = \'IT Solutions\'';

Here is the System.debug output:
SELECT Id FROM Opportunity WHERE NOT StageName LIKE '%closed%' AND division__c = 'IT Solutions'

I am just unsure what is wrong with this SOQL, seems I am escpaing the single quotes correctly... 

Thank you!
I am looking for a developer to help out with a couple of small projects.  Fairly simple apex triggers and a few dynamic visualforce pages that include several charts.  I have started both projects but need someone to help get the work done using best practices.
  • April 28, 2017
  • Like
  • 0
Hi all, we are looking for somebody to help us with code that would allow us to generate a marketing package from objects/custom fields that we have already created in APTO for Salesforce. Basically, we are in commercial real estate and would like this to be available on our 'Proposals' or pitches. For a proposal, we link/tie 'On-Market' listings and 'Sold' comparable properties (both of which are already in our database), and we would like them to then export or populate our excel template (which is also existing) including property pictures. We have achived a work-around using S-Docs, but had to mimc our template since they dont allow you to upload one. We ultimately just need to tie together the information and properties from our Proposal, to our excel proposal presentation template. Can anyone help or point me in the right direction? Any help is appreciated! Thank you very much!
I'm looking for a salesforce partner that has experience in cloning salesforce instances. Currently, we have 1 organization with 3 users. We want to split the organization into 3 different organizations and one user per organization but maintain all custom objects, fields etc. 

The manner in which we would decide which Data goes with which organization is easy enough as we have an ownerid to tie the object/contact/account/company to the user. 

I would consider doing this myself but unsure of the process. 

Any ideas/suggestions?
Our company is looking for a W9 SF consultant to help with coding, VisiualForce and other backend fuctions.
This work would be for a few hours a month. Please contact me if you are interested. Thank you!
I am a program manager of a financial coaching program at a Points of Light, a nonprofit based in Atlanta.
I’m looking for a Salesforce developer to update 2 surveys in a custom built portal. The surveys are created in Click Tools, mapped back into Salesforce and then linked to auto population mechanisms that feed into Conga report objects.
Please contact if you are interested. I have an admin manual that gives an overview of the portal.
Kind regards,
Sherria Saafir
Manager, Economic Opportunity
Points of Light
600 Means Street NW, Suite 210, Atlanta, Georgia 30318
t: 678.399.2487
email: ssaafir@pointsoflight.org
I have a project to build a content portal using Communities and need a contractor ideally in Southern California. The site will require 6-8 templates and will be about 100 pages.
I need to overlay some custom object data on a visual force page using the new maps VF tags. Small job, just needing some short help on it. If interested in please respond. Will compensate by the hour. 
We are looking for a part-time offshore developer to create 15-20 new Visual Force pages for a startup company.
Details will be provided later.  You must have 2-3 years of hands-on programming experience in Apex, VFP, Java Script, SOQL, etc.  Must sign an NDA (non-disclosure agreement).  Please contact us with your hourly rate and email address.

I need a salesforce developer to help me integrate Salesforce with Boberdoo. I need to be able to send lead information in one of my Salesforce Campaigns to my Boberdoo campaign. I understand this can be accomplished via API, though I do not have the exprerience to do so myself. Successful work will lead to future projects, if interested. 

Thank you

Is it possible to display PHP page in salesforce using Iframe probably without herko? which display data in XML and HTML formate. This PHP page is hosted inside corporate firewall and can't be accessed outside the firewall
  • April 23, 2015
  • Like
  • 1