• Visionary
  • NEWBIE
  • 10 Points
  • Member since 2013

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

I have a task to assign a lead to a specific user depending on 2 factors (Zip Code, and Product Family)
Some leads will have Product Family and Zip filled out - we only need to look at ones that have both filled in.

Each Zip Code can be owned by multiple individuals but that is segregated by Division
Custom Object: Zip_Code__c example
OwnerID                    ZipCode    Division__c
00511000000AAaa    50000       1
00511000000AAab    50000       2
00511000000AAac    50000       3
00511000000AAad    50000       4

Division is based on Product Family in Product2 Object
Name                       Family                Division__c
iPad Air                    Tablet                 1
iPad mini                  Tablet                 1
iPhone 7                   Phone                2
Samsung S7             Phone                3

So what i have to do is this
Get Lead.ProductFamily, and Lead.PostalCode
and figure out how to get Zip_Code__c.OwnerID for each Lead
 

This is my current code, but it seems to sometimes not work (no errors) just not pulling as expected.. I REALLY need someone's help.

 

trigger LeadTrigger on Lead (before insert) {

List<Lead> leadsToUpdate = new List<Lead>();
                  
                    
    for (Lead lead : Trigger.new)
    {     
      if (lead.ProductFamily__c == null || lead.ProductFamily__c == '' || lead.PostalCode.length() < 5)
      {
          // do nothing
      }
      else
      {
         
              List<Product2> prodList = [SELECT id,Division__c FROM Product2 WHERE Family = :lead.ProductFamily__c limit 1];
              if (prodList.size()<1)
              {
                  break;
              }
              List<Zip_Code__c> zipList = [SELECT OwnerId, Division__c, Zip_Code__c FROM Zip_Code__c WHERE Zip_Code__c = :lead.PostalCode.subString(0,5) and Division__c INCLUDES(:prodList[0].Division__c) ];
              if (zipList.size()<1){
                 break;
              }
              
              String[] divisions = zipList.size() > 0 ? zipList[0].Division__c.split(';') : null;
              if(divisions != null && prodList.size() > 0) {
                for(String div : divisions) {
                    if(prodList[0].Division__c == div) {
                        lead.OwnerId = zipList[0].OwnerId;
                        
                        leadsToUpdate.add(lead);
                    }
                }
             }
      } 
    }
}

i have a pricebook setup where price book has a multiselect picklist called Customer_Grouping_Codes

example:
Pricebook1 has Customer_Grouping_Codes: a1,a2,a3,a5,a9,a10
Pricebook2 has Customer_Grouping_Codes: a4,a6,a7,b1,b2
etc....

- on my account object i have a field called Customer_Group_1_Code__c(this is uploaded from source data warehouse)
- account: abc has Customer_Group_1_Code__c = a3
- I now have a field called Default_Price_Book__c on Account that is Lookup(Price Book)
- what i need to do is set this Account.Default_Price_Book__c on before insert, before update to the Pricebook2.id corresponding to Account.Customer_Group_1_Code__c 




here is what i have so far: 

trigger AccountPriceBookSelector on Account (before insert, before update) {
	
    for(Account acc : Trigger.new)
    {
        if(acc.Customer_Group_1_Code__c!=null)
        {
            
            List<Pricebook2> pb = [select id, name from PriceBook2 where Customer_Grouping_Codes__c includes (:acc.Customer_Group_1_Code__c) ];
             if(!pb.isEmpty())
             {
            	acc.Default_Price_Book__c=pb[0].id;
             }
        
        }
        else
        {
            List<Pricebook2> stdPBL =  [select id from Pricebook2 where IsStandard = TRUE];
            acc.Default_Price_Book__c = stdPBL[0].id;
        }
    }
}
 

I'm just not sure where to start with this - it looks so easy (pseudo code) but i'm having trouble

Got a trigger that should update number of cases for a set of accounts.
 
