• Kiran Kurella
  • SMARTIE
  • 625 Points
  • Member since 2008
  • CEO
  • Kurella Consulting LLC


  • Chatter
    Feed
  • 22
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 109
    Replies
When a user clicks on "New Event" from a lead, I would like to populate the campaign field on Events with the campaign that is listed on the Lead Record.  I'm running into an error where it says "Variable does not exist: whoid".  I can't seem to figure out why it would be complaining about whoid when it shows up under Workbench for events.

public with sharing class EventTriggerHandler 
{
	private boolean triggerIsExecuting = false;
    private integer batchSize = 0; 

 	public boolean isTriggerContext{
        get { return triggerIsExecuting;}
    }
    
    public boolean isVisualforcePageContext{
        get { return !isTriggerContext;}
    }
     
    public boolean isWebServiceContext{
        get { return !isTriggerContext;}
    }
    
    public boolean isExecuteAnonymousContext{
        get { return !isTriggerContext;}
    }

  	public EventTriggerHandler(boolean isExecuting, integer size){
    	triggerIsExecuting = isExecuting;
    	BatchSize = size;
  	}
    	
   	public void UpdateLastCampaignActivityOnEvents(Event[] newEvent)
  	{
  		Set<Id> whoIDs = new Set<ID>();
  		for(Event CurrentEvent : newEvent) 
    	{
    		WhoIds.add(CurrentEvent.whoid);
    	}
    	
    	if (whoIDs.size() > 0 )
    	{
    		list<Lead> CurrentLeads = [Select ID, Eloqua_Campaign_Name__c From Lead where ID IN :WhoIDs];
    		
    		map<id,Lead> Leads = new map<id,Lead>();
    		
    		if (currentLeads.size() > 0 )
    		{
    			for (Lead currentlead : currentleads)
    			{
    				Leads.put(currentLead.ID, currentLead);
    			}
    			
    			for(Event CurrentEvent : newEvent) 
		    	{
		    		Lead LeadLookup = Leads.get(CurrentEvent.WhoID); 
		    		if (LeadLookup <> null)
		    		{
		    			CurrentEvent.Last_Campaign_Activity__c = LeadLookup.Eloqua_Campaign_Name__C; 
		    		}
		    	}
    		}
    	}   	

  	}
 	
  	public void onBeforeInsert(Event[] newEvent)
  	{
  		UpdateLastCampaignActivityOnEvents(newEvent);
   	}
   
  
    /*
    @future public static void onAfterInsertAsync(Set<ID> newEventIDs){
    	
    }
    */
 	/*
 	public void OnAfterInsert(Event[] newEvents) {
 		
 		
 	}
 	*/
 	/*
 	public void onBeforeUpdate(Event[] oldEvent, Event[] updatedEvent, Map<ID, Event> oldEventMap) {

    }
    */
 	/*
    public void onAfterUpdate(Event[] oldEvent, Event[] updatedEvent, Map<ID, Event> oldEventMap) {
    		
    }
    */
  	/*  
    @future public static void onAfterUpdateAsync(Set<ID> updatedEvent){
    	
    }
    */
    /*
    public void onBeforeDelete(Event[] EventToDelete, Map<ID, Event> EventMap){
        
    }
    */
    /*
    public void onAfterDelete(Event[] deletedEvent, Map<ID, Event> EventMap){
    			
    }
    */
    
    /*
    @future public static void onAfterDeleteAsync(Set<ID> deletedEvent){
        //to make this work like the on after delete you need to do a select statement into 
        //a list where ID in :deletedOpportunitySplits, this would recreate the deletedOpportunitySplits list
        //from there the code would work the same.
    }
    */
    
    /*
    public void onUndelete(Event[] restoredEvent){
        
    }
    */ 
}


I have a trigger I want to update a related field in the Lead Object To Store the Related Contact based on an email match. 

 

trigger LeadTrigger on Lead (before insert, before update, after insert, after update) 
{	
	if(Trigger.isBefore)
	{
        List<String> leadEmails = new List<String>();
    	for(Lead lead:Trigger.new)
    	{
        leadEmails.add(lead.Email);
    	}

    	List<Contact> contacts = [SELECT id, Unique_Email__c FROM Contact WHERE Email IN :leadEmails ];

    	Set<String> contactEmails = new Set<String>();
        Set<String> contactID = new Set<String>();
        for(Contact contact:contacts)
        {
            contactEmails.add(contact.Unique_Email__c);
            contactEmails.add(contact.id);
        }
    
        for(Lead lead:Trigger.new)
        {
            if(contactEmails.contains(lead.Email)){

// This is where i am having the problem Once i have the set
                lead.Contact__c = contactID.id;
            }
    	}
        
	}
	
	else
	{
        //gonna do something else here
	}
}

 So the issue is once I have the set I cant seem to get it to assing the contact to the Lookup field in the Lead object I get an error saying the initial term of the field expression must be an Sobject Set <String>

 

Not sure i udnerstand what i am doing wrong any help would be appreciated

Apex Controller:
=====================

public with sharing class ApexButtonGetDist{
    public static Opportunity theOpportunity = new Opportunity();
    public static Opportunity theOpportunity2 = new Opportunity();
    public static Account getDistributor = new Account();
    
    public ApexButtonGetDist(ApexPages.StandardController stdController){
       theOpportunity = (Opportunity)stdController.getRecord();  
    }
    
    public PageReference doMyApexLogic() {
        theOpportunity2 = [SELECT ID, Name, Distributor_Name__c,Dist_street__c,Dist_City__c,Dist_State__c,Dist_PostalCode__c from Opportunity where Id = :theOpportunity.Id];
        getDistributor = [SELECT ID, Name, BillingStreet,BillingState,BillingCity,BillingPostalCode,SourceCode__c from Account where Id = :theOpportunity2.Distributor_Name__c];
        theOpportunity.Dist_street__c = getDistributor.BillingStreet;
      theOpportunity.Dist_City__c = getDistributor.BillingCity;
      theOpportunity.Dist_State__c = getDistributor.BillingState;
      theOpportunity.Dist_PostalCode__c = getDistributor.BillingPostalCode;        
      theOpportunity.Distr_SourceCode__c = getDistributor.SourceCode__c;        
        update theOpportunity;
        return new PageReference('/' + theOpportunity.ID);
    }
}

Test Class
@isTest
private class ApexButtonGetDistTest {
      
        static testmethod void testApexButtonGetDist(){
        
           Account acc = new Account (Name = 'test');
           
           insert acc;
            
           Opportunity opp = new Opportunity(Name = 'Test opp',
           StageName = 'Test Stage',
           CloseDate = date.today());
           insert opp;
           
        ApexPages.StandardController controller = new ApexPages.StandardController(opp);
        ApexButtonGetDist ABGD = new ApexButtonGetDist(controller);
        ABGD.doMyApexLogic();
       
       }           
}

The code Coverage is 53% So How do I increase the code coverage. The code below was not covered.

 theOpportunity.Dist_street__c = getDistributor.BillingStreet;
      theOpportunity.Dist_City__c = getDistributor.BillingCity;
      theOpportunity.Dist_State__c = getDistributor.BillingState;
      theOpportunity.Dist_PostalCode__c = getDistributor.BillingPostalCode;        
      theOpportunity.Distr_SourceCode__c = getDistributor.SourceCode__c;        
        update theOpportunity;
        return new PageReference('/' + theOpportunity.ID);
        
       

 I'm getting the following error on this line of code:  

Save error: Unexpected token: 'AND'

 

List<Task> newestTask = new List<Task> ([SELECT id, ActivityDate, AccountId FROM Task 													WHERE Owner_Matches_Account_Owner__c AND IsClosed AND ID in :ids									ORDER BY ActivityDate DESC LIMIT 1]);

 I know it must be obvious, but I can't figure out what's wrong with the multiple clauses in the WHERE section?  Any ideas?

Hello All,

 

I currently have a working workflow formula as follows:

 

IF(Product2.Name = "13-Credits" && Quantity = 1, 13, 
IF(Product2.Name = "13-Credits" && Quantity = 2, 13 * 2, 
IF(Product2.Name = "13-Credits" && Quantity = 3, 13 * 3, 

)))

 

I know I can either keep this formula as is or use a Case function. However, if I need to 100 different Quantity values, this will require me to have 100 different lines on the formula for each Quantity value. Even worst if I have 10 different Product2.Name requiring 100 different Quantity variations, the number of lines in this formula can easily = 10 * 100 = 1000 lines!

 

Is there any way I can reduce the number of lines in the this formula? 

 

Please respond with specific working formula examples.

 

Thanks,

Below is a class that has a list of all records in an object within a pageblocktable. Inline edits are enabled so I can update the records from this table if I like. I am trying to get a save button functioning that will save the entire list when I click it.

 

Right now when I click save, the data dissapears and does not persist. Please help!

 

