• jkucera
  • SMARTIE
  • 1564 Points
  • Member since 2009

  • Chatter
    Feed
  • 62
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 630
    Replies

Hello all,

 

I have a custom object 'Prospect' and want this to be similar to standard Lead object i.e., a convert button which converts prospect record to Account and Contact.

 

Just an FYI. This is a Force.com enterprise platform where CRM objects (Leads, Campaigns, Opportunities, etc.) are unavailable.

 

Thanks in advance,

VK

  • May 16, 2011
  • Like
  • 0

I have two lead triggers, Before Insert and After Insert. Both are showing null information for some fields. To test I am printing out lead information in the very beginning of Before Insert trigger and lead.Name always shows as Null. But I when open lead in UI the name is filled in correctly. Earlier today they were working just fine. The only changes I made were adding comment blocks for documentation. After that this issue started.

 

Any explanations? Could it be from updating trigger apiVersion from 16.0 to 19.0?

Hello!

I'm trying to create a trigger that will copy the value from a custom lead field called Parent Account to the standard Parent Account field on the account object when the lead is converted.

 

Here is the code I have: 

 

trigger populateParentAccount on Account (before Insert){
  List<Lead> convertedLeads=[SELECT Id, ConvertedAccountID,
  Parent_Account__c FROM Lead
  WHERE IsConverted=True AND ConvertedAccountId IN :trigger.new];
  Map<ID,ID> acctParentMap=new Map<ID,ID>();
  for (lead l: leads){
    acctParentMap.put(l.ConvertedAccountId,l.Parent_Account__c);
  }
  for (account a:trigger.new) {
    if (acctParentMap.containsKey(a.Id)){
      a.Parent_Account__c=acctParentMap.get(a.Id);
    }
  }
}

 

and here is the error message I'm getting: 

 

 Error: Compile Error: Variable does not exist: leads at line 6 column 16 

 

Any ideas what I'm doing wrong??

Hi does anyone have an example of converting a lead in a testmethod???

 

Lead l = new Lead(
    FirstName = 'TestShan',
    LastName = 'RazzTest',
    Email = 'haha@gmail.com');
insert l;

 

How would I convert it in code???

 

Hi All,

 

I am trying to Merge Contacts and Leads using the code example given below for Accounts.

 

 

List<Account> ls = new List<Account>{new Account(name='Acme Inc.'),new Account(name='Acme')};
insert ls;
Account masterAcct = [select id, name from account where name = 'Acme Inc.' limit 1];
Account mergeAcct = [select id, name from account where name = 'Acme' limit 1];
try {
merge masterAcct mergeAcct;
} catch (DmlException e) {
// Process exception here 

}

 

The above code works but when I code on similar lines and change Account to Lead or Contact. I get the error:

Compile Error: Field is not writeable: Contact.Name at line 66.....

Here is what I tried:

List<Contact> ls = new List<Contact>{new Contact(name='Classic Inc.'),new Contact(name='Classic')};
insert ls;
Contact masterAcct = [select id, name from contact where name = 'Classic Inc.' limit 1];
Contact mergeAcct = [select id, name from contact where name = 'Classic' limit 1];
try {
merge masterAcct mergeAcct;
} catch (DmlException e) {
// Process exception here 

}

 

 

 

Thankjs

Hector...

 

 

 

 

Hello - My clients adwords/salesforce is not working properly, can anyone point me in the right direction to get started debugging this?

 

I am trying to locate the API, but all I can manage to find are links to demo videos or powerpoints.

 

Thanks,

Jason

I have the following problem:

 

LastName is a required field on a Lead. Is there a way to change that? I have a requirement stating that Last Name should be optional, but no way to change it. Any ideas?

 

Thank you.

I had read in salesforce help files specifically for WebToCase that there was a limit on creation of cases at 500.

Later, I had read on a page NOT specific to WebToCase this:  "What is the maximum number of web cases we can capture?
In Professional, Enterprise, Unlimited, and Developer Edition organizations, you can capture up to 500 cases a day. If your
company generates more than that, click Help & Training at the top of any page and select the My Cases tab to submit your
request directly to salesforce.com."

This led me to conclude that salesforce limits the number of cases to 500 per day regardless of mechanism used to create (API, Email To Case, Web To Case, entering manually via the web GUI).
I suspect the above quote is misleading and the 500 limit does not apply to API case creation.
However, can someone out there confirm for me that the 500 case limit per day does not apply to ones created via the API or the GUI?
or give added clarification as to which modes have a limit.

At my company, we have an enterprise license. And I do realize the API has is a request limit of N (where N is IIRC 1,000,000 without looking it up).
We use WebToCase and are looking to switch to using the API, but I need this clarification first.

Thank you in advance,
Tom Walters, eHealth Global

Hello. I want to use the Description field in the CampaignMember object for user data entry. However, when I place it on a page layout, it's automatically set to read-only and I can't change it. Is there a way around this? What's the reason for this field to be read-only?

I have multiple Lead Remarks that need to get updated when a lead is converted.  Below is my code, however when it triggers, it only updates the first lead remark.  I need it to update all of them.  I am guessing that I need a for loop in here somewhere, but not sure where.

 

 

trigger UpdateCustomeObject_Trigger on Lead (before update) {
//This trigger will associate a Custom Object record with the contact and opportunity associated to the
//lead after it has been converted.
//The Custom Object is associated to an opportunity only if an opportunity record exist on the Lead.
    for (Integer i = 0; i < Trigger.new.size(); i++){
        if (Trigger.new[i].IsConverted == true && Trigger.old[i].isConverted == false){
            Set<Id> leadIds = new Set<Id>();
            for (Lead lead : Trigger.new)
                leadIds.add(lead.Id);
           
            Map<Id, Lead_Remark__c> entries = new Map<Id, Lead_Remark__c>([select Contact__c, Lead__c from Lead_Remark__c where lead__c in :leadIds]);       
            if(!Trigger.new.isEmpty()) {
                for (Lead lead : Trigger.new)  {
                    for (Lead_remark__c Lead_Remark : entries.values()) {
                        if (Lead_Remark.Lead__c == lead.Id) {
                            Lead_Remark.contact__c = lead.ConvertedContactId;
                            update Lead_Remark;
                            break;
                        }
                    }
                }
            }
        }
    }

}

 

Thanks in advance,

David

  • May 19, 2010
  • Like
  • 0

Hello all,

 

I need to create two new leads when an Opportunity is closed-won and map over some date from Opp to the new leads.

I am a newbie to Apex programming and any pointers how to do this is really appreciated.

 

Thanks much,

