• krisp
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies

Hi All,

 

Just a question regarding web-to-lead.  My client has a four (4) step registration process in their website.

 

Step 1 contains Name, Surname, Email Address, Step 2 has address information, Step 3 is custom fields, including Step 4.  Now, they want to create a Lead record in Salesforce immediately after the lead inserts their information and clicks "next" in Step 1.  Should they also fill in Step 2's information, they want to update the Lead in Salesforce with this information (address), etc.

 

So I need a way of querying SF for the inserted record (using email address) and updating this with the new info.  Do I do this in the PHP code, or in Salesforce (query incoming web to Lead records).

 

Any help is very much appreciated.

 

Thanks in advance.

  • March 28, 2012
  • Like
  • 0

Hi All,

 

I am struggling with my web-to-lead form, it is not populating the vaules prodived in the form, in Salesforce.  My site has four steps a user must go through, Step 1 takes the Contact Details, and the last step does the submission:

 

Any help is much appreciated, thank you, site is http://dev2.roimedia.co.za/vantagefx-com/testform

 

STEP1:

<form class="formular roi_form" id="individualForm" method="post" action="#"><input id="00N90000002JIvi" type="hidden" value="MT4" title="Platform" name="00N90000002JIvi"><input type="hidden" value="3" name="00N90000001sJbd"><input id="00N90000002gWIe" type="hidden" value="ETFX65792" size="20" name="00N90000002gWIe" maxlength="20"><input id="lead_source" type="hidden" value="VFX Ac2" name="lead_source"><input id="00N90000002oqaA" type="hidden" value="41.135.64.38" name="00N90000002oqaA"><input type="hidden" value="00Dd0000000eDrk" name="oid"><input type="hidden" value="http://www.vantagefx.com/get-trading/choose-region/australian-or-international/international-application/thank-you" name="retURL"><input type="hidden" id="ga-page" name="ga-page" value="/personal-details" /><div class="form_progress_bar_step_1"></div><fieldset><input type="hidden" value="2" name="nextstep" id="nextstep" /><input type="hidden" name="eaf5234d9fb03b9c897da0c29c49974d" value="1" /><input type="hidden" name="1cf1" value="c8b641db5c041d8d5df714bb67af2734" /><div class="form_top"><h3>Personal Details</h3><div class="required"><span>*</span> Required</div></div><div class="form_grey_back"><div class="form_grey_item"><select id="title" size="1" name="title" class="validate[required] text-input chosen_title" style="width: 155px; top: 2px;"><option value="">*Title</option><option value="Mr" selected="selected">Mr</option><option value="Mrs">Mrs</option><option value="Miss">Miss</option><option value="Ms">Ms</option><option value="Dr">Dr</option><option value="Prof">Prof</option><option value="Sir">Sir</option></select></div><div class="form_grey_item"><input type="text" onclick="selfocus(this);" id="first_name" name="first_name" maxlength="150" style="width: 165px;" class="validate[required] text-input" value="Kabelo" /></div><div class="form_grey_item form_grey_item_no_margin_right"><input type="text" onclick="selfocus(this);" id="last_name" name="last_name" maxlength="150" class="validate[required] text-input" value="Moloi" /></div><div class="form_grey_item form_grey_item_no_margin_bottom"><input onclick="selfocus(this);" class="text-input validate[required]" name="email" id="email" value="kabelo_moloi@yahoo.com" maxlength="64" type="text"></div><div class="form_grey_item form_grey_item_no_margin_bottom"><input type="text" id="00N900000015Fkf" onclick="selfocus(this);" style="width: 130px;" name="00N900000015Fkf" maxlength="15" class="validate[required] text-input" value="0113679000" /></div><div class="form_grey_item form_grey_item_no_margin_right form_grey_item_no_margin_bottom"><input type="text" onclick="selfocus(this);" id="nationality" name="nationality" maxlength="150" class="validate[required] text-input" value="South African" /></div><div style="clear:both"></div></div>

STEP 4