Controller Class:

Public class listorgs  implements iterator<org__c>{
        public static List<org__c> newlist {get; set;}
        Integer i {get; set;}
        public ApexPages.StandardController listorgs {get; set;}
        public listorgs(ApexPages.StandardController controller) {
            listorgs = controller;}

        
        public listorgs(){
            newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c , Type__c, Pod__c, org_id__c
                       from org__c order by type__c asc];
            i = 0;
                }
        Public boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Public Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
        public string page{get;set;}
        public string openpageurl {get;set;}
                
        public void onload()
        {
            page = '';
            openpageurl = '';
        }
        
        public pagereference redirect()
        {
           if( page == 'login')
            {
                openpageurl = 'http://google.com';
            }
            return null;
        }
    public pagereference save(){
                    newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c , Type__c, Pod__c, org_id__c
                       from org__c order  by type__c asc ];
            update newlist;
            return null;
            
        }
            
}

 Visualforce page:

<apex:page controller="listorgs" sidebar="false">

    <apex:form >
    
        <Apex:pageblock >
          <apex:pageblockButtons >
            <apex:commandButton action="{!Save}" value="Save"/>
            </apex:pageblockButtons><apex:inlineEditSupport />
        <br/>
        <br/>
            
            <apex:pageblockTable value="{!newlist}" var="obj">
           
               <apex:column >
                   <apex:commandButton onclick="window.open('{!obj.LoginURL__c}')" value="Login" reRender="loginhome">
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
                
                    

                
                <apex:column headerValue="Username" >
                    <Apex:outputfield value="{!obj.name}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Type" >
                    <Apex:outputfield value="{!obj.Type__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Description">
                    <Apex:outputfield value="{!obj.Description__c}"/>
                
                </apex:column>
                
                <apex:column headerValue="Org ID">
                    <Apex:outputfield value="{!obj.Org_ID__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="POD">
                    <Apex:outputfield value="{!obj.POD__c}"/>
                    
                </apex:column>    
                    
                
                <apex:column headerValue="HRM Installed?">
                    <Apex:outputfield value="{!obj.HRM_Installed__c}"/>
                    
                </apex:column>
                
            </apex:pageblockTable>
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 Thanks for the help!!

I have been working with this trigger for some time and just can't seem to get it to stop adding mutliple records so I am resorting to the boards!

 

I am just trying to create a simple trigger on OpportunityLineItem that creates a custom object record when certain fields are updated. I am sure that I am using Trigger.old & Trigger.new in the wrong way. When I make certain changes- two records are inserted instead of one.

 

Could someone tell me what I am doing wrong?

 

trigger Itemupdated on OpportunityLineItem (before update) {

 

//List to hold LineItemHistory
List <Oppty_Line_Item_History__c> insertHIST = new List <Oppty_Line_Item_History__c>();
Oppty_Line_Item_History__c IH;

for (OpportunityLineItem o: Trigger.new) {

OpportunityLineItem oldoli = Trigger.oldMap.get(o.ID);
if (o.site__c != oldoli.site__c||o.fixed_Variable__c != oldoli.fixed_Variable__c||o.UnitPrice != oldoli.UnitPrice||
o.quantity != oldoli.quantity||o.Modification_Type__c != oldoli.Modification_Type__c)
{



IH= new Oppty_Line_Item_History__c ();
IH.Action_Initiated_by__c=o.lastmodifiedbyId;
IH.Action_Date__c=o.lastmodifieddate;
IH.Action__c = 'Product Updated';
IH.Oppty_Line_Item_id__c = o.id;
IH.Opportunity__c = o.OpportunityId;
IH.Product_Name__c=o.Product_Name_in_TEXT__c;
IH.Oppty__c=o.opptytrigger__c;
IH.Line_Item__c=o.Line_Item_Id__c;
IH.Product_Family__c = o.Product_Family__c;
IH.Site__c=o.Site__c;
IH.fixed_Variable__c=o.fixed_Variable__c;
IH.Discount__c=o.Discount__c;
IH.Modification__c=o.Modification__c;
IH.Modification_Type__c= o.Modification_Type__c;
IH.Quantity__c=o.Quantity;
IH.Sales_Price__c = o.UnitPrice;
IH.Total_Price__c = o.Total__c;

insertHIST.add(IH);

}



//once loop is done, you need to insert new records in SF
//DML operations might cause an error, so you need to catch it with try/catch block.
try {
insert insertHIST;
}
catch (system.Dmlexception e) {
system.debug(e);
}

 

 

}}

 

Hello,

 

I need some help with incorporating exception handling (try/catch) on my code below.  I have a trigger that auto updates the stage on the Opportunity to "Feasibility", when a Feasibility (custom object) record is created. We have a validation rule on the Opportunity that all the required fields will need to be filled in before you can change the Opportunity Stage to "Feasibility".  How can I update the dml error message to "Fill in all required fields on the Opportunity" so that our user doesnt see this long text.  

 

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger OpptyStageUpdate_Feasibility caused an unexpected exception, contact your administrator: OpptyStageUpdate_Feasibility: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 006J0000007V2QeIAK; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Field is required.: [Budget__c]: Trigger.OpptyStageUpdate_Feasibility: line 31, column 1

 

 

 

trigger OpptyStageUpdate_Feasibility on Feasibility__c (after insert, after update) {

// Updates the Opportunity Stage to Feasibility when Feasibility record is created

//Lists the Opportunities from Proposals that meet criteria

List<ID> feasIds = new List<ID>();
for (Feasibility__c f: Trigger.new){
if(f.Stage__c <> null){
feasIds.add(f.Opportunity__c);
}
}

//Pulls the SOQL list and updates the Oppty Stage
List<Opportunity> opptyList = [SELECT ID, StageName, Opportunity_Type__c, RecordTypeId
FROM Opportunity
WHERE ID in:feasIds];



for (Feasibility__c f: Trigger.new){
for (Opportunity opp: opptyList){

if (f.Stage__c <> 'Closed Rejected'){
opp.StageName = 'Feasibility' ;
}
}

}

update opptyList;

}

 

 

 

  • June 11, 2013
  • Like
  • 0

Hello Experts,

 


Is there a possibility to view Account or any Other Customer/Standard Objects fields value on Task Screen using formula or workflow? Don't want to update via Apex Code class/Batch class.

  • June 11, 2013
  • Like
  • 0

I have the following Trigger:

 

trigger send_notification on Inquery__c (after update) {

Inquery__c inquery = trigger.new[0];

if (Trigger.isUpdate) {

      if(inquery.Quilification__c == 'Qualified') {

      }
      if(inquery.Quilification__c == 'Disqualified') {
          Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
          EmailTemplate et=[Select id from EmailTemplate where name=:'Ineligible_course_candidate'];
          mail.setTemplateId(et.id);
          mail.setTargetObjectId(inquery.email__c);
          mail.setSenderDisplayName('Salesforce Support');
         Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

      }

   }
}

 

Im getting the following error:

 

Error:Apex trigger send_notification caused an unexpected exception, contact your administrator: send_notification: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.send_notification: line 15, column 1

 

for the following line:

 

EmailTemplate et=[Select id from EmailTemplate where name=:'Ineligible_course_candidate'];

 

Anyone know why?

 

Thanks

 

I have a trigger that assigns the account owner to the contact owner record when the contact is inserted or updated (before insert, before update).  I only want to execute code when the account on the contact changes.  If there is no change, I don't want to execute the code.

 

I can compare the account value on the contact using the trigger.new collection and the trigger.oldMap collection.  The code is factored out into a separate class using the trigger template pattern.

 

It is making it a little trickier to do the check and only run the code when the account changes.

 

Here is my class:

 

global class ContactAssignOwnership implements Triggers.HandlerInterface {
	
	Contact[] newCollection = trigger.new;
	Set<Id> accountIds = new Set<Id>();

	
	global void handle() {
		assignContactOwnership(getAccountIds());
	}
	
	private Set<Id> getAccountIds() {
		for(Contact c: newCollection) {
			accountIds.add(c.accountId);
		}
		return accountIds;
	}
	
	private void assignContactOwnership(Set<Id> accountIds) {
		Map<Id, Account> mapAccounts = new Map<Id, Account>([select Id, ownerId from Account where id in: accountIds]);
		
		for(Contact c : newCollection) {
			if(!mapAccounts.isEmpty() && mapAccounts.size() > 0) {
				if(mapAccounts.containsKey(c.accountId)) {
					c.OwnerId = mapAccounts.get(c.accountId).OwnerId;
				}
			}
		}
	}
}

 

I'd like to do the check in the handle method so that I don't run any unnecessary code.  However, how can I accomplish that for bulk?  I need to compare the account values for each record and see if they are different, then call the assignContactOwnership method which has a soql query, so I can't put that method inside a for loop or I'll hit limits.  Also, the oldMap isn't available in the before insert context so I'll get a null pointer exception if I use it there.

 