VK86

  • May 14, 2010
  • Like
  • 0

A lot of SalesForce objects have a field "Description", and they are usually accessible through the API.

 

So does the object CampaignMember but for some reason it is NOT accessible through the API.

 

Can anyone tell me why that is?

I need to have control over it from Perl.

 

 

Hi,

 

I have a trigger (before Insert) on Campaign Member that would insert tasks to contact/Leads on a campaign whenever a Contact/Lead is added to it.

I am unable to figure out how i can i write a test class to cover that trigger.

 

I am assuming that we need to insert Campaign Member's which would then fire off the trigger.

But how do i insert a campaign member using apex?

 

Can any one help me out on writing this test method.

 

Thanks in advance,

Sales4ce

 

I am creating custom Visualforce pages for a couple of the various record types that I have defined for campaigns.  I would like to include the functionality of the standard "Manage Members" push button (that appears on the standard campaign page. 

 

Is this possible?

 

Thanks,

Barb

  • April 07, 2010
  • Like
  • 0

I need a way to apply lead assignment rules whenever the lead score goes above 99 and the lead review status is complete.

 

Here is my trigger code:

 

 

trigger ApplyLeadAssignmentRules on Lead (before update, before insert) {


    for (Lead l:trigger.new) {


        Decimal score =   l.Score__c;
        String review_status =  l.Review_Status__c;

        if(score == null) score = 0.0;
        if(review_status == null) review_status = '';
            
        if( (score >= 100) && (review_status.equalsIgnoreCase('Complete'))  ){
            Database.DMLOptions dmo = new Database.DMLOptions();
            dmo.assignmentRuleHeader.useDefaultRule = true;
            l.setOptions(dmo);
            Database.update(l);   
        }     

    }


}

 

 

This throws the following exception:

 

Apex script unhandled trigger exception by user/organization:

Source organization:

ApplyLeadAssignmentRules: execution of BeforeUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id ; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 00QQ0000001Q2av) is currently in trigger ApplyLeadAssignmentRules, therefore it cannot recursively update itself: []

 

 

How do I fix this? Any solution?

Hi,

 

We upload leads for different departments: Sales or Marketing

 

I need to indicate which leads are more relevant to the respective department.

 

- I created a multiple picklist in Campaigns:  Sales or Marketing

 

- I want to pull the values in each campaign when a sales rep looks at the Leads object.

 

- I'll create a specific list view for the  Sales or Marketing Departments.

 

 

====

 

I'm having trouble with pulling the values from Campaign Object to the Lead Object.

 

This is what I've done so far:

 

Lead Validation Rule

 Campaign.Department__c 

 

What's the formula to pull the data from Campaigns?

 

Thanks.

 

  • March 15, 2010
  • Like
  • 0

In Apex, how to query contact fields in the same query?

 

Event ev=[Select who.email,who.title from event where Id='xxxxx']; ?

 

If we can't do this way, can someone please advice how i can grab the contact Object values in soql query by quering Event Object?

Message Edited by mavs on 02-26-2010 12:42 PM
  • February 26, 2010
  • Like
  • 0

Hi,

 

Is there any way to control user access to Leads, Accounts or Contacts? Since we have a fair amount of sales rep turnover, we don't want to risk our information being taken to a competitor.

 

Thanks,

Pete

  • February 24, 2010
  • Like
  • 0

Hopefully this is an easy question.

When I sign in to developer.force.com I see lots of options in the App Setup > Develop menu:

Apex Classes 

Apex Triggers 

API 

Components 

Custom Settings 

Email Services 

Pages 

S-Controls 

Sites 

Static Resources 

Tools

 

 

When I sign in to salesforce.com with the trial version I only see these options:

API

Components

Custom Settings

Email Services

Pages

Static Resources

Remote Access 

 

Is there something I can do to make the missing menu options visible?  

Thanks :) 

Hi members.. i have a question about developing apex code in salesforce. i am a fresher completed my masters in management. i trained in salesforcce as admin and developer. but i am worrying about developing apex code for a real time project.could you please tell me what percent of code is written by developers as own and what percent of code will be available from the sources like forums, google, importing the existindg code...... etc.

 

waiting for the responses from all

 

THANKS IN ADVANCE

HARRY

I'm building an app to move Chatter from leads to contact/acct/oppty upon lead conversion.  


I want to allow customers to pick which of the 3 objects to move the feed to (or can be all 3), and want to store that in a custom setting.

 

I figure a VF page is the best way to go to show the settings, but I'm struggling with the some very basic concepts.  How do I:

1) Load the custom setting row when the detail page loads

2) From an "Edit" button on that detail page, pass the record to the edit page

 

My controller code doesn't seem to do either of these right now:

public with sharing class LeadConvertChatterController{
    public final LeadConvertChatter__c lcc;
	public static String settingName='default';

    public LeadConvertChatterController(ApexPages.StandardController controller) {
        this.lcc=getSetting();
    }//LeadConvertChatterCustomSettingsController
    
//need new button that creates the defaults if they aren't there yet.  needs to be hidden if there is a record, and then show the details instead

    public PageReference newSetting(){
        PageReference pageRef=null;
        return pageRef;
    }

    public PageReference editSetting(){
        PageReference pageRef=page.LeadConvertChatterSetupEdit;
        
        return pageRef;
    }

    public LeadConvertChatter__c getSetting(){
        Map<String, LeadConvertChatter__c> settings=LeadConvertChatter__c.getAll();
        if (settings.containsKey(settingName)==FALSE){
            LeadConvertChatter__c setting=new LeadConvertChatter__c(Name=settingName, Contact__c=TRUE, Account__c=FALSE, Opportunity__c=FALSE, MergeLeadContact__c=TRUE);
            insert setting;
            return setting;
        }else{
            LeadConvertChatter__c setting=settings.get(settingName);
            return setting;
        }
    }//getSettings

}//LeadConvertChatterController

 

VF detail page which doesn't seem to take the record assignment in the controller:

<apex:page standardController="LeadConvertChatter__c" extensions="LeadConvertChatterController">
    <apex:sectionHeader title="Lead Convert Chatter Settings" subtitle="Edit Settings" />
    <apex:form >
        <apex:pageBlock title="Edit Settings" id="thePageBlock">
            <apex:pagemessages />
            <b><Font Color="#FF0000"></Font></b>
            <apex:pageBlockButtons >
                <apex:commandButton value="Edit" action="{!editSetting}"/>&nbsp;&nbsp;&nbsp;   
            </apex:pageBlockButtons>        
           <apex:pageBlockSection title="Where should Chatter people posts on the Lead move upon Lead Convert?">
                <table >
                    <tbody>
                    <tr>
                        <td>
                            <apex:outputField value="{!LeadConvertChatter__c.Contact__c}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <apex:outputField value="{!LeadConvertChatter__c.Account__c}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <apex:outputField value="{!LeadConvertChatter__c.Opportunity__c}"/>
                        </td>
                    </tr>
                    </tbody>
                </table>                    

            </apex:pageBlockSection>            

           <apex:pageBlockSection title="Should Chatter posts be moved on Lead or Contact merge?">
                <table>
                    <tbody>
                    <tr>
                        <td>   
                            <apex:outputField value="{!LeadConvertChatter__c.MergeLeadContact__c}"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </apex:pageBlockSection>              
            
        </apex:pageBlock>                            
    </apex:form>
</apex:page>

 

 

  • September 28, 2012
  • Like
  • 0

Either the article is wrong, or there's a bug as the doc says create() is supported on EmailServicesFunction but I can't insert from Apex.

 

Article says allowed methods:

create()delete()describeSObjects()getDeleted()getUpdated()query()retrieve()update()upsert()

 

Error:

DML Not allowed on Email ServicesFunction

 

	String emailServicesFunctionName='g2wSerializeGetRegistrants';
	String emailHandlerApexClassName='g2wEmailHandlerSerializeGetRegistrants';
EmailServicesFunction e=new emailServicesFunction();
				e.functionName=emailServicesFunctionName;
				ApexClass emailHandlerClass=[SELECT Id FROM ApexClass WHERE Name=:emailHandlerApexClassName LIMIT 1];
				e.ApexClassId=emailHandlerClass.Id;
				e.isActive=TRUE;
				e.AddressInactiveAction='0';
				e.AttachmentOption='0';
				e.AuthenticationFailureAction='0';
				e.AuthorizedSenders='';
				e.IsAuthenticationRequired=FALSE;//require uber security? not needed here
				e.IsTlsRequired=FALSE;
				e.OverLimitAction='3';
				insert e;

 

 

At risk of showing how much I suck at UI, I can't get a link to work to point to a detail page.

 

This VF page only shows if there's an error, and I want to show a link to a Chatter Group for some of the errors (let's assume all the time for this thread).

 

How do I do that?

 

If I try to pass the ID from a method to a class var, I get an error "Variable doesn't exist: newGroup"

 

VF:

<apex:page standardController="Opportunity" extensions="createExternalGroupController" action="{!createExternalGroup}">
    <apex:pagemessages />

    <apex:form>

        <apex:pageBlock id="thePageBlock">

                <apex:commandLink id="groupExists" value="Go to Customer Group"  action="{!groupLink}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 Apex:

public with sharing class createExternalGroupController{

    public final Opportunity o;
    public PageReference pageRedirect= new PageReference('');
    public Id newGroup;
    public createExternalGroupController(ApexPages.StandardController controller) {
        this.o=(Opportunity)controller.getRecord();
        pageRedirect=ApexPages.CurrentPage();
    }
    
    public pageReference groupLink(){
        PageReference pageRef=new PageReference('/'+newGroup);
        return pageRef;
    }//opptyLink

    public pageReference methodThatDoesStuff(){
       CollaborationGroup g=new CollaborationGroup();
                g.CollaborationType='Private';
                g.CanHaveGuests=TRUE;
                g.name=groupName;
       insert g;

       newGroup=g.Id;
       return pageRedirect;
    }

 

I just added a NameSpace to my Developer org, and now 2 tests fail with an awful error message.  I'm tempted to just remove the tests so I can actually upload the package.

 

The code hasn't changed, and tests still pass in installed orgs that have the unmanaged package.

 

Error debug lines:

 

21:18:53.48|USER_DEBUG|[7,9]|DEBUG|query string: Select Id, recordId__c FROM chttrunfollow__UnfollowQueue__c WHERE scheduledUnfollowDate__c<= TODAY AND IsDeleted=FALSE
21:18:53.48|METHOD_EXIT|[7,9]|system.debug(String)
21:18:53.48|METHOD_ENTRY|[8,52]|database.query(String)
21:18:53.48|SOQL_EXECUTE_BEGIN|[8,52]|Aggregations:0|Select Id, recordId__c FROM chttrunfollow__UnfollowQueue__c WHERE scheduledUnfollowDate__c<= TODAY AND IsDeleted=FALSE
21:18:53.51|SOQL_EXECUTE_END|[8,52]|Rows:3
21:18:53.51|METHOD_EXIT|[8,52]|database.query(String)
21:18:53.51|METHOD_ENTRY|[9,9]|system.debug(String)
21:18:53.51|METHOD_ENTRY|[9,31]|LIST<chttrunfollow__UnfollowQueue__c>.size()
21:18:53.52|METHOD_EXIT|[9,31]|LIST<chttrunfollow__UnfollowQueue__c>.size()
21:18:53.52|USER_DEBUG|[9,9]|DEBUG|size: 3
21:18:53.52|METHOD_EXIT|[9,9]|system.debug(String)
21:18:53.52|METHOD_ENTRY|[10,16]|Database.getQueryLocator(String)
21:18:53.52|SOQL_EXECUTE_BEGIN|[10,16]|Aggregations:0|Select Id, recordId__c FROM chttrunfollow__UnfollowQueue__c
21:18:53.77|SOQL_EXECUTE_END|[10,16]|Rows:3
21:18:53.77|METHOD_EXIT|[10,16]|Database.getQueryLocator(String)
21:18:53.105|FATAL_ERROR|Internal Salesforce.com Error

 I saw this thread, and added my namespace, but no luck:

http://community.salesforce.com/t5/Visualforce-Development/Visualforce-An-internal-server-error-has-occurred/m-p/167376

 

Class that produces the above error:

 

global with sharing class UnfollowProcessUnfollowQueueBatch implements Database.Batchable<sObject>{

   global String sObjectQuery ='Select Id, recordId__c FROM chttrunfollow__UnfollowQueue__c WHERE scheduledUnfollowDate__c<= TODAY' ;
   
   global Database.QueryLocator start(Database.BatchableContext BC){
        system.debug('query string: '+sObjectQuery);
        List<chttrunfollow__UnfollowQueue__c> uq = database.query(sObjectQuery);
        system.debug('size: '+uq.size());
        return Database.getQueryLocator(sObjectQuery);
   }

   global void execute(Database.BatchableContext BC, List<sObject> scope){
        Set<Id> recordIds=new Set<Id>();
  
        for(sObject s : scope){
            recordIds.add(String.ValueOf(s.get('recordId__c')));
        }//for
    
        //This is the method that unfollows all people from the records 
        try{
            UnfollowRecords.UnfollowRecordsButtonAction(recordIds);
            delete scope;
        } catch (Exception e) {
        }//try
   }

   global void finish(Database.BatchableContext BC){
       AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email from AsyncApexJob where Id =:BC.getJobId()];
  }

}//UnfollowRecordsFromDelayQueueBatch