<form class="formular roi_form" id="individualForm" method="post" action="#"><input id="00N90000002JIvi" type="hidden" value="MT4" title="Platform" name="00N90000002JIvi"><input type="hidden" value="3" name="00N90000001sJbd"><input id="00N90000002gWIe" type="hidden" value="ETFX65792" size="20" name="00N90000002gWIe" maxlength="20"><input id="lead_source" type="hidden" value="VFX Ac2" name="lead_source"><input id="00N90000002oqaA" type="hidden" value="41.135.64.38" name="00N90000002oqaA"><input type="hidden" value="00Dd0000000eDrk" name="oid"><input type="hidden" value="http://www.vantagefx.com/get-trading/choose-region/australian-or-international/international-application/thank-you" name="retURL"><input type="hidden" id="ga-page" name="ga-page" value="/declaration" /><input value="end" id="nextstep" name="nextstep" type="hidden" /><input type="hidden" name="eaf5234d9fb03b9c897da0c29c49974d" value="1" /><input type="hidden" name="1cf1" value="c8b641db5c041d8d5df714bb67af2734" /><div class="form_progress_bar_step_4"></div><input type="hidden" name="final_submit" value="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" /><fieldset>

<div class="form_submit_block"><input value="Finish" style="float:right;" class="button form_button_next form_button_complete" name="button_76" type="submit">


  • March 27, 2012
  • Like
  • 0

Hi All, I have a class and trigger that assign numbers to Opportunities depending on the business unit (Custom Field).  On a mass update (Dataloadre) I get duplicate values for this number, meaning two records will receive one number.  Below is my Trigger, thereafter my class.

 

Thanks in Advance.

 

trigger UpdateAutoNumber on Opportunity (before insert, before update) {
   
List <Opportunity> updates = new List <Opportunity>();   
if(Trigger.isInsert){
    Opportunity [] oppr =Trigger.new;
        AutoNumberHolder.display(oppr);
    }
   
   
   
if(Trigger.isUpdate){
    if (AutoNumberHolder.firstRun == true) {
     for (Opportunity oppr: Trigger.new){
        
          
                if(oppr.business_unit__c != Trigger.oldMap.get(oppr.Id).business_unit__c||
                   oppr.Product_Type__c != Trigger.oldMap.get(oppr.Id).Product_Type__c ){
                     updates.add(oppr);
                      
       
               }

         }
   

    }
    AutoNumberHolder.display(updates);
    AutoNumberHolder.firstRun = false;
  }
}

 

Class

 