Any help is appreciated.

Thanks.

Hello

The requirement here is to make 2 picklists, one with records from object Functional_Group_del__c and another with records from object. Equipment_Type__c (which has a lookup field to Functional_Group_del__c)  When a record of Functional_Group_del__c is chosen in the first picklist, the values in the second picklist are restricted to records in Equipment_Type__c whose lookup field value is equal to the Functional Group chosen in the first picklist.

The variable 'fgOptions'  populates the first picklist with Functional Group values. The variable 'fgVal' must store the value currently chosen in the first picklist. 

The following code gives the error "variable is not visible" regarding 'fgVal'. Should the setter method be in some other form? In general, what must be done to give getter methods access to variables that take their values from a user input?

The markup:

<apex:page controller="buildTypeController1"> 
  <apex:pageBlock title="Select Functional Group">    
      <apex:form >
          <apex:selectList size="1" value="{!fgVal}"> 
              <apex:selectoptions value="{!fgOptions}"/>
                  <apex:actionsupport action="{!setFgVal}" event="onchange" rerender="type"/>
          </apex:selectList>
      </apex:form>
  </apex:pageBlock> 
  <apex:outputpanel id="type">
  <apex:pageBlock title="Select Equipment Type">    
      <apex:form >
          <apex:selectList size="1">
              <apex:selectoptions value="{!typeOptions}" />
          </apex:selectList>
      </apex:form>
   </apex:pageBlock>
   </apex:outputpanel>
</apex:page>

 The controller:

public with sharing class buildTypeController1 {
    public SelectOption fgVal{get;}
    public void setFgVal(SelectOption fgVal){
       system.debug('#############'+fgVal);
       this.fgVal=fgVal;
    }
    public list<SelectOption> getFgOptions(){
        list<Functional_Group_del__c> fgList = new list<Functional_Group_del__c>();
        list<SelectOption> fgOptions = new list<SelectOption>();
        fgList = [select id,name from Functional_Group_del__c];
        if(fgList.size()>0){
            for(Functional_Group_del__c fg : fgList){
                fgOptions.add(new SelectOption(fg.Name,fg.Name));
            }
            return fgOptions;
        }
        else
        return null;
    }
    public list<SelectOption> getTypeOptions(){
        list<Equipment_Type__c> typeList = new list<Equipment_Type__c>();
        list<SelectOption> typeOptions = new list<SelectOption>();
        //system.debug('*************'+string.valueof(fgVal));
        typeList = [select id,name,Functional_Group__c from Equipment_Type__c];
        if(typeList.size()>0){
            for(Equipment_Type__c et : typeList){
                typeOptions.add(new SelectOption(et.Name,et.Name));
            }
            return typeOptions;
        }
        else
        return null;
    }
        
}

 

 

I'm writing my first visualforce email template and am having a problem with it not displaying the OutputField. I'm not sure what I'm doing wrong. 

Here's the controller:

public class getBloomerProductsController {
	// get the oppty id
	public id OpptyID {get;set;}

	//a list to hold the bloomerproducts
	public List<OpportunityLineItem> BloomerangProducts {get;set;}
	
	public getBloomerProductsController() {		
	}
	
	public List<OpportunityLineItem> BloomerangProducts() {
		System.debug('bloomerangProducts is' + BloomerangProducts);
		System.debug('OpportunityID is'+ OpptyID);
		return [Select PricebookEntry.Name From OpportunityLineItem WHERE HasBloomerang__c = true and OpportunityID =: OpptyID];		
	}
}

 Here's the component:

<apex:component id="getBloomerProducts" controller="getBloomerProductsController" access="global">	
	<apex:attribute name="OpportunityID" description="This is the Opportunity Id." type="Id" assignTo="{!OpptyID}"/> 
	<table border="1">
		<tr>
		    <td><apex:outputText value="Product name"/></td>
		</tr>  
 	<apex:repeat value="{!BloomerangProducts}" var="blp" >
		<tr>
		    <td><apex:outputField value="{!blp.PricebookEntry.Name}"/></td>		    
		</tr>                
	</apex:repeat>
	</table>
</apex:component>

 Here's the email template

<messaging:emailTemplate recipientType="Contact"
    relatedToType="Opportunity"
    subject="New Firespring Bloomerang Sale"
    replyTo="sales@firespring.com" >
    
<messaging:htmlEmailBody >        
    <html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
               TD  {font-size: 11px; font-face: verdana } 
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE>
        <font face="arial" size="2">
        <p>A new sale was made to:</p>
        <br/>Account:{!relatedTo.Account.name}    
        <br/>Contact:{!recipient.Name}      
        <c:getBloomerProductsController OpportunityID="{!relatedTo.Id}"></c:getBloomerProductsController>
         </font>
       
        </body>
    </html>
</messaging:htmlEmailBody>    
        
</messaging:emailTemplate>

 

I thought maybe I was writing the query incorrectly so I changed the query to select only the OpportunityLineItem.Id and it still doesn't display any products. What am I doing wrong?

 

Thanks!

Setup: 


We built a custom object where we're capturing just a few fields:  type, completed_date and (associated) contact IDs for each type.  Type(Type__c) can have a value of a either meetng or call.  I'm tryting to retrive the number of meetings and number of calls and group those by the contact Ids using a SOQL aggregate:  COUNT(fieldName).  The ideal result is that we want to see that contact Joe Smith has 4 calls and 3 meetings;  contact Susan Johnson has 1 call and 10 meetings.

 

Current Code:

 

String query = 'SELECT aacac.Contact_Id__c varAggContactId, COUNT(aacac.Type__c) varAggCount, aacac.Completed_Date__c FROM Accumulated_Activity__c aacac WHERE (aacac.Type__c LIKE \'%Meetng%\' OR aacac.Type__c LIKE \'%Call%\') GROUP BY aacac.Contact_Id__c,  aacac.Completed_Date__c';
System.debug(query);
System.debug(Database.query(query));

 

//This Returns

 

AggregateResult:{varAggCount=4, Completed_Date__c=Thu May 30 00:00:00 GMT 2013, varAggContactId=0033000000JDZklAGH},
AggregateResult:{varAggCount=2, Completed_Date__c=Sun Jun 02 00:00:00 GMT 2013, varAggContactId=0033000000JDZklAGH},

 

As you can see I'm getting the number but I don't know if the 4 is the number of meetings or calls. 

 

Question:


Any thoughts how I can get both the number of a certain type grouped by contact as well as the type value itself (4 meetings, 2 calls)?

 

Thank you in advance!

-BroncoBoy

 

Hi I have been working on salesforce for quite a while now. Despite that I consider myself as a beginner.. Can you Please give me scenarios as to where I will have to use sets and Maps.. I have used Lists and I am comfortable with It but I have never faced a scenario as to when I have to use a Map and Set in differnt scenerio.. so that I could help me to understand the usage of these two collection elements..

 

 

 

Right now I have a button on the Cases layout called Change Management.  When you click the button, it creates a Change record and a junction object, all works fine.  Problem we have is when you click Save after all that, would like it to behaving like the Save button on Cases where after you create a case, click Save, it goes back to the Case you just created.  Right now, when you click Save on the Change record, it returns to the Home tab.  Here's my code below, how can I get it to return to the Change record that gets created?

public class SampleCaseButtonController {
    //Create a variable to hold the case that is accessible from the rest of the class
    private Case currCase = new Case();

    public SampleCaseButtonController(ApexPages.StandardController controller) {
       
        List<Case> caseList = [Select AccountId, Contact.Phone, Contact.Email, Contact.MobilePhone, ContactId, Dealer__c, Product__c, Support_Advocate__c From Case c Where Id = :controller.getId() LIMIT 1];
        //If cases are returned from the query
        if(caseList.size() > 0){
           currCase = caseList[0];
        }
    }
    
    public PageReference changeCase(){
    
        // Create a new Change Record
        Change__c newChange = new Change__c();
          
        // Fill in the values for the new record
        newChange.Account_Lookup__c = currCase.AccountId;
        
        // We put the case contact id field into a string because in the SOQL query,
        // we cannot compare the User ContactId field to an ID field directly. Doing so will
        // throw an "Invalid assignment of Schema.Sobjectfield to Id" error.  Exact reason
        // unknown but likely related to the special construction of the Portal fields in the 
        // User object.
       
        String tmpId = currCase.ContactId;
        if(tmpId != null)
        {
        newChange.Contact_Approver2__c  = [Select id From User Where ContactId = :tmpId LIMIT 1].Id;
        }
        newChange.Dealer_Account4__c    = currCase.Dealer__c;
        newChange.ProductChange__c      = currCase.Product__c;
        newChange.Support_Advocate1__c  = currCase.Support_Advocate__c;   
    
        newChange.Contact_Phone__c =  currCase.Contact.Phone;
        newChange.Contact_Mobile__c = currCase.Contact.MobilePhone;
        newChange.Contact_Email__c = currCase.Contact.Email;
              
        
        // Insert the change record 
        Database.insert(newChange);
        
          //create a new Case Change Association
        Case_Change_Association__c newCCA = new Case_Change_Association__c();
         // Fill in the values for the new record
         newCCA.Case__c = currCase.Id;
         newCCA.Change__c = newChange.id;
         
        //Insert the new Case Change Association record
        Database.insert (newCCA);
            
        PageReference retPage = new PageReference('/' + newChange.id + '/e');
        return retPage;
    
    }

}

 

  • May 30, 2013
  • Like
  • 0