Other Class that calls this class:

 

global with sharing class unfollowTryBatchJobsAgain{

    public static void unfollowTryBatchJobsAgain(){
        Integer numBatchApexJobsLimit=5;//at time of coding, there are at most 5 concurrent batch apex jobs in any org
        List<AsyncApexJob> numBatchJobs = [SELECT Id, Status FROM AsyncApexJob WHERE Status = 'Queued' OR Status = 'Processing'];

        //This is the number of jobs that can be queued up by this method
        Integer numJobsAvailable=numBatchApexJobsLimit - numBatchJobs.size();

        if(numJobsAvailable>0){
            List<UnfollowBatchJobsQueue__c> batchJobsQueued=[SELECT Id, IsDeleted, delayJob__c, delayRulesIncluded__c, evalateEachRecordForDaysDelay__c, numRulesUsedInThisObject__c, objectName__c, sObjectQuery__c FROM UnfollowBatchJobsQueue__c WHERE IsDeleted=FALSE ORDER BY  CreatedDate ASC];
            //Goal here is to process the delay queue first as it's more important than the others. Rather than do 2 queries, it's handled with variables here:
            Integer delayJobNum=1000;//initialize to huge number as a backup
            for (Integer i=0;i<batchJobsQueued.size();i++){
                if (batchJobsQueued[i].delayJob__c==TRUE){
                    delayJobNum=i;
                    break;
                }//if 2
            }//for 1
            
            for(Integer i=0; i<numJobsAvailable && i<batchJobsQueued.size(); i++){
                //if this is the high priority "delayed records scheduled for unfollow today" job, do it first
                if (delayJobNum!=1000){
                    UnfollowProcessUnfollowQueueBatch unfollowDelayedRecords= new UnfollowProcessUnfollowQueueBatch();
                    unfollowDelayedRecords.sObjectQuery=batchJobsQueued[delayJobNum].sObjectQuery__c;
                    try{
                        Id unfollowRulesProcessId = Database.executeBatch(unfollowDelayedRecords, 200); 
                        delete batchJobsQueued[delayJobNum];
                    } catch(exception e){
//                        system.debug('Either the batch failed or the job deletion from teh queue failed: '+e);
                    }//try
                } else if(batchJobsQueued[i].delayRulesIncluded__c==FALSE){
                 //is this the simple case with no "days delay" rules?
                    UnfollowRecordsBatch  unfollowRecords= new UnfollowRecordsBatch();
                    unfollowRecords.ObjectName=batchJobsQueued[i].objectName__c;
                    unfollowRecords.numRulesUsedInThisObject=batchJobsQueued[i].numRulesUsedInThisObject__c.intValue();
                    unfollowRecords.sObjectQuery =  batchJobsQueued[i].sObjectQuery__c;
                
                    try{
                        Id unfollowRulesProcessId = Database.executeBatch(unfollowRecords, 200); 
                        delete batchJobsQueued[i];
                    } catch(exception e){
//                        system.debug('Either the batch failed or the job deletion from the queue failed: '+e);
                    }//try
                } else {
                //else it's the more complex case where we need to check for the unfollow date
                    UnfollowQueueDelayRecordsBatch queueDelayRecords= new UnfollowQueueDelayRecordsBatch();
                    queueDelayRecords.ObjectName=batchJobsQueued[i].objectName__c;
                    queueDelayRecords.sObjectQuery =  batchJobsQueued[i].sObjectQuery__c;
                    queueDelayRecords.evalateEachRecordForDaysDelay=batchJobsQueued[i].evalateEachRecordForDaysDelay__c;
                    if(queueDelayRecords.evalateEachRecordForDaysDelay==TRUE){
//let's cross our fingers that the rule criteria didn't change between when this job first ran and now :(  
//Will the code fail elegantly if the rules were changed?
//I'd rather not create a 3rd queue just to save the state of the rules due to stupid batch apex limits
                        queueDelayRecords.delayRules=[Select Id, ObjectName__c, Active__c, FieldName__c, FieldType__c, Operator__c, Value__c, DaysDelay__c FROM UnfollowRule__c WHERE DaysDelay__c>0 AND Active__c = TRUE AND objectName__c=:queueDelayRecords.ObjectName]; 
                    }//if 3

                    try{
                        Id unfollowRulesProcessId = Database.executeBatch(queueDelayRecords, 200); 
                        delete batchJobsQueued[i];
                    } catch(exception e){
//                        system.debug('Either the batch failed or the job deletion from the queue failed: '+e);
                    }//try
                }//if 2
            }//for 1
        }//if 1
        
/*                        
        //This will store the job definition for the jobs over the numBatchApexJobsLimit to be run later
        List<UnfollowBatchJobsQueue__c> batchJobsQueued=new List<UnfollowBatchJobsQueue__c>();

        List<UnfollowRule__c> activeNonDelayedRules=[Select Id, ObjectName__c, Active__c, FieldName__c, FieldType__c, Operator__c, Value__c, DaysDelay__c FROM UnfollowRule__c WHERE (DaysDelay__c<1 OR DaysDelay__c=null) AND Active__c = TRUE];
        
        //now count the # rules for each object to pass into the email later
        For (UnfollowRule__c rule:activeNonDelayedRules){
            List<UnfollowRule__c> rules=new List<UnfollowRule__c>();
            if(objectRulesMap.containsKey(rule.ObjectName__c)){
                //get the existing rules in the map & add the new one
                rules=objectRulesMap.get(rule.ObjectName__c);
                rules.add(rule);
                objectRulesMap.remove(rule.ObjectName__c);
                objectRulesMap.put(rule.ObjectName__c, rules);
            } else {
                rules.add(rule);
                objectRulesMap.put(rule.ObjectName__c,rules);
            }//if 1
        }//for 1

        //Now queue up all the batch jobs
        for (String objectName:objectRulesMap.keyset()){
            //First check if there's a slot available - max of 5 concurrent jobs across all apps
            addFieldNames=FALSE;            
            query=buildQuery(objectName, objectRulesMap.get(objectName), addFieldNames);
            if(numJobsAvailable>0){
                numJobsAvailable--;//subtract one from the limit
                UnfollowRecordsBatch  unfollowRecords= new UnfollowRecordsBatch();
                unfollowRecords.ObjectName=objectName;
    
                unfollowRecords.numRulesUsedInThisObject=objectRulesMap.get(objectName).size();
                unfollowRecords.sObjectQuery =  query;
//                system.debug('The sObjectQuery string is: '+unfollowRecords.sObjectQuery);
                
                Id unfollowRulesProcessId = Database.executeBatch(unfollowRecords, 200); 
            }else{
                String sObjectQuery = query;
//                system.debug('There are 5 batch jobs already running, so this job is not scheduled.  Delay Job: TRUE, Object: '+objectName+', # Rules: '+objectRulesMap.get(objectName).size()+', Query: '+sObjectQuery );
                UnfollowBatchJobsQueue__c job=new UnfollowBatchJobsQueue__c(delayJob__c=FALSE, delayRulesIncluded__c=FALSE, objectName__c=objectName, numRulesUsedInThisObject__c=objectRulesMap.get(objectName).size(), sObjectQuery__c=sObjectQuery);
                batchJobsQueued.add(job);
            }//if 1
        }//for 1
        try{
            if(batchJobsQueued.size()>0){
                insert batchJobsQueued;
            }//if 1
        }catch (DMLException e){
//            system.debug('The batch jobs were not added to the queue successfully, likely due to dupe object name.  Error: '+e);
        }//try
*/        
    }//unfollowTryBatchJobsAgain
}//unfollowTryBatchJobsAgain

 

 

 

 