trigger CaseTrigger on Case (after insert, after update) 
{ 
Set<Account> accTemp=new Set<Account>(); 
List<Account> accTemp2 = new List<Account>(); 

// code to populate accTemp set with Accounts........ 
for(Account a : accTemp)
{ 
cases = [select id, accountid from Case WHERE accountid=:a.id AND isclosed!=true and createdDate >: System.Today()-365 LIMIT 90]; 
a.Nuber_Of_Open_Cases__c = cases.size(); 
accTemp2.add(a); 

} 
update(accTemp2); 

}


please help as i'm getting too many SOQL queries error when i do bulk upload.
i populate accTemp which is a Set<Account> with accounts that meet a certain criteria

then....
 
trigger CaseTrigger on Case (after insert, after update)
{
Set<Account> accTemp=new Set<Account>();
List<Account> accTemp2 = new List<Account>();
// code to populate accTemp set with Accounts........


 for(Account a : accTemp){
            cases = [select id, accountid from Case WHERE accountid=:a.id AND isclosed!=true and createdDate >: System.Today()-365 LIMIT 90];
            a.Nuber_Of_Open_Cases__c = cases.size();
            accTemp2.add(a);
        }
        update(accTemp2);

}

please help as i'm getting too many SOQL queries error when i do bulk upload.

Ok so we are working on a SF1 google maps app for our Sales Team.

We have an issue with being able to access some of the Actions from the action bar .... well since the action bar doesn't appear on our custom maps inteface.

What we want to do is port some of the actions to the info window

here is what we have (noticed the circled "New Visit" ) 

User-added image

how can i make that link go out to an action i created?

User-added image

What i ultimately want is ( i realize i might not be able to make the icon appear there exactly like on the action bar)

User-added image

How can this be done?

Hi all,

 

This is driving me nuts, i believe what i need is a very simple VF page but can't seem to get anywhere

 

i need to create a custom edit button that would point to a VF page.

This VF page would then redirect back to the standard page but would append an extra value to the URL

 

 .....salesforce.com/a0wW0000000Dzl5/e?retURL=%2Fa0wW0000000Dzl5&x=somevalue

 

anyone seen/done something like this? I would really appreciate if you could post some code i could start with..

 

 

 

 

I'm new to VF so please be gentle - here is the scenario:

 

we have a custom object, the fields in this object will change (rather new ones will be added often) as new categories emerge...

 

So i need a way to create the VF page where i don't have to code every single field every time there is a new field created, but i need to be able to handle the Save function, perhaps the Save&New etc.. in a special way.

 

How can i create this? oh and the page should open in EDIT mode.

 

please help or let me know if this is even possible? 

 

<apex:page standardController="My_Feedback__c">
     <apex:form >
           <apex:detail />
     </apex:form>
</apex:page>

 

clicking "edit" or "delete" or "clone" standard buttons on the page that renders doesn't do anything...

I have a task to assign a lead to a specific user depending on 2 factors (Zip Code, and Product Family)
Some leads will have Product Family and Zip filled out - we only need to look at ones that have both filled in.

Each Zip Code can be owned by multiple individuals but that is segregated by Division
Custom Object: Zip_Code__c example
OwnerID                    ZipCode    Division__c
00511000000AAaa    50000       1
00511000000AAab    50000       2
00511000000AAac    50000       3
00511000000AAad    50000       4

Division is based on Product Family in Product2 Object
Name                       Family                Division__c
iPad Air                    Tablet                 1
iPad mini                  Tablet                 1
iPhone 7                   Phone                2
Samsung S7             Phone                3

So what i have to do is this
Get Lead.ProductFamily, and Lead.PostalCode
and figure out how to get Zip_Code__c.OwnerID for each Lead
 

This is my current code, but it seems to sometimes not work (no errors) just not pulling as expected.. I REALLY need someone's help.

 