Hi all,

 

Still new to Apex and am having trouble with this test class:

 

@isTest

public class emailHandlerTest {

static testMethod void emailTest() {

//Create fake records
RecordType rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Account' AND isActive = true AND DeveloperName like '%Person_Account%' LIMIT 1];
Account a = new Account();
a.RecordTypeId = rt.Id;
a.LastName = 'test';
insert a;

Property__c prop = new Property__c();
prop.Address_Line_1__c = '123 Street';
prop.Name = '123 Street';
insert prop;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Opportunity' AND isActive = true AND Name like '%Rental%' LIMIT 1];
Opportunity opp = new Opportunity();
opp.AccountId = a.Id;
opp.Name = 'test';
opp.StageName = 'test';
opp.CloseDate = system.today();
opp.RecordTypeId = rt.Id;
opp.Property__c = prop.Id;
insert opp;

rt = [SELECT Id FROM RecordType WHERE SobjectType = 'Applicants__c' AND isActive = true AND Name like '%Primary_Applicant%' LIMIT 1];
Applicants__c app = new Applicants__c();
app.RecordTypeId = rt.Id;
app.Opportunity_Name__c = opp.Id;
app.Property__c = prop.Id;
app.Applicant_Email__c = 'test@test.com';

//Initiate Test One - Will the first email field fill in after an applicant record is inserted?
Test.startTest();

insert app;

Test.stopTest();

system.assert(opp.Additional_Applicant_1__c == 'test@test.com'); //This is Line 43
}
}

 

Actual Trigger being tested is here:

 

trigger emailHandler on Applicants__c (after insert) {

Set<ID> opportunityIds = new Set<ID>();

for (Applicants__c a: trigger.new) {

opportunityIds.add(a.Opportunity_Name__c);
}

List<Applicants__c> applicantEmail = [Select id, Applicant_Email__c From Applicants__c Where id in: Trigger.new];

List<Opportunity> emailFields = [Select id, Additional_Applicant_1__c, Additional_Applicant_2__c,Additional_Applicant_3__c,Additional_Applicant_4__c
From Opportunity
Where id in: opportunityIds];

for (Opportunity o: emailFields) {

for (Applicants__c a: applicantEmail) {

String email = a.Applicant_Email__c;

if (o.Additional_Applicant_1__c == null) {

o.Additional_Applicant_1__c = email;

}Else if (o.Additional_Applicant_1__c <> null && o.Additional_Applicant_2__c == null) {

o.Additional_Applicant_2__c = email;

}Else if (o.Additional_Applicant_1__c <> null && o.Additional_Applicant_2__c <> null && o.Additional_Applicant_3__c == null) {

o.Additional_Applicant_3__c = email;

}Else if (o.Additional_Applicant_1__c <> null && o.Additional_Applicant_2__c <> null && o.Additional_Applicant_3__c <> null && o.Additional_Applicant_4__c == null) {

o.Additional_Applicant_4__c = email;
}
}
}

update emailFields;
}

 

As you can see I'm creating fake records so that I can fulfill the required fields on my Applicant__c object.  I have to have an account to create the property, a property to create the opportunity, etc.  

 

The trigger I'm testing is "after insert" so that's why I'm putting the "insert app" line in within the test; because I want to see what happens to the opportunity after an applicant record is inserted.  What should happen is that "test@test.com" gets put in an opportunity field called "Additional_Applicant_1__c".

 

I'm using the Developer Console and there are no errors to solve.  I run the test and get "Assertion Failed" at line 43, which I take to mean that "test@test.com" is NOT present on that field.

 

The trouble is that an actual test of this code works perfectly (meaning if I physically create the applicant record instead of using the test class).

 

Bottom Line: I know the code works, but I can't get the test class to prove it.  Please help!

 

I'm calling a static method from a trigger. I had all the of the methods in one originally, but had to change it to support bulk processing.  I'm using a design pattern I've used elsewhere successfully, however for some reason, I'm not getting past the initial queries in the method. I'm not seeing why that's happening and am hoping someone has a suggestion. 

 

Thanks!

JoAnn

 

Trigger: 

trigger notifyPtnrOfNewLead on Lead (after insert, after update) {
    	List<Lead> leadsInTrigger = new List<Lead>();
    	String[] ptnrs= new List<String>();

    
    if(!controlTriggerRecursion.hasAlreadyLooped()){
        
        for(Lead l: trigger.new){
               if(l.Preferred_Partner_for_Tech_Purchases__c.length()>0){
                   leadsIntrigger.add(l);
                   ptnrs.add(l.Preferred_Partner_for_Tech_Purchases__c);
                    }
        }
    }
    		controlTriggerRecursion.setHasAlreadyLooped();
        	ptrCampaignHandling.findPtrCampaign(leadsInTrigger,ptnrs);
       
}

 

 

Class & Method: 

 

public class ptrCampaignHandling{
    
    public static void findPtrCampaign(List<Lead> ptrLead, String[] cmpaignPtr){

Map<String, Campaign> ptnrCampaignMap = new Map<String, Campaign>(); //This Query and the one for Accounts below are looping, but I'm not understanding why...
List<Campaign> camps = [SELECT id, Name, Campaign_Partner__c, Primary_Partner_Contact__c, Email_Template_Name__c, isActive, StartDate, EndDate, Type, Primary_Partner_Contact__r.Email FROM Campaign WHERE Type = 'Partners' AND IsActive = True]; for(Campaign cmp : camps){ ptnrCampaignMap.put(cmp.Name,cmp); } Map<String, Id> cmpPartnerId = new Map<String, Id>(); List<Account> ptrAccts = [SELECT id, Name FROM Account WHERE Type = 'Partner' AND Partner_Status__c = 'Agreement Signed' ORDER by CreatedDate DESC]; for(Account pa: ptrAccts){ cmpPartnerId.put(pa.Name, pa.id); } Map<Lead, Id> cmsToCreate = new Map<Lead, Id>(); List<Lead> newCampaignsToCreate = new List<Lead>(); for(Lead newLead : ptrLead){ String campName = newLead.pi_campaign__c + ' - ' + newLead.Preferred_Partner_for_Tech_Purchases__c; Campaign ptnrCampaign = ptnrCampaignMap.get(campName); if(ptnrCampaign != NULL){ cmsToCreate.put(newLead, ptnrCampaign.id); } else { newCampaignsToCreate.add(newLead); } } insertCamp(newCampaignsToCreate, cmpPartnerId); createNewCampMembers(cmsToCreate); } public static void insertCamp(Lead[] newCampsToCreate, Map<String, Id> cmptrList){ List<Campaign> newCampsToInsert = new List<Campaign>(); String[] CampaignPartners; for(Lead l : newCampsToCreate){ String campName = l.pi_campaign__c + ' - ' + l.Preferred_Partner_for_Tech_Purchases__c; Campaign newPtnrCampaign = new Campaign(); newPtnrCampaign.Name = campName; newPtnrCampaign.Type = 'Partners'; newPtnrCampaign.StartDate = date.today(); newPtnrCampaign.EndDate = date.today().addMonths(3); newPtnrCampaign.Campaign_Partner__c = newPtnrCampaign.Primary_Partner_Contact__c = cmptrList.get(l.Preferred_Partner_for_Tech_Purchases__c); newPtnrCampaign.isActive = true; newPtnrCampaign.Email_Template_Name__c = l.pi_campaign__c + ' - Lead Notification'; newcampsToInsert.add(newPtnrCampaign); campaignPartners.add(cmptrList.get(l.Preferred_Partner_for_Tech_Purchases__c)); } insert newCampsToInsert; findPtrCampaign(newCampsToCreate, campaignPartners); } public static void createNewCampMembers(Map<Lead, Id> newCM){ CampaignMember cm = new CampaignMember(); List<CampaignMember> cmsToInsert = new List<CampaignMember>(); for(Lead l : newCM.keySet()){ cm.CampaignId = newCM.get(l); cm.LeadId = l.id; cm.Status = 'Responded'; cmsToInsert.add(cm); } insert cmsToInsert; } }

 

Hi,

 

Below is the trigger written on Accounts to send email to the old account owner whenever there is a ownership change.

 