public with sharing class AutoNumberHolder {
public static boolean firstRun = true;

public static void display(Opportunity [] oppr){

      integer ssaCounter = 0;
      integer ausCounter = 0;
      integer cisCounter = 0;
      integer indCounter = 0;
      integer bgtCounter = 0;
      integer betCounter = 0;
      integer delCounter = 0;
      integer bbaCounter = 0;
      integer baaCounter = 0;
      integer balCounter = 0;

for( Opportunity o: oppr){
          if(o.Business_Unit__c=='Bateman Engineering (SSA)')
                  ssaCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Engineering (AUS)')
                  ausCounter += 1;
                 
         else if(o.Business_Unit__c=='Bateman Engineering (CIS)')
                  cisCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Engineering (IND)')
                  indCounter += 1;
                 
         else if(o.Business_Unit__c=='Bateman Global Technology (BGT)')
                  bgtCounter += 1;

  
      
       else  if (o.Business_Unit__c=='Bateman Engineered Technologies (BET)')
                 betCounter = betCounter + 1;
                
         else if(o.Business_Unit__c=='Delkor Global (DEL)')
                  delCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Beijing Axis (BBA)')
                  bbaCounter += 1;
                 
         else if(o.Business_Unit__c=='Bateman Africa (BAA)')
                  baaCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Litwin (BAL)')
                  balCounter += 1;
 }

AutoNumberHolder__c autoNum =[select id, Num1__c, Num2__c, Num3__c, Num4__c, Num5__c, Num6__c, Num7__c, Num8__c, Num9__c, Num10__c
                               from AutoNumberHolder__c LIMIT 1];

//assuming its an integer field - we are reserving numbers from the counter
//for the opportunities we have to number

integer ssaCtrStarts = autoNum.Num1__c.intValue() + 1;
integer ausCtrStarts = autoNum.Num2__c.intValue() + 1;
integer cisCtrStarts = autoNum.Num3__c.intValue() + 1;
integer indCtrStarts = autoNum.Num4__c.intValue()  + 1;
integer bgtCtrStarts = autoNum.Num5__c.intValue() + 1 ;

integer betCtrStarts = autoNum.Num6__c.intValue()  + 1;
integer delCtrStarts = autoNum.Num7__c.intValue() + 1;
integer bbaCtrStarts = autoNum.Num8__c.intValue()  + 1;
integer baaCtrStarts = autoNum.Num9__c.intValue()  + 1;
integer balCtrStarts = autoNum.Num10__c.intValue() + 1;

autoNum.Num1__c  +=  ssaCounter;
autoNum.Num2__c  += ausCounter;
autoNum.Num3__c  +=  cisCounter;
autoNum.Num4__c  += indCounter;
autoNum.Num5__c  +=  bgtCounter;

autoNum.Num6__c  += betCounter;
autoNum.Num7__c  +=  delCounter;
autoNum.Num8__c  += bbaCounter;
autoNum.Num9__c  += baaCounter;
autoNum.Num10__c  += balCounter;


update autoNum;

for( Opportunity o: oppr){
          if(o.Business_Unit__c=='Bateman Engineering (SSA)') {

               o.Enquiry_Number2__c = ssaCtrStarts.format();
               ssaCtrStarts +=1;
 }
         else if(o.Business_Unit__c=='Bateman Engineering (AUS)'){
                o.Enquiry_Number2__c = ausCtrStarts.format(); 
                ausCtrStarts += 1;
  }
         else  if(o.Business_Unit__c=='Bateman Engineering (CIS)'){
                o.Enquiry_Number2__c = cisCtrStarts.format(); 
                cisCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Engineering (IND)'){
                o.Enquiry_Number2__c = indCtrStarts.format(); 
                indCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Global Technology (BGT)'){

                o.Enquiry_Number2__c = bgtCtrStarts.format(); 
                bgtCtrStarts += 1;
 }
        
       
else  if(o.Business_Unit__c=='Bateman Engineered Technologies (BET)'){

                o.Enquiry_Number2__c = betCtrStarts.format(); 
                betCtrStarts += 1;
                system.debug('bmc Controller '+ betCtrStarts);
                system.debug('Enquiry Number '+ o.Enquiry_Number2__c);
 }
 

         else  if(o.Business_Unit__c=='Delkor Global (DEL)'){
                o.Enquiry_Number2__c = delCtrStarts.format(); 
                delCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Beijing Axis (BBA)'){
                o.Enquiry_Number2__c = bbaCtrStarts.format(); 
                bbaCtrStarts += 1;
  }
         else  if(o.Business_Unit__c=='Bateman Africa (BAA)'){
                o.Enquiry_Number2__c = bbaCtrStarts.format(); 
                baaCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Litwin (BAL)'){
                o.Enquiry_Number2__c = delCtrStarts.format(); 
                balCtrStarts += 1;
  }
 
}
 }
}

  • September 12, 2011
  • Like
  • 0

Hi All,

 