trigger LeadTrigger on Lead (before insert) {

List<Lead> leadsToUpdate = new List<Lead>();
                  
                    
    for (Lead lead : Trigger.new)
    {     
      if (lead.ProductFamily__c == null || lead.ProductFamily__c == '' || lead.PostalCode.length() < 5)
      {
          // do nothing
      }
      else
      {
         
              List<Product2> prodList = [SELECT id,Division__c FROM Product2 WHERE Family = :lead.ProductFamily__c limit 1];
              if (prodList.size()<1)
              {
                  break;
              }
              List<Zip_Code__c> zipList = [SELECT OwnerId, Division__c, Zip_Code__c FROM Zip_Code__c WHERE Zip_Code__c = :lead.PostalCode.subString(0,5) and Division__c INCLUDES(:prodList[0].Division__c) ];
              if (zipList.size()<1){
                 break;
              }
              
              String[] divisions = zipList.size() > 0 ? zipList[0].Division__c.split(';') : null;
              if(divisions != null && prodList.size() > 0) {
                for(String div : divisions) {
                    if(prodList[0].Division__c == div) {
                        lead.OwnerId = zipList[0].OwnerId;
                        
                        leadsToUpdate.add(lead);
                    }
                }
             }
      } 
    }
}

i have a pricebook setup where price book has a multiselect picklist called Customer_Grouping_Codes

example:
Pricebook1 has Customer_Grouping_Codes: a1,a2,a3,a5,a9,a10
Pricebook2 has Customer_Grouping_Codes: a4,a6,a7,b1,b2
etc....

- on my account object i have a field called Customer_Group_1_Code__c(this is uploaded from source data warehouse)
- account: abc has Customer_Group_1_Code__c = a3
- I now have a field called Default_Price_Book__c on Account that is Lookup(Price Book)
- what i need to do is set this Account.Default_Price_Book__c on before insert, before update to the Pricebook2.id corresponding to Account.Customer_Group_1_Code__c 




here is what i have so far: 

trigger AccountPriceBookSelector on Account (before insert, before update) {
	
    for(Account acc : Trigger.new)
    {
        if(acc.Customer_Group_1_Code__c!=null)
        {
            
            List<Pricebook2> pb = [select id, name from PriceBook2 where Customer_Grouping_Codes__c includes (:acc.Customer_Group_1_Code__c) ];
             if(!pb.isEmpty())
             {
            	acc.Default_Price_Book__c=pb[0].id;
             }
        
        }
        else
        {
            List<Pricebook2> stdPBL =  [select id from Pricebook2 where IsStandard = TRUE];
            acc.Default_Price_Book__c = stdPBL[0].id;
        }
    }
}
 

I'm just not sure where to start with this - it looks so easy (pseudo code) but i'm having trouble

Got a trigger that should update number of cases for a set of accounts.
 
trigger CaseTrigger on Case (after insert, after update) 
{ 
Set<Account> accTemp=new Set<Account>(); 
List<Account> accTemp2 = new List<Account>(); 

// code to populate accTemp set with Accounts........ 
for(Account a : accTemp)
{ 
cases = [select id, accountid from Case WHERE accountid=:a.id AND isclosed!=true and createdDate >: System.Today()-365 LIMIT 90]; 
a.Nuber_Of_Open_Cases__c = cases.size(); 
accTemp2.add(a); 

} 
update(accTemp2); 

}


please help as i'm getting too many SOQL queries error when i do bulk upload.
We have an existing Visualforce page that is the home screen for Salesforce1 users.

When I log in this morning on my iPad 2, whenever the app loads, I get booted to Safari ("Introducing Salesforce1" knowledge base article). Anytime I try to reload Salesforce1, it keeps happening, so I can't even switch orgs now in the Salesforce1 app.

Help?

I'm new to VF so please be gentle - here is the scenario:

 

we have a custom object, the fields in this object will change (rather new ones will be added often) as new categories emerge...

 

So i need a way to create the VF page where i don't have to code every single field every time there is a new field created, but i need to be able to handle the Save function, perhaps the Save&New etc.. in a special way.

 

How can i create this? oh and the page should open in EDIT mode.

 

please help or let me know if this is even possible? 

 

<apex:page standardController="My_Feedback__c">
     <apex:form >
           <apex:detail />
     </apex:form>
</apex:page>

 

clicking "edit" or "delete" or "clone" standard buttons on the page that renders doesn't do anything...