The trigger got saved, but from UI when you change the account owner below is the error thrown at line 5 and 6.

 

Error: Apex trigger SendEmailOnOwnerChange caused an unexpected exception, contact your administrator: SendEmailOnOwnerChange: execution of AfterUpdate

caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.SendEmailOnOwnerChange: line 5,6 column 1

 

Please help me out to fix the issue.

 

trigger SendEmailOnOwnerChange on Account (after update) {

    if (trigger.old[0].OwnerId != trigger.new[0].OwnerId) {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

        String emailAddr = [select Email from User where Division != 'NZ' AND Id = :trigger.old[0].OwnerId].Email;
        String newOwnerName = [select Name from User where Division != 'NZ' AND Id = :trigger.new[0].OwnerId].Name;

        String[] toAddresses = new String[] {emailAddr};
        mail.setToAddresses(toAddresses);

        mail.setSubject('ALERT-Owner Changed for Account : ' + trigger.new[0].Name);

        mail.setPlainTextBody('Owner of Account: ' + trigger.new[0].Name + ' Changed to ' + newOwnerName);
        mail.setHtmlBody('Owner of Account: <b>' + trigger.new[0].Name + '</b> Changed to <b>' + newOwnerName  + '</b>');

        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}

  • May 29, 2013
  • Like
  • 0
    Public static void CaseRollUpFieldsOpportunity(Map<Id,Opportunity> oldMap, Map<Id,Opportunity> newMap)
    {
    List<Id> OpptyCaseIds = new List<Id>();
    map<Id,Double> CaseMap = new map <Id,Double>(); 

    for (Opportunity o : newMap.Values())
    {   
        if(o.Total_Adjusted__c > 0)
        {      
                    OpptyCaseIds.add(o.Case_No__c);
        }
    }

    for(AggregateResult q : [Select Case_No__c, SUM(Total_Adjusted__c) From Opportunity Where Case_No__c in: OpptyCaseIds Group By Case_No__c])
        {
       // CaseMap.put((Id)q.get('Case_No__c'),(Double)q.get('expr0'));
    }
    
    List<Case> CasesToUpdate = new List<Case>();
    
    for(Case a : [Select Id, Total_Adjusted__c from Case where Id IN :OpptyCaseIds])
    {
            Double AdjustedSum = CaseMap.get(a.Id);
            a.Total_Adjusted__c = AdjustedSum;
            CasesToUpdate.add(a);
    }

    update CasesToUpdate;
    }

 I have a problem with the commented field. btw Case_No__c is case id....  I just need to know how to add the double to the map so I can update the field on the case record.  Please let me know what you think.

 

Thank you,

Steve Laycock

Hi there,
 
We are a consulting company in SF Bay Area, specialized in providing SFDC development/configuration solutions.
 
We have provided SFDC Administration and Custom Programming using Visual Force Pages, Apex, Web Services, Dot Net and S-Controls for various major clients in USA/Canada.
 
We can implement any sized Project with the following requirements/tasks:
 
 1. Visual Force Pages, Custom Controllers and Controller extensions using Apex code


 2. Enhancements to your existing S-Controls or convert them into Visual Force pages

   

 3. Specialized in writing bulk Triggers


 4. Design/Customize Management Systems:
        a. Design new Custom Objects, Page Layouts and Custom Reports
       

        b. Specialized in customizing your Sales Quote Management       

        c. Lead / Web2Lead Management (Lead De-duplication and Conversion Process)
        d. Portal Management
        e. Assignment Rules/Workflow Rules/Approval Processes
        f. eMail2Case Management
        


 5. Data Management
        a. Data Migration from Legacy System
        b. Import/Export data to SQL Server, Oracle databases


 6. Schedule Jobs
        a. Cron Job
        b. Dot.Net Applications using Windows Scheduled Task
        c. Any Apex code which cannot be implemented due to governor limits

Hear are few client references available in the Jobs Board site: 

         Reference 1

         Reference 2

         Reference 3  

 

If you need, we can provide more references. Please email us to discuss further. 

 

 Thanks

Message Edited by CodeWizard on 11-09-2009 11:22 AM

Hi there,
 
We are a consulting company based in the bay area, specialized in providing SFDC configuration/development solutions.
 
We have provided SFDC Administration and Custom Programming with Visual Force,  Apex , S-Controls for various major clients in USA/Canada.
 
We can undertake the following tasks.
 
 1. New Visual Force Pages/Apex  Development.
 2. Fix/Enhance Existing Visual Force Pages.
 3. Convert existing SControls to Visual Force pages.

 4. Enhance existing SControls/Fix Bugs in it.
 5. Create New Triggers/Fix Bugs in Trigger/Deploy them into Production.
 6. Customize SFDC for your requirements.
        a. Create New Custom Objects/Page Layouts/Custom Reports
        b. Portal Management.
        c. Workflow Rules/Approval Processes.
        d. Web2Lead Management.
        e. eMail2Case Management.
        f. Assignment Rules
        g. Any other Customization Tasks.
 7. Data Management.
        a. Fix Existing Data for New requirements.
        b. Provide Mass Update Solutions.
        c. Any other data related tasks.
 8. Scheduling Jobs.
        a. Cron Jobs.
        b. DotNet based Scheduling Tasks.
        c. Any apex code which cannot be implemented by normal means because of governor limits.
 9. Adobe Flex/AIR based applications support(Charts & UI).
 10. Excel VBA based application support.
 
We can quickly convert your sControls to VF/Apex pages.

We can customize the AppExchange Tools built on VF to your business needs.

We can generate PDF based invoices in your company specific format with your company logo. 

We can write effective test methods to deploy your apex code.

 

We received good appreciations from our clients for our quality work delivered on time and for after delivery support.Our clients are impressed about our competitive rates.

Please visit the links below for customer references in our previous postings.

 

Reference 1

Reference 2

 

 

We can provide more references. Please email us to discuss further.

 

Thanks

Message Edited by CodeWizard on 11-09-2009 11:21 AM

Hi there,
 
We are a consulting company based in the bay area, specialized in providing SFDC configuration/development solutions.
 
We have provided SFDC Administration and Custom Programming with S-Controls, Adobe Flex, Apex and Visual Force for various major clients in USA/Canada.
 
We can undertake the following tasks.
 
 1. New Visual Force Pages/Apex  Development.
 2. Fix/Enhance Existing Visual Force Pages.
 3. Enhance existing SControls/Fix Bugs in it.
 4. Create New Triggers/Fix Bugs in Trigger/Deploy them into Production.
 5. Customize SFDC for your requirements.
        a. Create New Custom Objects/Page Layouts/Custom Reports
        b. Portal Management.
        c. Workflow Rules/Approval Processes.
        d. Web2Lead Management.
        e. eMail2Case Management.
        f. Assignment Rules
        g. Any other Customization Tasks.
 6. Data Management.
        a. Fix Existing Data for New requirements.
        b. Provide Mass Update Solutions.
        c. Any other data related tasks.
 7. Scheduling Jobs.
        a. Cron Jobs.
        b. DotNet based Scheduling Tasks.
        c. Any apex code which cannot be implemented by normal means because of governor limits.
 8. Adobe Flex/AIR based applications support(Charts & UI).
 9. Excel VBA based application support.
 
We received good appreciations from our clients for our quality work delivered on time and for after delivery support.Our clients are impressed about our competitive rates.

 

Please visit the links below for customer references in our previous postings.

 

Reference 1

Reference 2

 

We can provide more references. Please email us to discuss further.

 

Thanks
 

Message Edited by CodeWizard on 02-15-2009 02:50 PM
Message Edited by CodeWizard on 11-09-2009 11:20 AM

Hi there,
 
We are a consulting company based in the bay area, specialized in providing SFDC configuration/development solutions.
 
We have provided SFDC Administration and Custom Programming with S-Controls, Adobe Flex, Apex and Visual Force for various major clients in USA/Canada.
 
We can undertake the following tasks.
 
 1. New Visual Force Pages/Apex  Development.
 2. Fix/Enhance Existing Visual Force Pages.
 3. Enhance existing SControls/Fix Bugs in it.
 4. Create New Triggers/Fix Bugs in Trigger/Deploy them into Production.
 5. Customize SFDC for your requirements.
        a. Create New Custom Objects/Page Layouts/Custom Reports
        b. Portal Management.
        c. Workflow Rules/Approval Processes.
        d. Web2Lead Management.
        e. eMail2Case Management.
        f. Assignment Rules
        g. Any other Customization Tasks.
 6. Data Management.
        a. Fix Existing Data for New requirements.
        b. Provide Mass Update Solutions.
        c. Any other data related tasks.
 7. Scheduling Jobs.
        a. Cron Jobs.
        b. DotNet based Scheduling Tasks.
        c. Any apex code which cannot be implemented by normal means because of governor limits.
 8. Adobe Flex/AIR based applications support(Charts & UI).
 9. Excel VBA based application support.
 
We received good appreciations from our clients for our quality work delivered on time and for after delivery support.Our clients are impressed about our competitive rates.

 

Please visit the links below for customer references in our previous postings.

 

Reference 1

Reference 2

 

We can provide more references. Please email us to discuss further.

 

Thanks

 

Message Edited by CodeWizard on 02-15-2009 02:50 PM
Message Edited by CodeWizard on 11-09-2009 11:19 AM
Hi there
 
We are a consulting company based in the bay area, specialized in providing SFDC configuration/development solutions.
 
We have provided SFDC Administration and Custom Programming with S-Controls, Adobe Flex, Apex and Visual Force for various major clients in USA/Canada.
 
We can undertake the following tasks.
 
 1. New Visual Force Pages/Apex  Development.
 2. Fix/Enhance Existing Visual Force Pages.
 3. Enhance existing SControls/Fix Bugs in it.
 4. Create New Triggers/Fix Bugs in Trigger/Deploy them into Production.
 5. Customize SFDC for your requirements.
        a. Create New Custom Objects/Page Layouts/Custom Reports
        b. Portal Management.
        c. Workflow Rules/Approval Processes.
        d. Web2Lead Management.
        e. eMail2Case Management.
        f. Assignment Rules
        g. Any other Customization Tasks.
 6. Data Management.
        a. Fix Existing Data for New requirements.
        b. Provide Mass Update Solutions.
        c. Any other data related tasks.
 7. Scheduling Jobs.
        a. Cron Jobs.
        b. DotNet based Scheduling Tasks.
        c. Any apex code which cannot be implemented by normal means because of governor limits.
 8. Adobe Flex/AIR based applications support(Charts & UI).
 9. Excel VBA based application support.
 
We received good appreciations from our clients for our quality work delivered on time and for after delivery support.
Our clients are impressed about our competitive rates.We can provide references.
Please email us to discuss further.

Thanks

Message Edited by CodeWizard on 11-09-2009 11:17 AM
Hi,
 
Do you have a requirement to run a  manual batch process which could not be done so far because of governor limits? We can develop the batch process using apex programming overcoming the governor limits.
 
Are you struggling to deploy your apex classes/triggers because of the test coverage issues? We can help you optimize the test methods and deploy it for you.
 
We are a consulting company based in the bay area (California), specialized in providing SFDC configuration/development solutions. We have provided SFDC Administration and Custom Programming with S-Controls, Adobe Flex, Apex, Visual Force and VB.Net for various major clients in USA/Canada.

We received good appreciations from our clients for our quality work delivered on time.We can provide references. Please email us to discuss further.

Thanks

Message Edited by CodeWizard on 11-09-2009 11:16 AM
Hi there
 
Is your organization having a requirement for batch processing and because of apex governor limits you could not do that?
 
We can help you to write an application which can run from asp.net/vb.net which may be accessed by clicking a tab/link in sfdc.
 
We have successfully implemented a complex roll up summary batch using dot net technology.
 
We are a consulting company based in the bay area (California), specialized in providing SFDC configuration/development solutions. We have provided SFDC Administration and Custom Programming with S-Controls, Adobe Flex, Apex, Visual Force and VB.Net for various major clients in USA/Canada.

We received good appreciations from our clients for our quality work delivered on time.We can provide references. Please email us to discuss further.

Thanks

Message Edited by CodeWizard on 11-09-2009 11:15 AM
Hi there
 
Is your organization currently using SControls and are you thinking of enhancing its functionality/fixing the bugs in it?
 
We specialize in quickly understanding your existing code and fix any bugs/provide enhancements for your SControls.
 
Also we can write new SControls, Triggers, Apex Classes, Visual Force pages for your requirement.
 
We are a consulting company based in the bay area (California), specialized in providing SFDC configuration/development solutions. We have provided SFDC Administration and Custom Programming with S-Controls, Adobe Flex, Apex, Visual Force and VB.Net for various major clients in USA/Canada.

We received good appreciations from our clients for our quality work delivered on time.We can provide references. Please email us to discuss further.

Thanks

Message Edited by CodeWizard on 11-09-2009 11:15 AM
Hi there
 
Does your organization have a requirement to schedule some process in Salesforce.com?
 
Is your organization currently using an scontrol to do a calculation like rollup summary, which takes lots of time to compute?
 
We have a solution to this problem if your organization has an internet facing windows server. We have specialized in writing VB.Net based applications, which can be scheduled using windows scheduler. This application can run at a desired frequency and  do necessary computations.
 
Also using these applications, we can send emails basing on some crtieria. Please note that there is no governor limits to the computations done using this approach. So any of your requirement that was not implemented because of trigger/apex class governor limits, they can be implemented effectively.
 
We are a consulting company based in the bay area (California), specialized in providing SFDC configuration/development solutions. We have provided SFDC Administration and Custom Programming with S-Controls, Adobe Flex, Apex, Visual Force and VB.Net for various major clients in USA/Canada.

We received good appreciations from our clients for our quality work delivered on time.We can provide references. Please email us to discuss further.

Thanks

Message Edited by CodeWizard on 11-09-2009 11:14 AM
Hi there
Is your company getting leads into your sfdc org from web2lead/Manual Lead?  If so, you might be spending lots of time in identifying the duplicate leads, deleting them, setting the right status/stage to lead(qualification) etc
 
Do you want to mark the duplicate leads and delete them by automation?
Do you want to qualify the lead basing on various business criteria by automation?
Do you want to convert the lead to accounts/contacts/opportunities if they are rightly qualified by automation?
Do you want to map the leads/contacts against the right campaigns by automation?
 
If you automate the above process, you can save a lot on manpower and your sales rep can spend time in actual selling rather than filtering out duplicate leads/qualifying them and converting them manually.
 
Yes we can do that for you.We are a consulting company based in the bay area (California), specialized in providing SFDC configuration/development solutions. We have provided SFDC Administration and Custom Programming with S-Controls, Adobe Flex, Apex and Visual Force for various major clients in USA/Canada.

We received good appereciations from our clients for our quality work delivered on time.We can provide references. Please email us to discuss further.

Thanks



Message Edited by CodeWizard on 10-30-2008 07:33 AM
Message Edited by CodeWizard on 11-09-2009 10:31 AM

Hi

We are getting the following message: "This lead was converted on {0}", when converting a Lead via APEX code using "ConvertLead" method.

Observation: We noticed the standard field "ConvertedDate" was null after we converted the Lead through code. When we converted the Lead by using SFDC standard Convert button, the "ConvertedDate" field is filling properly with today's date.

Did we miss anything or is there a bug in the API?

Thanks in Advance

-----------------------------------------------------------------------------------------------------

Here is the code we are using for the conversion:

            Database.LeadConvert LC = new database.LeadConvert();

            LC.setAccountId(MatchingAccounts[0].Id);
            LC.setLeadId(LeadNew[Ld].Id);             
            
            LC.setDoNotCreateOpportunity(true);
            LC.setConvertedStatus('Converted'); 
            
            Database.LeadConvertResult LCR = Database.convertLead(LC);            

 

 

Hi there

We are a consulting company based in the bay area (California), specialized in providing SFDC configuration/development solutions.

We have provided SFDC Administration and Custom Programming with S-Controls, Adobe Flex, Apex and Visual Force for various major clients in USA.

We provided SFDC solutions to complex business requirements.

We received good appereciations from our clients for our quality work delivered on time.

We can provide references. Please email us to discuss further.

Thanks



Message Edited by CodeWizard on 08-06-2008 10:15 PM

Message Edited by CodeWizard on 08-06-2008 10:23 PM


Message Edited by CodeWizard on 08-06-2008 10:24 PM

Message Edited by CodeWizard on 08-12-2008 07:27 AM
Message Edited by CodeWizard on 11-09-2009 10:32 AM
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}}" />
               
            </apex:map>
        </apex:pageblockSection>
    </apex:pageBlock>