i am trying to crate a formula based on the below criteria (user selection), but I am hiiting the limit of 5000 characters (size) limit.

  1. I have a 2 picklist fields, with one dependant. Business Unit, Product Type (dependant)
  2. If a user Selects Business unit (BET) and a Product Type with an acronym (e.g BGC), an enquiry number is generated based on the Product Type with a 5 character long number appended at the end (e.g BGC-00001).
  3. If no Product Type is selected for Business Unit BET, then the Enquirt Number Should be BET-00001
  4. Should the Business Unit NOT be BET, the Enqury Number is the business unit appended with a 4 character long number (e.g AUS-0001

I currently have the following code, but hit the limit when saving.  Please assist (reluctant on going to code for this):

 

IF (
AND(
ISPICKVAL(Business_Unit__c,"Bateman Engineered Technologies (BET)"),
OR(
ISPICKVAL(Product_Type__c,"Air Environmental (BPC)"),
ISPICKVAL(Product_Type__c,"Cement (BLC)"),
ISPICKVAL(Product_Type__c,"Comminution (BUC)"),
ISPICKVAL(Product_Type__c,"Conveyors (BCC)"),
ISPICKVAL(Product_Type__c,"Distribution (BGC)"),
ISPICKVAL(Product_Type__c,"Jetfloat (BQC)"),
ISPICKVAL(Product_Type__c,"Load Out Stations (BEC)"),
ISPICKVAL(Product_Type__c,"Pneumatics (BLC)"),
ISPICKVAL(Product_Type__c,"Process Equipment (BOC)"),
ISPICKVAL(Product_Type__c,"Specialised Handling (BAC)"),
ISPICKVAL(Product_Type__c,"Stackers & Reclaimers (BBC)"),
ISPICKVAL(Product_Type__c,"Water (BMC)")
)),
LEFT(SUBSTITUTE(TEXT(Product_Type__c ),LEFT(TEXT(Product_Type__c),FIND("(",TEXT(Product_Type__c))), ""),3)&"-"&
LPAD(Enquiry_Number2__c,5,'0'),



IF(

ISPICKVAL(Business_Unit__c,"Bateman Engineered Technologies (BET)"),

LEFT(SUBSTITUTE(TEXT(Business_Unit__c),LEFT(TEXT(Business_Unit__c),FIND("(",TEXT(Business_Unit__c))),""),3)&"-"&
LPAD(Enquiry_Number2__c,5,'0'),

LEFT(SUBSTITUTE(TEXT(Business_Unit__c),LEFT(TEXT(Business_Unit__c),FIND("(",TEXT(Business_Unit__c))),""),3)&"-"&
LPAD(Enquiry_Number2__c,4,'0')
))

 

Thanks in advance

 

  • July 29, 2011
  • Like
  • 0

Hi All,

 

I have a request to auto-number opportunities based on a custom field, business unit. Eg.:

SSA-001

BTE-001

SSA-002

NTE-001

SSA-003 etc

 

I have a cutom object that will hold these numbers and increment based on the business unit in the Opportunity.  This object has no relation (link) to the Opportunity object.  I am currently updating a field on the Opportunity, based on the business unit.  I am currently hitting governor limits when I mass import opportunities.  Please assis urgently.  Herewith my code below:

 

public with sharing class AutoNumberHolder {

public static void display(Opportunity [] oppr){

      Integer m;

 

//List<Opportunity> oppList = new List<Opportunity>();

for( Opportunity o: oppr){

          if(o.Business_Unit__c=='Bateman Engineering (SSA)'){

              AutoNumberHolder__c n =[select id, opportunity__c, Num1__c, num2__c from AutoNumberHolder__c ];

              m=n.Num1__c.intValue();

              m=m+1;

              o.Test_Num__c=m;

              n.Num1__c=m;

 

                  update n;

        }

 

      if(o.Business_Unit__c=='Bateman Engineering (AUS)'){

                  AutoNumberHolder__c n =[select id, opportunity__c, Num1__c, num2__c from AutoNumberHolder__c ];

                  m=n.Num2__c.intValue();

                  m=m+1;

                 o.Test_Num__c=m;

                 n.Num2__c=m;

 

                  update n;

        }

 

 

     }

   }

}

 

Here’s the Trigger:

 

trigger UpdateAutoNumber on Opportunity (before insert,

before update) {

      if(Trigger.isInsert){

 

Opportunity [] oppr =Trigger.new;

                  AutoNumberHolder.display(oppr);

 

}

if(Trigger.isUpdate){  

 

for (Integer i = 0; i < Trigger.new.size(); i++)    {

 

if (Trigger.new[i].business_unit__c != Trigger.old[i].Business_Unit__c){

      Opportunity [] oppr = Trigger.new;

   AutoNumberHolder.display(oppr); 

   }

 

 } 

 

Much appreciated.

  • March 25, 2011
  • Like
  • 0

Hi All,

 

I'd like to create a report that will give me a Product's Actual Sales (open and closed won) per user.  Each user has their own product targets and it will be a static value.

 

Thanks

  • August 30, 2010
  • Like
  • 0

Hi All,

 

I am struggling with my web-to-lead form, it is not populating the vaules prodived in the form, in Salesforce.  My site has four steps a user must go through, Step 1 takes the Contact Details, and the last step does the submission:

 

Any help is much appreciated, thank you, site is http://dev2.roimedia.co.za/vantagefx-com/testform

 

STEP1:

<form class="formular roi_form" id="individualForm" method="post" action="#"><input id="00N90000002JIvi" type="hidden" value="MT4" title="Platform" name="00N90000002JIvi"><input type="hidden" value="3" name="00N90000001sJbd"><input id="00N90000002gWIe" type="hidden" value="ETFX65792" size="20" name="00N90000002gWIe" maxlength="20"><input id="lead_source" type="hidden" value="VFX Ac2" name="lead_source"><input id="00N90000002oqaA" type="hidden" value="41.135.64.38" name="00N90000002oqaA"><input type="hidden" value="00Dd0000000eDrk" name="oid"><input type="hidden" value="http://www.vantagefx.com/get-trading/choose-region/australian-or-international/international-application/thank-you" name="retURL"><input type="hidden" id="ga-page" name="ga-page" value="/personal-details" /><div class="form_progress_bar_step_1"></div><fieldset><input type="hidden" value="2" name="nextstep" id="nextstep" /><input type="hidden" name="eaf5234d9fb03b9c897da0c29c49974d" value="1" /><input type="hidden" name="1cf1" value="c8b641db5c041d8d5df714bb67af2734" /><div class="form_top"><h3>Personal Details</h3><div class="required"><span>*</span> Required</div></div><div class="form_grey_back"><div class="form_grey_item"><select id="title" size="1" name="title" class="validate[required] text-input chosen_title" style="width: 155px; top: 2px;"><option value="">*Title</option><option value="Mr" selected="selected">Mr</option><option value="Mrs">Mrs</option><option value="Miss">Miss</option><option value="Ms">Ms</option><option value="Dr">Dr</option><option value="Prof">Prof</option><option value="Sir">Sir</option></select></div><div class="form_grey_item"><input type="text" onclick="selfocus(this);" id="first_name" name="first_name" maxlength="150" style="width: 165px;" class="validate[required] text-input" value="Kabelo" /></div><div class="form_grey_item form_grey_item_no_margin_right"><input type="text" onclick="selfocus(this);" id="last_name" name="last_name" maxlength="150" class="validate[required] text-input" value="Moloi" /></div><div class="form_grey_item form_grey_item_no_margin_bottom"><input onclick="selfocus(this);" class="text-input validate[required]" name="email" id="email" value="kabelo_moloi@yahoo.com" maxlength="64" type="text"></div><div class="form_grey_item form_grey_item_no_margin_bottom"><input type="text" id="00N900000015Fkf" onclick="selfocus(this);" style="width: 130px;" name="00N900000015Fkf" maxlength="15" class="validate[required] text-input" value="0113679000" /></div><div class="form_grey_item form_grey_item_no_margin_right form_grey_item_no_margin_bottom"><input type="text" onclick="selfocus(this);" id="nationality" name="nationality" maxlength="150" class="validate[required] text-input" value="South African" /></div><div style="clear:both"></div></div>

STEP 4

<form class="formular roi_form" id="individualForm" method="post" action="#"><input id="00N90000002JIvi" type="hidden" value="MT4" title="Platform" name="00N90000002JIvi"><input type="hidden" value="3" name="00N90000001sJbd"><input id="00N90000002gWIe" type="hidden" value="ETFX65792" size="20" name="00N90000002gWIe" maxlength="20"><input id="lead_source" type="hidden" value="VFX Ac2" name="lead_source"><input id="00N90000002oqaA" type="hidden" value="41.135.64.38" name="00N90000002oqaA"><input type="hidden" value="00Dd0000000eDrk" name="oid"><input type="hidden" value="http://www.vantagefx.com/get-trading/choose-region/australian-or-international/international-application/thank-you" name="retURL"><input type="hidden" id="ga-page" name="ga-page" value="/declaration" /><input value="end" id="nextstep" name="nextstep" type="hidden" /><input type="hidden" name="eaf5234d9fb03b9c897da0c29c49974d" value="1" /><input type="hidden" name="1cf1" value="c8b641db5c041d8d5df714bb67af2734" /><div class="form_progress_bar_step_4"></div><input type="hidden" name="final_submit" value="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" /><fieldset>

<div class="form_submit_block"><input value="Finish" style="float:right;" class="button form_button_next form_button_complete" name="button_76" type="submit">


  • March 27, 2012
  • Like
  • 0

Hi All, I have a class and trigger that assign numbers to Opportunities depending on the business unit (Custom Field).  On a mass update (Dataloadre) I get duplicate values for this number, meaning two records will receive one number.  Below is my Trigger, thereafter my class.

 

Thanks in Advance.

 

trigger UpdateAutoNumber on Opportunity (before insert, before update) {
   
List <Opportunity> updates = new List <Opportunity>();   
if(Trigger.isInsert){
    Opportunity [] oppr =Trigger.new;
        AutoNumberHolder.display(oppr);
    }
   
   
   
if(Trigger.isUpdate){
    if (AutoNumberHolder.firstRun == true) {
     for (Opportunity oppr: Trigger.new){
        
          
                if(oppr.business_unit__c != Trigger.oldMap.get(oppr.Id).business_unit__c||
                   oppr.Product_Type__c != Trigger.oldMap.get(oppr.Id).Product_Type__c ){
                     updates.add(oppr);
                      
       
               }

         }
   

    }
    AutoNumberHolder.display(updates);
    AutoNumberHolder.firstRun = false;
  }
}

 

Class

 

public with sharing class AutoNumberHolder {
public static boolean firstRun = true;

public static void display(Opportunity [] oppr){

      integer ssaCounter = 0;
      integer ausCounter = 0;
      integer cisCounter = 0;
      integer indCounter = 0;
      integer bgtCounter = 0;
      integer betCounter = 0;
      integer delCounter = 0;
      integer bbaCounter = 0;
      integer baaCounter = 0;
      integer balCounter = 0;

for( Opportunity o: oppr){
          if(o.Business_Unit__c=='Bateman Engineering (SSA)')
                  ssaCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Engineering (AUS)')
                  ausCounter += 1;
                 
         else if(o.Business_Unit__c=='Bateman Engineering (CIS)')
                  cisCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Engineering (IND)')
                  indCounter += 1;
                 
         else if(o.Business_Unit__c=='Bateman Global Technology (BGT)')
                  bgtCounter += 1;

  
      
       else  if (o.Business_Unit__c=='Bateman Engineered Technologies (BET)')
                 betCounter = betCounter + 1;
                
         else if(o.Business_Unit__c=='Delkor Global (DEL)')
                  delCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Beijing Axis (BBA)')
                  bbaCounter += 1;
                 
         else if(o.Business_Unit__c=='Bateman Africa (BAA)')
                  baaCounter += 1;

         else  if(o.Business_Unit__c=='Bateman Litwin (BAL)')
                  balCounter += 1;
 }

AutoNumberHolder__c autoNum =[select id, Num1__c, Num2__c, Num3__c, Num4__c, Num5__c, Num6__c, Num7__c, Num8__c, Num9__c, Num10__c
                               from AutoNumberHolder__c LIMIT 1];

//assuming its an integer field - we are reserving numbers from the counter
//for the opportunities we have to number

integer ssaCtrStarts = autoNum.Num1__c.intValue() + 1;
integer ausCtrStarts = autoNum.Num2__c.intValue() + 1;
integer cisCtrStarts = autoNum.Num3__c.intValue() + 1;
integer indCtrStarts = autoNum.Num4__c.intValue()  + 1;
integer bgtCtrStarts = autoNum.Num5__c.intValue() + 1 ;

integer betCtrStarts = autoNum.Num6__c.intValue()  + 1;
integer delCtrStarts = autoNum.Num7__c.intValue() + 1;
integer bbaCtrStarts = autoNum.Num8__c.intValue()  + 1;
integer baaCtrStarts = autoNum.Num9__c.intValue()  + 1;
integer balCtrStarts = autoNum.Num10__c.intValue() + 1;

autoNum.Num1__c  +=  ssaCounter;
autoNum.Num2__c  += ausCounter;
autoNum.Num3__c  +=  cisCounter;
autoNum.Num4__c  += indCounter;
autoNum.Num5__c  +=  bgtCounter;

autoNum.Num6__c  += betCounter;
autoNum.Num7__c  +=  delCounter;
autoNum.Num8__c  += bbaCounter;
autoNum.Num9__c  += baaCounter;
autoNum.Num10__c  += balCounter;


update autoNum;

for( Opportunity o: oppr){
          if(o.Business_Unit__c=='Bateman Engineering (SSA)') {

               o.Enquiry_Number2__c = ssaCtrStarts.format();
               ssaCtrStarts +=1;
 }
         else if(o.Business_Unit__c=='Bateman Engineering (AUS)'){
                o.Enquiry_Number2__c = ausCtrStarts.format(); 
                ausCtrStarts += 1;
  }
         else  if(o.Business_Unit__c=='Bateman Engineering (CIS)'){
                o.Enquiry_Number2__c = cisCtrStarts.format(); 
                cisCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Engineering (IND)'){
                o.Enquiry_Number2__c = indCtrStarts.format(); 
                indCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Global Technology (BGT)'){

                o.Enquiry_Number2__c = bgtCtrStarts.format(); 
                bgtCtrStarts += 1;
 }
        
       
else  if(o.Business_Unit__c=='Bateman Engineered Technologies (BET)'){

                o.Enquiry_Number2__c = betCtrStarts.format(); 
                betCtrStarts += 1;
                system.debug('bmc Controller '+ betCtrStarts);
                system.debug('Enquiry Number '+ o.Enquiry_Number2__c);
 }
 

         else  if(o.Business_Unit__c=='Delkor Global (DEL)'){
                o.Enquiry_Number2__c = delCtrStarts.format(); 
                delCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Beijing Axis (BBA)'){
                o.Enquiry_Number2__c = bbaCtrStarts.format(); 
                bbaCtrStarts += 1;
  }
         else  if(o.Business_Unit__c=='Bateman Africa (BAA)'){
                o.Enquiry_Number2__c = bbaCtrStarts.format(); 
                baaCtrStarts += 1;
 }
         else  if(o.Business_Unit__c=='Bateman Litwin (BAL)'){
                o.Enquiry_Number2__c = delCtrStarts.format(); 
                balCtrStarts += 1;
  }
 
}
 }
}

  • September 12, 2011
  • Like
  • 0

Hi All,

 

I have a request to auto-number opportunities based on a custom field, business unit. Eg.:

SSA-001

BTE-001

SSA-002

NTE-001

SSA-003 etc

 

I have a cutom object that will hold these numbers and increment based on the business unit in the Opportunity.  This object has no relation (link) to the Opportunity object.  I am currently updating a field on the Opportunity, based on the business unit.  I am currently hitting governor limits when I mass import opportunities.  Please assis urgently.  Herewith my code below:

 

public with sharing class AutoNumberHolder {

public static void display(Opportunity [] oppr){

      Integer m;

 

//List<Opportunity> oppList = new List<Opportunity>();

for( Opportunity o: oppr){

          if(o.Business_Unit__c=='Bateman Engineering (SSA)'){

              AutoNumberHolder__c n =[select id, opportunity__c, Num1__c, num2__c from AutoNumberHolder__c ];

              m=n.Num1__c.intValue();

              m=m+1;

              o.Test_Num__c=m;

              n.Num1__c=m;

 

                  update n;

        }

 

      if(o.Business_Unit__c=='Bateman Engineering (AUS)'){

                  AutoNumberHolder__c n =[select id, opportunity__c, Num1__c, num2__c from AutoNumberHolder__c ];

                  m=n.Num2__c.intValue();

                  m=m+1;

                 o.Test_Num__c=m;

                 n.Num2__c=m;

 

                  update n;

        }

 

 

     }

   }

}

 

Here’s the Trigger:

 

trigger UpdateAutoNumber on Opportunity (before insert,

before update) {

      if(Trigger.isInsert){

 

Opportunity [] oppr =Trigger.new;

                  AutoNumberHolder.display(oppr);

 

}

if(Trigger.isUpdate){  

 

for (Integer i = 0; i < Trigger.new.size(); i++)    {

 

if (Trigger.new[i].business_unit__c != Trigger.old[i].Business_Unit__c){

      Opportunity [] oppr = Trigger.new;

   AutoNumberHolder.display(oppr); 

   }

 

 } 

 

Much appreciated.

  • March 25, 2011
  • Like
  • 0