I'm trying to create an app that lets customers select an opportunity field from a picklist, and IsClosed is the primary field most will use.

 

However, my describe calls don't return it, likely because it is not truly an oppty field but rather an OpportunityStage field.

 

Is there any simple way to return IsClosed using an oppty describe call?

 

Code that populates the field list.  Note that ObjectName is dynamic - assume for this question it is equal to Opportunity.  Note I remove a bunch of field types, but IsClosed isn't a Reference type, and I'm pretty sure it isn't any of the others (anytype, base64, etc)

 

    public List<selectOption> getFieldNames(){
        List<selectOption> options=new List<selectOption>();
        List<String> fieldLabels=new List<String>();//included to create a sorted field name list
        Map<String,String> fieldLabelNameMap=new Map<String,String>();
        Boolean evaluateFields=False;
        
        if(u.ObjectName__c!=null){
            evaluateFields=True;
        }
 
        if (evaluateFields){//if 1    
            SObjectType objToken = Schema.getGlobalDescribe().get(u.ObjectName__c); //assume this equals Opportunity
            DescribeSObjectResult objDef = objToken.getDescribe();
            Map<String, SObjectField> fieldMap = objDef.fields.getMap();//this doesn't return IsClosed as far as I can tell

            options.add(new selectOption('',''));
            
            for (String fName:fieldMap.keySet()){//for 1
                //Disallow unsupported field types

                //This disallows the unsupported types: text area, anytype, encrypted string, multiselect picklists, lookup fields, base64, reference fields, and URL's
                if(fieldMap.get(fName).getDescribe().getType()!=Schema.DisplayType.anytype&&fieldMap.get(fName).getDescribe().getType()!=Schema.DisplayType.base64&&fieldMap.get(fName).getDescribe().getType()!=Schema.DisplayType.EncryptedString&&fieldMap.get(fName).getDescribe().getType()!=Schema.DisplayType.Id&&fieldMap.get(fName).getDescribe().getType()!=Schema.DisplayType.MultiPicklist&&fieldMap.get(fName).getDescribe().getType()!=Schema.DisplayType.Reference&&fieldMap.get(fName).getDescribe().getType()!=Schema.DisplayType.TextArea){
                    //Disallow fields that aren't updatable
                    if(fieldMap.get(fName).getDescribe().isUpdateable()==True){
                        fieldLabels.add(fieldMap.get(fName).getDescribe().getLabel());                  
                        fieldLabelNameMap.put(fieldMap.get(fName).getDescribe().getLabel(), fName);
                    }//if 3    
                }//if 2
            }//for 1
            fieldLabels.sort();
            for (String fLabel:fieldLabels){//for 1
                    options.add(new selectOption(fieldLabelNameMap.get(fLabel),fLabel));
                }//if 2
            }//for 1    
        }//if 1

        return options;
    }//getFieldNames

 

 

  • September 05, 2010
  • Like
  • 0

1% of installers surface this error to me every time the Lead trigger in the app fires:

 

Apex script unhandled exception by user/organization: 00560000000nYMJ/00D30000000039c

Failed to invoke future method 'public static void evaluateLeads(SET:Id)'

caused by: System.NullPointerException: Attempt to de-reference a null object

(leadScoring)


External entry point

Debug Log:

 

Any ideas why the class LeadScoring would be null and the method call fails? 

 

This Lead trigger calls the class, which should exist upon install unless something went wrong:

 

trigger evaluateLeadScoringRulesLeadInsertOrUpdate on Lead (After insert, After update) {

Set<Id> leadIds=new Set<Id>();

//Needed as asynch apex does not allow passage of Sobjects, only Set's
for (Lead l:trigger.new){
leadIds.add(l.Id);
}//for

//Send that list of created or updated campaign members to the apex class for processing
system.debug('Future lead scoring method evaluateLeads already called? '+LeadScoring.leadScoringClassAlreadyCalled());
if (LeadScoring.leadScoringClassAlreadyCalled()==False){
system.debug('# Future Calls until limit hit: '+Limits.getLimitFutureCalls());
if (Limits.getLimitFutureCalls()>0){//don't call the method if the limit is reached
LeadScoring.evaluateLeads(leadIds);
}
}
}//trigger

 

Class called from the trigger that seems to be the source of the NPE:

 