</apex:page>
Any help would be  much appreciated !
Hello.

I have a customer's org into which I have installed a managed package.  On the org is some Apex code that calls a method in the managed package.  One of the things that the method does is make a SOQL select statement, but this fails saying "No such column".  However, if I run exactly the same SOQL statement outside of the managed package, it works.

Here is a sample of the code:
 
System.debug('HERE2: ' + [SELECT BillingAddress,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,ShippingAddress,Phone,Fax,Website,Sic,Industry,AnnualRevenue,NumberOfEmployees,Ownership,TickerSymbol,Description,Rating,Site,OwnerId,CreatedDate,CreatedById,LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate,LastViewedDate,IsPartner,IsCustomerPortal FROM Account Where Id in :setaccountId]);
Account member = (Account)(XXXXXXX.Util.getSObjects(setAccountId)[0]);

This is the debug log:
 
16:25:15.8 (1244514753)|SOQL_EXECUTE_BEGIN|[49]|Aggregations:0|SELECT Id, IsDeleted, MasterRecordId, Name, Type, RecordTypeId, ParentId, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, BillingAddress, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry, ShippingAddress, Phone, Fax, Website, Sic, Industry, AnnualRevenue, NumberOfEmployees, Ownership, TickerSymbol, Description, Rating, Site, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, LastViewedDate, IsPartner, IsCustomerPortal FROM Account WHERE Id = :tmpVar1
16:25:15.8 (1278032882)|SOQL_EXECUTE_END|[49]|Rows:1
16:25:15.8 (1278087443)|HEAP_ALLOCATE|[49]|Bytes:8
16:25:15.8 (1278113162)|HEAP_ALLOCATE|[49]|Bytes:524
16:25:15.8 (1278151757)|HEAP_ALLOCATE|[49]|Bytes:8
16:25:15.8 (1278378087)|HEAP_ALLOCATE|[49]|Bytes:651
16:25:15.8 (1278413071)|HEAP_ALLOCATE|[49]|Bytes:658
16:25:15.8 (1278443969)|USER_DEBUG|[49]|DEBUG|HERE2: (Account:{Id=0014E00000BAA5FQAX, IsDeleted=false, Name=Prasad Household, RecordTypeId=0124E0000004PsOQAU, BillingStreet=Bill1, BillingCity=Bill City, BillingState=State, BillingPostalCode=Postal, BillingCountry=UK, BillingAddress=API address [ Bill1, Bill City, State, Postal, UK, null, null, null, null, null], ShippingAddress=null, OwnerId=0054E000000L2viQAC, CreatedDate=2016-06-16 14:51:04, CreatedById=0054E000000L2viQAC, LastModifiedDate=2016-08-10 12:49:52, LastModifiedById=0054E000000L2p6QAC, SystemModstamp=2016-08-10 12:49:52, LastViewedDate=2016-08-10 14:43:09, IsPartner=false, IsCustomerPortal=true})
16:25:15.8 (1278457800)|STATEMENT_EXECUTE|[50]
16:25:15.8 (1288020530)|HEAP_ALLOCATE|[50]|Bytes:36
16:25:15.8 (1288035968)|HEAP_ALLOCATE|[50]|Bytes:159
16:25:15.8 (1288039088)|HEAP_ALLOCATE|[50]|Bytes:147
16:25:15.8 (1288069088)|METHOD_ENTRY|[1]|01p4E000000D3mS|Util.Util()
16:25:15.8 (1288073885)|STATEMENT_EXECUTE|[1]
16:25:15.8 (1288095397)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1288135086)|METHOD_EXIT|[1]|Util
16:25:15.8 (1288197449)|METHOD_ENTRY|[50]|01p4E000000D3mS|XXXXXX.Util.getSObjects(Set<Id>)
16:25:15.8 (1288210369)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1289170040)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1308239962)|SOQL_EXECUTE_BEGIN|[30]|Aggregations:0|SELECT Id,IsDeleted,MasterRecordId,Name,Type,RecordTypeId,ParentId,BillingStreet,BillingCity,BillingState,BillingPostalCode,BillingCountry,BillingAddress,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,ShippingAddress,Phone,Fax,Website,Sic,Industry,AnnualRevenue,NumberOfEmployees,Ownership,TickerSymbol,Description,Rating,Site,OwnerId,CreatedDate,CreatedById,LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate,LastViewedDate,IsPartner,IsCustomerPortal FROM Account Where Id IN :p_Ids
16:25:15.8 (1309713440)|METHOD_EXIT|[50]|01p4E000000D3mS|XXXXXX.Util.getSObjects(Set<Id>)
16:25:15.8 (1309785853)|VARIABLE_SCOPE_BEGIN|[43]|Ex|Exception|true|false
16:25:15.8 (1309879374)|VARIABLE_ASSIGNMENT|[43]|Ex|"common.apex.runtime.impl.ExecutionException: No such column 'BillingAddress' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."|0x1a7353e4

As you can see, the code in the managed package does the same SOQL select, but fails.

Note that this managed package works fine in other orgs

I have tried raising a case with Salesforce, but was told it was a "Developer Support Issue".

Thanks,

Carl







 
  • August 11, 2016
  • Like
  • 0
The problem appears when I try to save a dashboard using PATCH method of Dashboards REST API. I do this by the same way as it said in the developer guide (https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/analytics_api_dashboard_save_dashboard.htm)
I tried different variants of PATCH request body, but in the response I got the same error:
{"errorCode":"JSON_PARSER_ERROR","message":"The request body is either invalid or incomplete."}

Request sends to https://ap2.salesforce.com/services/data/v36.0/analytics/dashboards/IdOfDasboard

Body of the request is:
{
	"dashboardMetadata": {
		"name": "TestDashboard"    
	}
}

Have anybody any ideas why it happens?

Thank you,
Alexei Chudovsky 
We have an managed package which references settings stored in static resource which is not part of the managed package. We want to keep the static resource not a part of the managed package because we want to let the user modify those settings. 
Could you please let me know what is the best practices way to referene static resources not part of a managed package wtihin Visualforce page which is part of a managed package. 
We cannot use URLFOR because that would require the resource to be a part of the package. 
If we handcraft the url like this <apex:includeScript value="/resource/1463666571000/foo" />
The resource would not be loaded because the absolute url will be https://MANAGEDPACKAGEPREFIX.cs80.visual.force.com/resource/1463666571000/foo and Salesforce will not find it because the resource sits here: 
https://c.cs80.visual.force.com/resource/1463666571000/foo

Thanks!
Hi ,

We would like to delete the Webservice classes that is a part of a Managed Package. We raised a case and got the delete permission to delete objects and other stuff.

When didnt get the option for webservice classed and tried to edit them it shows like it cannot be done when part of a Managed Package.

Could some one please guide us in deleting them from the Managed Package.

Appriciate your time.Thank you very much for your support.

Regards,
Christwin
With standard rollups, I can run an accounts & contacts report and include opportunity values per account.  Since I disabled rollups as a result of activating advanced currency, I want to use a trigger to rollup opportunities into accounts.  Then run the same contacts & accounts report.  

This has nothing to do with contact roles.

What is the trigger for this?
Roll ups are disabled in our org due to advanced currency.

Can a trigger be used to count opportunities associated to each contact?
Hi,
I'm having some problems with the callout Governor Limits doing callouts in a Apex Class (Error: Too many call outs) . Doing some research I found that is posible to avoid this issue with Batch Apex, but I can't find a clear example and also I found some Batch Apex Governor Limits (Call out 10) I'm not sure if I'm reading this right but 10 call out in a Batch Apex is not going to help me. 
Can someone please help me with an example.
Thanks.

 
Hi I'm trying to get a value of contact field when the contact is selected through a lookup. But for some reason it's rendering. I'm sure what am I missing or maybe actionsupport isn't the solution?

By the way the Unit is a custome object on where I'm using standard object and calling an extension Class
<apex:actionRegion immediate="true">
    <apex:pageblockSection columns="1" title="Items">
            <apex:outputPanel id="name">
             <apex:pageBlockTable value="{!Item}" var="a" columns="3">      
                <apex:column headerValue="Materials" >
                    <apex:inputfield value="{!a.Contact__c}"/>
                    <apex:actionSupport event="onchange" action="{!getUnit}" rerender="name"/>
                </apex:column>     
                <apex:column headerValue="Unit">
                    <apex:outputfield value="{!Unit.Contact__r.Lastname}"/>
                </apex:column> 
                <apex:column headerValue="ship">
                    <apex:inputfield value="{!a.Job_Role__c}"/>
                </apex:column> 
            </apex:pageBlockTable>
            </apex:outputPanel>

          <apex:pageBlockTable value="{!Item}" var="a" columns="3"> 
           </apex:pageBlockTable>

  </apex:actionRegion>
</apex:pageblockSection>
public with sharing class CreateMaterialItem {

    ApexPages.StandardController JC;
    Public Job_Contact__c Unit {get; set;}
    
    public CreateMaterialItem(ApexPages.StandardController controller) {
        
        Unit = [select id, contact__c, contact__r.lastname from Job_contact__c where job__c =: JC.getID() limit 1];

    }
    public pageReference getUnit(){
         
        for (Job_contact__c lst : [select id, contact__c, contact__r.lastname from Job_contact__c where job__c =: JC.getID() limit 10]) {
                
                Unit.contact__r.lastname = lst.contact__r.lastname;
             }
             return null;
     } 
.
.
.
.
}//end of class
Please please help! This is kind of urgent!


Hi, 
    I have a hyperlink in visualforce page, if i click on hyperlink, the value should copy to clipboard