public global class LeadScoring {

public static Boolean leadScoringClassAlreadyCalled=FALSE;

public static boolean leadScoringClassAlreadyCalled(){
return leadScoringClassAlreadyCalled;
}

@future //this method is called from the trigger. It's an asynch method so the trigger call has high governor limits
public static void evaluateLeads(Set<Id> leadIds){
evaluateLeads2(leadIds);
}//evaluateLeads

//this method is called from batch apex. It cannot be an asynch method as batch apex can't call @future methods
public static void evaluateLeads2(Set<Id> leadIds){
Integer i,j;
Double scoreChange;//safer to define as a double in case anyone tries to change the field's # decimals
Schema.DescribeFieldResult cmFieldDescribe;
leadScoringClassAlreadyCalled=TRUE;
...
...

 

Thanks for the help!

I have a managed package that works for 99% of installers, but 2 are returning these email errors to me:

 

 

Apex script unhandled exception by user/organization: 00560000000nYMJ/00D30000000039c

Failed to invoke future method 'public static void evaluateLeads(SET:Id)'

caused by: System.NullPointerException: Attempt to de-reference a null object

(leadScoring)


External entry point

Debug Log:

 

This trigger calls a bigger class, which should exist upon install unless something went wrong:

 

trigger evaluateLeadScoringRulesLeadInsertOrUpdate on Lead (After insert, After update) {

Set<Id> leadIds=new Set<Id>();

//Needed as asynch apex does not allow passage of Sobjects, only Set's
for (Lead l:trigger.new){
leadIds.add(l.Id);
}//for

//Send that list of created or updated campaign members to the apex class for processing
system.debug('Future lead scoring method evaluateLeads already called? '+LeadScoring.leadScoringClassAlreadyCalled());
if (LeadScoring.leadScoringClassAlreadyCalled()==False){
system.debug('# Future Calls until limit hit: '+Limits.getLimitFutureCalls());
if (Limits.getLimitFutureCalls()>0){//don't call the method if the limit is reached
LeadScoring.evaluateLeads(leadIds);
}
}
}//trigger

 

 

Class called from the trigger that seems to be the source of the NPE:

 

public global class LeadScoring {

public static Boolean leadScoringClassAlreadyCalled=FALSE;

public static boolean leadScoringClassAlreadyCalled(){
return leadScoringClassAlreadyCalled;
}

@future //this method is called from the trigger. It's an asynch method so the trigger call has high governor limits
public static void evaluateLeads(Set<Id> leadIds){
evaluateLeads2(leadIds);
}//evaluateLeads

//this method is called from batch apex. It cannot be an asynch method as batch apex can't call @future methods
public static void evaluateLeads2(Set<Id> leadIds){
Integer i,j;
Double scoreChange;//safer to define as a double in case anyone tries to change the field's # decimals
Schema.DescribeFieldResult cmFieldDescribe;
leadScoringClassAlreadyCalled=TRUE;
...
...

 

 

Could these be caused by:

 

 

  1. No apex perms for the running user?
  2. Bad package install?
  3. No @future perms for the running user?
As this is a managed package, the customer can't do much to debug either. 

I'm an integrations n00b and can't get a basic XML post to work as I've been receiving an error.  Is this an Apex error or a received error from the other site?

 

system.CalloutException: no protocol:

 

<?xml version="1.0" encoding="ISO-8859-1"?>
<serv:message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<securityContext>
<webExID>jkucera</webExID>
<password>Jdk47012</password>
<siteID>243585</siteID>
<partnerID>g0webx!</partnerID>
</securityContext>
</header>
<body>
<bodyContent xsi:type="java:com.webex.service.binding.meeting.LstsummaryMeeting"><listControl><maximumNum>5</maximumNum></listControl><order><orderBy>STARTTIME</orderBy></order></bodyContent>
</body>
</serv:message>

 

I'm trying to get the XML file from this URL, and I'm fairly confident in my login credentials:

 

https://apidemoeu.webex.com/WBXService/XMLService

 

 My Apex method that attempts the HttpRequest get:

 

 

public static void callWebEx(String[] args)
{
WebEx_Login__c wec=[Select Id, siteName__c, xmlURL__c, siteId__c, partnerId__c, webExId__c, password__c, xmlServerURL__c FROM WebEx_Login__c LIMIT 1];

String siteName = wec.siteName__c; // WebEx site name
String xmlURL = wec.xmlURL__c; // XML API URL
String siteID = wec.siteId__c; // Site ID
String partnerID = wec.partnerId__c; // Partner ID
String webExID = wec.webExId__c; // Host username
String password = wec.password__c; // Host password
String xmlServerURL = wec.xmlServerURL__c;

String reqXML = '<?xml version="1.0" encoding="ISO-8859-1"?>\r\n';
reqXML += '<serv:message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"';
reqXML+='>\r\n';

reqXML += '<header>\r\n';
reqXML += '<securityContext>\r\n';
reqXML += '<webExID>' + webExID + '</webExID>\r\n';
reqXML += '<password>' + password + '</password>\r\n';
reqXML += '<siteID>' + siteID + '</siteID>\r\n';
reqXML += '<partnerID>' + partnerID + '</partnerID>\r\n';
reqXML += '</securityContext>\r\n';
reqXML += '</header>\r\n';
reqXML += '<body>\r\n';
reqXML += '<bodyContent xsi:type="java:com.webex.service.binding.meeting.LstsummaryMeeting">';
reqXML += '<listControl>';
reqXML += '<maximumNum>5</maximumNum>';
reqXML += '</listControl>';
reqXML += '<order>';
reqXML += '<orderBy>STARTTIME</orderBy>';
reqXML += '</order>';
reqXML += '</bodyContent>\r\n';
reqXML += '</body>\r\n';
reqXML += '</serv:message>\r\n';
system.debug('ReqXML: '+reqXML);

System.debug('XML Request POSTed to ' + xmlServerURL + '\n');
System.debug(reqXML+'\n');

Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(reqXML);
req.setMethod('GET');
try{
HttpResponse res = http.send(req);//point of failure
system.debug('Status: '+res.getStatus());
system.debug('Status_Code: '+res.getStatusCode());
system.debug('Body: '+res.getBody());

XmlStreamReader reader = res.getXmlStreamReader();

while(reader.hasNext()) {
System.debug('Event Type:' + reader.getEventType());
if (reader.getEventType() == XmlTag.START_ELEMENT) {
System.debug(reader.getLocalName());
}//if
reader.next();
}//while
}catch(system.CalloutException e){
system.debug('Response Callout Exception: '+e);
}//try

}

 

 

 

 

 

Message Edited by jkucera on 02-09-2010 09:01 PM

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

 

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

  

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

 

 

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

To share with the community a discussion I had with another customer, here's the basics for a trigger that checks the campaign member HasResponded field and changes the Opportunity Primary Campaign Source. 

 

This could modified for whatever criteria you want PrimaryCampaignSource to use.

 

trigger checkPrimaryCampaignSource on Opportunity (before update) {
for (Opportunity o: Trigger.new) {
Lead l = [SELECT id,converteddate FROM Lead WHERE ConvertedOpportunityId =:o.ID LIMIT 1];
try {
if(l.converteddate!=null){
CampaignMember cm = [Select id,Status, HasResponded FROM campaignmember WHERE LeadId=:l.id AND CampaignId=:o.Campaign.id];
if (cm.HasResponded ==false){
o.CampaignId=null;
}
}
} catch (Exception e){
system.debug('error: ' +e);
}
}

 


}
Message Edited by jkucera on 12-21-2009 04:37 PM

can any body please help me with,how to add members to a collaboration group using trigger..

 

Any help would be helpfull..

 

Thanks in Advance!!!

  • February 19, 2013
  • Like
  • 0

I am able to successfully run my flow and update my record from the flow itself but when I run the flow from my visualforce page (that is accessible to the public) I cannot get the flow to complete - and update the record. I get the "authorization required" page and the record does not update. Any thoughts on what I am doing wrong?

 

I have the most current version activated am 99% sure I have the public access settings for the site configured correctly.

 

My flow is a survey and the record update happens on the campaign record for that specific program. The survey starts with the user entering the date of the program, this generates a list (dynamic choice) of programs with a start date of the date entered on the first screen. The user selects which program they want to survey and then proceed through the survey questions. I then have a summary screen that displays the answers they just provided and when they click "next" it should update the record and take them to the last screen. Instead, I get an error and the record does not update.

 

I have the following filter on the record update:

 

Update CAMPAIGN that meet the following criteria: ID equals varProgramID. (varProgramID pulls the campaign record ID from the program that is selected from the dynamic choice-generated list).

 

Any insights would be greatly appreciated!

I'm building an app to move Chatter from leads to contact/acct/oppty upon lead conversion.  


I want to allow customers to pick which of the 3 objects to move the feed to (or can be all 3), and want to store that in a custom setting.

 

I figure a VF page is the best way to go to show the settings, but I'm struggling with the some very basic concepts.  How do I:

1) Load the custom setting row when the detail page loads

2) From an "Edit" button on that detail page, pass the record to the edit page

 

My controller code doesn't seem to do either of these right now:

public with sharing class LeadConvertChatterController{
    public final LeadConvertChatter__c lcc;
	public static String settingName='default';

    public LeadConvertChatterController(ApexPages.StandardController controller) {
        this.lcc=getSetting();
    }//LeadConvertChatterCustomSettingsController
    
//need new button that creates the defaults if they aren't there yet.  needs to be hidden if there is a record, and then show the details instead

    public PageReference newSetting(){
        PageReference pageRef=null;
        return pageRef;
    }

    public PageReference editSetting(){
        PageReference pageRef=page.LeadConvertChatterSetupEdit;
        
        return pageRef;
    }

    public LeadConvertChatter__c getSetting(){
        Map<String, LeadConvertChatter__c> settings=LeadConvertChatter__c.getAll();
        if (settings.containsKey(settingName)==FALSE){
            LeadConvertChatter__c setting=new LeadConvertChatter__c(Name=settingName, Contact__c=TRUE, Account__c=FALSE, Opportunity__c=FALSE, MergeLeadContact__c=TRUE);
            insert setting;
            return setting;
        }else{
            LeadConvertChatter__c setting=settings.get(settingName);
            return setting;
        }
    }//getSettings

}//LeadConvertChatterController

 

VF detail page which doesn't seem to take the record assignment in the controller:

<apex:page standardController="LeadConvertChatter__c" extensions="LeadConvertChatterController">
    <apex:sectionHeader title="Lead Convert Chatter Settings" subtitle="Edit Settings" />
    <apex:form >
        <apex:pageBlock title="Edit Settings" id="thePageBlock">
            <apex:pagemessages />
            <b><Font Color="#FF0000"></Font></b>
            <apex:pageBlockButtons >
                <apex:commandButton value="Edit" action="{!editSetting}"/>&nbsp;&nbsp;&nbsp;   
            </apex:pageBlockButtons>        
           <apex:pageBlockSection title="Where should Chatter people posts on the Lead move upon Lead Convert?">
                <table >
                    <tbody>
                    <tr>
                        <td>
                            <apex:outputField value="{!LeadConvertChatter__c.Contact__c}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <apex:outputField value="{!LeadConvertChatter__c.Account__c}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <apex:outputField value="{!LeadConvertChatter__c.Opportunity__c}"/>
                        </td>
                    </tr>
                    </tbody>
                </table>                    

            </apex:pageBlockSection>            

           <apex:pageBlockSection title="Should Chatter posts be moved on Lead or Contact merge?">
                <table>
                    <tbody>
                    <tr>
                        <td>   
                            <apex:outputField value="{!LeadConvertChatter__c.MergeLeadContact__c}"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </apex:pageBlockSection>              
            
        </apex:pageBlock>                            
    </apex:form>
</apex:page>

 

 

  • September 28, 2012
  • Like
  • 0

Hi,

 

We have an Apex app that will make occasional web service calls to our own web site. We use OAuth to authenticate the SF user against our provider. In order to successfully make the call from SF to us, our Apex app needs to know the consumer key and secret required to create and sign the request.

 

We need to store the consumer key and secret somewhere in SF, but it needs to be protected. Ideally, we would like these values to be shipped with our managed package so our customers do not need to manually enter the key and secret into Salesforce.

 

Is there a best practice to include sensitive information, particular the OAuth consumer key and secret, in a SF managed package? If not, what are the alternatives?

 

Thanks,

 

Steve

I'm an OAuth noob and strugging to get a login page to pop up where Apex is the client and GoToWebinar is the Service.  How do I make the login screen pop up?  Does it somehow magically take over the VF page via redirect or do I need some javascript to open a new window?  Below is my attempted approach using HttpRequest:

 

My first attempt is something like this:

public class G2WButtonController{
    public G2WButtonController(ApexPages.StandardController stdController){
    }
    
    //Code that will run upon button click
    public void autoRun(){
        callG2W(args);
    }

    public static void callG2W(String[] args) 
    {
        String postURL='https://api.citrixonline.com/oauth/authorize?client_id=<myClientId>';
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(postURL);
        req.setMethod('POST');
        HttpResponse res = http.send(req);

        //Class to parse the results
        XmlStreamReader reader = res.getXmlStreamReader();
    }
}

 VF

<apex:page standardController="G2W_Login__c" extensions="G2WButtonController" action="{!autoRun}">
  <apex:pagemessages />

    <apex:sectionHeader title="Auto-Running Apex Code"/>
  <apex:outputPanel >
      You tried calling Apex Code from a button.  If you see this page, something went wrong.  You should have
      been redirected back to the record you clicked the button from.
  </apex:outputPanel>

</apex:page>

 Once I get the login page to pop up, I'm assuming I would then parse the HttpResponse to get a param from the redirect URL- is that correct?

 

Any code samples others have would be greatly appreciated!

Some quick background on merges and Apex triggers:

When a User merges Leads or Contacts, the merge losers are deleted and the
merge winners are updated with the fields chosen by the User in the merge UI.

The only way to detect a merge in Apex triggers is to trigger "after delete" on
the loser records and check them for the "MasterRecordId" field.  If present,
the record being deleted is a merge loser, and the "MasterRecordId" points to
the merge winner.

(this is all covered in the docs )

As stated in the docs, the losers are deleted before the merge winner is
updated with the fields chosen by the User in the UI.

So, let's say that I merge two Leads: Lead A ("a@test.com") and Lead B
("b@test.com").  In the UI I choose Lead A as the master record (winner), but
in the "decide between conflicting fields" UI I choose "b@test.com" as the
Email address to use for the winner.

Two DML ops happen:

 

DELETE loser (via merge)
Trigger.old = { LastName = "B", Email = "b@test.com" }

UPDATE winner (via merge)
Trigger.old = { LastName = "A", Email = "a@test.com" }
Trigger.new = { LastName = "A", Email = "b@test.com" }


However, if we update the winner during the loser delete trigger (the only time
we can detect a merge, remember) ... then something buggy happens.

Our application does exactly this, by detecting merges and copying the loser's

Email address into a custom "OtherEmails" field of the winner.  (this isn't just
arbitrary, there's a good reason for it).


So, during the "DELETE loser" trigger, we update the winner like so:

DELETE loser (via merge)
Trigger.old = { LastName = "B", Email = "b@test.com" }
{
// our custom trigger code
Lead winner = [select Id, Email, OtherEmails from Lead where Id = '<winnerId>']
winner.OtherEmails += loser.Email
update winner;
// this update of course fires triggers too, which would look like this:
UPDATE winner (via standard update)
Trigger.old = { LastName = "A", Email = "a@test.com", OtherEmails = null }
Trigger.new = { LastName = "A", Email = "a@test.com", OtherEmails = "b@test.com" }
}

 

The bug happens in the merge-driven winner update, where SFDC should be
applying the fields chosen by the User during conflict resolution.

The fields chosen by the User are simply gone.  They never get updated into the
winner.  Instead, an update fires that looks like this:

UPDATE winner (via merge)
Trigger.old = { LastName = "A", Email = "a@test.com", OtherEmails = null }
Trigger.new = { LastName = "A", Email = "a@test.com", OtherEmails = "b@test.com" }

 
The User's choice of "Email = b@test.com" is simply gone ... instead this
merge-driven update is a duplicate of the update that happen in the loser's
delete trigger.


What do I expect to happen?

This is a tricky situation, hence the title of this post.  With the present
order of operations - with the loser delete happening before the winner update,
and with the merge only being detectable in the loser delete, I can't think of
any good way to resolve conflicts between trigger-driven winner updates and the
user-selected winner updates.  A couple other changes may fix the issue:

1.  Update the winner before deleting the loser.

This way, custom merge logic (in loser-delete triggers) would be working with a
Winner that's already been updated with the User-selected fields.

Of course, this is a breaking change for implementations that rely on the
current behavior (though I don't see how they could), and there are probably
good reasons for the current order of operations that I can't think of but
which are obvious to SFDC's devs.

2.  Provide an actual "after merge" trigger that provides the losers & winners at the same time.

This "after merge" trigger would be just like an "after update" trigger (ie,
Trigger.old/new contain the pre- and post-update state of the Winners), plus a
new contact variable Trigger.mergeLosers that contains what you would expect.

 

 

 

Salesforce support - i have created case 05650893 to track this issue.

  • June 21, 2011
  • Like
  • 1

Hi, I'm trying to create a custom button to convert leads into accounts, but NOT contacts.

 

Is there anyway to do this? I don't know how to create Salesforce buttons at all.

Hello. I want to use the Description field in the CampaignMember object for user data entry. However, when I place it on a page layout, it's automatically set to read-only and I can't change it. Is there a way around this? What's the reason for this field to be read-only?
 

hi,

 

is there any way to list out all the objects available in a n SF instance?

 

i'm using JAVA and an enterprise WSDL.

 

please help to solve this issue.

 

 

regards,

MM Praneeth

I need a way to apply lead assignment rules whenever the lead score goes above 99 and the lead review status is complete.

 

Here is my trigger code:

 

 

trigger ApplyLeadAssignmentRules on Lead (before update, before insert) {


    for (Lead l:trigger.new) {


        Decimal score =   l.Score__c;
        String review_status =  l.Review_Status__c;

        if(score == null) score = 0.0;
        if(review_status == null) review_status = '';
            
        if( (score >= 100) && (review_status.equalsIgnoreCase('Complete'))  ){
            Database.DMLOptions dmo = new Database.DMLOptions();
            dmo.assignmentRuleHeader.useDefaultRule = true;
            l.setOptions(dmo);
            Database.update(l);   
        }     

    }


}

 

 

This throws the following exception:

 

Apex script unhandled trigger exception by user/organization:

Source organization:

ApplyLeadAssignmentRules: execution of BeforeUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id ; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 00QQ0000001Q2av) is currently in trigger ApplyLeadAssignmentRules, therefore it cannot recursively update itself: []

 

 

How do I fix this? Any solution?

On the standard CampaignMember object, I have a custom lookup field that I am trying to populate....It links to the Lead object and is called "SFDC_Lead__c".

 

I'm trying to create a trigger that populates this fields with the value from the standard campaignmember field "Lead".  This is what I have so far, although it doesn't work:

 

trigger SetCampaignMemberLeadField on CampaignMember (before insert, before update) {    for (CampaignMember a : Trigger.new) {        a.SFDC_Lead__c = a.Lead.Id;    }}

 

Hi,

 

I have a requirement like I need to group all the opportunities assigned to the campaign based on the stage field of the opportunity. I need to filter the campaigns based on some custom fields like product and Region. How an we join these two objects to get my requirement.

Its urgent...

Please post the solution if any body knows......

 

Thanks,

 

Suresh.

I am trying to figure out how to make the Primary Campaign Source button in the leads area so that when I convert it just goes through and I don't need to reenter it. I know how to create buttons and new fields, but this does not give me this option of one that carries through. Customer service says they know it can be done with a formula, but don't know how to do it so they suggested this board.
  • August 14, 2009
  • Like
  • 0

Currently my organization is using PE. I am trying to develop a lead scoring system and want to figure out how I can total or count the number of campaigns a lead responds to. We have leads that will responded to more than one campaign but I don't know a way to include this information.

 

Is it possible to create a formula field that can total # of campaigns responded to in PE? Thanks for any assistance!

 

Respectfully, 

 

Jared