my vfp code;
<apex:outputLink  value="https://{!sfurll}/apex/CoreBenefit_PDF?id={!Returnid}" target="_blank" styleClass="newlink" >
Copy Url
</apex:outputLink>

If i click on "Copy Url", the "https://c.ap1.visual.force.com/apex/CoreBenefit_PDF?id=kA690000000H1An" should be saved in clipboard
Hello,

New to using JS, we have a need on a VisualForce page when the label of a pageBlockSectionItem is clicked, to execute a JS popup. In order to keep the code clean, I have put the JS in a seperate static resource. I am now trying to access a function for the onLabelClick and it is not working. If I put the <script> tags in the VF page and invoke the fuction onLabelclick it works, but is there a way to avoid that?

Below is the VF code I have that is not working:


<apex:page standardController="QA__c">
 <apex:includeScript value="{!$Resource.QA_Javascript}"/>  
 <apex:form >
 <apex:pageMessages />
 <apex:pageBlock title="QA Scoring Form">
 <apex:pageBlockButtons >
     <apex:commandButton action="{!save}" value="Save" />
     <apex:commandButton action="{!cancel}" value="Cancel"/>
 </apex:pageBlockButtons> 
 <apex:actionRegion >
  <apex:pageblockSection title="QA Information">
      <apex:inputField value="{!QA__c.Reviewee__c}"/>
      <apex:inputField value="{!QA__c.Complexity__c}"/>
      <apex:inputField value="{!QA__c.QA_Quote_Number__c}"/>
      <apex:inputField value="{!QA__c.QA_Date__c}"/>
      <apex:inputField value="{!QA__c.Overall_Comments__c}"/>
  </apex:pageblockSection>
  <apex:pageBlockSection title="Phone Etiquette" id="pe">
       <apex:pageBlockSectionItem onLabelclick="appGreet();" >       
           <apex:outputLabel value="Appropriate Greeting" for="ag1"/>
           <apex:panelGrid columns="2">
               <apex:inputField value="{!QA__c.Appropriate_Greeting__c}" id="ag1">
                <apex:actionSupport event="onchange" reRender="pe"/>
               </apex:inputfield>
               <apex:inputField value="{!QA__c.App_Greet_Comment__c}" id="ag2" label="Comments"/>
           </apex:panelGrid>
       </apex:pageBlockSectionItem>


Hi,

I've writen a trigger and test class that work well in the Sandbox, but when I attempt to deploy in Production, the test fails.
Whenever a "Worker" (custom object) is created, I need to also create a matching Contact.  I'm not concerned with creating duplicates at this point.  We use the Nonprofit Starter Pack.

Trigger:
trigger NewContactforWorker on VanaHCM__Worker__c (after insert) {
	List<Contact> conList = new List<Contact>();
    for (VanaHCM__Worker__c wkr : trigger.new) {
        Contact a = new Contact(
            Worker__c = wkr.Id, 
            FirstName = wkr.VanaHCM__First_Name__c,
            LastName = wkr.VanaHCM__Last_Name__c, 
            QSAC_external_id__c = wkr.VanaHCM__External_Worker_ID__c,
            npe01__Preferred_Email__c = 'Personal',
            npe01__PreferredPhone__c = 'Home', 
            npe01__Primary_Address_Type__c = 'Home');
        conList.add(a);
    }
    if(conlist.size()>0){
try{
    insert conList;
    system.debug('inserted new contact');
}catch(DMLException e){
System.debug('Error trying to insert new contact(s). Alert the media!');
}
}
}
And the test class:
@istest public class WorkerToContactTestClass {
    private static testmethod void TestWorkerToContact(){
        VanaHCM__Worker__c testwrkr = new VanaHCM__Worker__c(VanaHCM__First_Name__c = 'Flip', 
                                                             VanaHCM__Last_Name__c = 'Nahasapeemapetalan', 
                                                             VanaHCM__External_Worker_ID__c = 'X1');
        insert testwrkr;
        
        list<contact> foundWorkers = [SELECT Id FROM Contact WHERE QSAC_external_id__c = 'X1'];
        system.assertEquals(foundWorkers.size()>0, TRUE);
    }

Can anyone help?

Thank you

  • October 07, 2014
  • Like
  • 0
When a user clicks on "New Event" from a lead, I would like to populate the campaign field on Events with the campaign that is listed on the Lead Record.  I'm running into an error where it says "Variable does not exist: whoid".  I can't seem to figure out why it would be complaining about whoid when it shows up under Workbench for events.

public with sharing class EventTriggerHandler 
{
	private boolean triggerIsExecuting = false;
    private integer batchSize = 0; 

 	public boolean isTriggerContext{
        get { return triggerIsExecuting;}
    }
    
    public boolean isVisualforcePageContext{
        get { return !isTriggerContext;}
    }
     
    public boolean isWebServiceContext{
        get { return !isTriggerContext;}
    }
    
    public boolean isExecuteAnonymousContext{
        get { return !isTriggerContext;}
    }

  	public EventTriggerHandler(boolean isExecuting, integer size){
    	triggerIsExecuting = isExecuting;
    	BatchSize = size;
  	}
    	
   	public void UpdateLastCampaignActivityOnEvents(Event[] newEvent)
  	{
  		Set<Id> whoIDs = new Set<ID>();
  		for(Event CurrentEvent : newEvent) 
    	{
    		WhoIds.add(CurrentEvent.whoid);
    	}
    	
    	if (whoIDs.size() > 0 )
    	{
    		list<Lead> CurrentLeads = [Select ID, Eloqua_Campaign_Name__c From Lead where ID IN :WhoIDs];
    		
    		map<id,Lead> Leads = new map<id,Lead>();
    		
    		if (currentLeads.size() > 0 )
    		{
    			for (Lead currentlead : currentleads)
    			{
    				Leads.put(currentLead.ID, currentLead);
    			}
    			
    			for(Event CurrentEvent : newEvent) 
		    	{
		    		Lead LeadLookup = Leads.get(CurrentEvent.WhoID); 
		    		if (LeadLookup <> null)
		    		{
		    			CurrentEvent.Last_Campaign_Activity__c = LeadLookup.Eloqua_Campaign_Name__C; 
		    		}
		    	}
    		}
    	}   	

  	}
 	
  	public void onBeforeInsert(Event[] newEvent)
  	{
  		UpdateLastCampaignActivityOnEvents(newEvent);
   	}
   
  
    /*
    @future public static void onAfterInsertAsync(Set<ID> newEventIDs){
    	
    }
    */
 	/*
 	public void OnAfterInsert(Event[] newEvents) {
 		
 		
 	}
 	*/
 	/*
 	public void onBeforeUpdate(Event[] oldEvent, Event[] updatedEvent, Map<ID, Event> oldEventMap) {

    }
    */
 	/*
    public void onAfterUpdate(Event[] oldEvent, Event[] updatedEvent, Map<ID, Event> oldEventMap) {
    		
    }
    */
  	/*  
    @future public static void onAfterUpdateAsync(Set<ID> updatedEvent){
    	
    }
    */
    /*
    public void onBeforeDelete(Event[] EventToDelete, Map<ID, Event> EventMap){
        
    }
    */
    /*
    public void onAfterDelete(Event[] deletedEvent, Map<ID, Event> EventMap){
    			
    }
    */
    
    /*
    @future public static void onAfterDeleteAsync(Set<ID> deletedEvent){
        //to make this work like the on after delete you need to do a select statement into 
        //a list where ID in :deletedOpportunitySplits, this would recreate the deletedOpportunitySplits list
        //from there the code would work the same.
    }
    */
    
    /*
    public void onUndelete(Event[] restoredEvent){
        
    }
    */ 
}


Hi,

I am receiving an error that is not allowing users to access a VF page in a production org.  This works  fine in the full sandbox that we developed in, and tested before deploying to prod.  The only thing we can see that maybe causing the error is that Prod is on Summer 14 and Full sandbox is on Winter 15 release.  We've isolated it to a portion of the code which requires access to the standard fiscal year in the org.

We have done the following trouble shooting:
*Compared Full Sandbox vs Prod profiles
*cloned the system admin in prod (as this works fine for system admin) and just removed view all data and sales still receive an error.  Repeated this in the full sandbox and this worked
*we noticed that Prod is on Summer 14 and Full sandbox is on Winter 15, wondering if this is an issue.

Exact code error we get is “Error - sObject type 'Organization' is not supported" and from all salesforce forums, the only suggested workaround is to use "without sharing" (elevate the access of the page as admin) which ideally we don't want to do.

Thanks,
When I used page-break-inside: avoid; on a <div> contianer in a Visualforce renderAs="pdf" page, it doesn't work as expected. It doesn't have any effect.

What I want to achieve is, when an element is spread out between 2 pages of the pdf, it is automatically put on the next page of the pdf, as if it would have page-break-before: always;.

Does anyone know of this bug, is there a workaround or did someone have good results using page-break-inside: avoid;?