• learnSF
  • NEWBIE
  • 75 Points
  • Member since 2008

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 98
    Questions
  • 160
    Replies

Where can I find code to create a custom link on the opportunity to pull up a map of the address?

 

I was hoping to find code somewhere then figure out how to add my fields to the address fields in Google.

 

Is it harder than I am making it sound? I have no coding experience other than some apex coding testing. Any suggestions?

  • December 08, 2009
  • Like
  • 0

Hi,

 

I have pdf attchment with 6 pages.

 

I need to write code in apex which only last 4 pages from pdf and sent email with that new attachment and remove first two pages.

 

Can someone tell me how we can split pdf pages from attachment and create new attachment?

 

Thanks

***JR. DEVELOPER, SALESFORCE.COM***

 

Rewards Network has an exciting opportunity for a Jr. Developer, Salesforce.com to join our growing team of IT professionals!  Rewards Network (NASDAQ: DINE), headquartered in Chicago, IL, operates the leading dining rewards programs in North America by marketing participating restaurants to members of these programs and by providing incentives to members to dine at these restaurants. In addition to operating the dining rewards program of leading airline frequent flyer programs, hotel frequent-stay programs, retailer shopping programs, college savings programs, and other affinity organizations, the Company offers its own dining rewards program, iDine® at www.idine.com.

 

Summary  

The Junior Developer’s role is to work with business partners to realize the full capability of Salesforce.com CRM.  They will contribute to all technical aspects of projects developed and perform detailed analysis of business and technical requirements.

 

Essential Duties and Responsibilities

  • Work with business partners to realize the full capabilities of Salesforce.com CRM
  • Provide operational support to the Salesforce.com system
  • Contribute to all technical aspects of projects developed
  • Perform detailed analysis of business and technical requirements
  • Write supporting documentation supporting business needs
  • Create development and integration plans

 

Position Requirements

Formal Education & Certification:

  • Bachelor degree in the field of computer science, information technology, or business administration strongly preferred

Knowledge & Experience:

  • Must have minimum 4+ years of total IT experience including 2+ years of SFDC
  • Experience with Salesforce.com Administration (User, Roles, Profile, Workflows, Approval Process, Relationship Object, Page Layout, Validation rules, Field sharing and Security, Company profile, Email2Case, MassEmail)
  • Prior experience with Force.com developer toolkit - Apex, Visualforce, Force.com IDE, Force.com Migration  Tool, Web Services/SOA & Metadata APIs
  • Prior experience with data migration and ETL tools such as Informatica
  • Must have good knowledge and working experience in development & implementation of multiple SFDC projects
  • Strong development, and unit testing skills
  • Strong web development skills including CSS, JavaScript, XML, HTML, SOAP, XML, JavaScript, AJAX
  • Familiar with Services Oriented Design Principles (SOA)
  • Ability with Object Oriented Development Skills (Java, .Net)
  • Fundamental understanding of Web Services
  • SQL, RDBMS experience preferred
  • Salesforce.com Certified Force.com Developer desired, but not required

Personal Attributes:

  • Ability to work in a fast-paced environment
  • Ability to manage priorities judiciously
  • Excellent written and oral, presentation, and written communication skills
  • Excellent customer service and interpersonal skills
  • Ability to articulate ideas to both technical and non-technical audiences
  • Exceptionally self-motivated and directed
  • Keen attention to detail
  • Superior analytical, evaluative, and problem-solving abilities

 

Interested candidates must submit their cover letter, resume, and salary history to:  Recruiting@rewardsnetwork.com

 

EOE M/F/D/V

Hi,

 

I want to retrive Id from page url in javascript instead of apex class.

 

I know we can do it in apex like  

System.currentPagereference().getParameters().get('id');

 

How we can achive in ajax toolkit javascript?

 

Thanks

 

Hi,

 

I want to retrive Id from page url in javascript instead of apex class.

 

I know we can do it in apex like  

System.currentPagereference().getParameters().get('id');

 

How we can achive in ajax toolkit javascript?

 

Thanks

Hi,

 

I have visual force page where user can enter first name and last name. I made both fields as required with tag required="true" in input text.

 

I see that when user don't enter that field and hit register button, visual force shows message like "
  • j_id0:j_id31:j_id36: Validation Error: Value is required." I want to customize this message as "Validation Error: Value is required".
  •  

    Any help?

     

    Thanks

Hi,

 

I have apex terriger and within trigger I have logic and three query  which is like this.

 

List<Account> allAccount = [Select Market_Territory__c,RecordTypeId,RecordType.Name,Territory_Affiliate__c,County_and_State_Combo__c,Affiliate_Sales_Manager__c, Id,Selling_Territory__c From Account where Id in :putallAccount.KeySet()]; List<Affiliate_Management__c> affiliateManagement = [Select Name, Id From Affiliate_Management__c where Name IN :affiliateName]; List<Territory_Market__c> territoryMarket = [Select t.Territory_State__c, t.Territory_Market__c, t.Territory_County__c,t.Name,t.Market_Category__c, t.Parent_Market__r.Name,t.Parent_Market__r.Market_Category__c, t.Parent_Market__c,t.County_State_Combo__c From Territory_Market__c t where t.Name in : account];

 

all this query is outside of for loop.

 

Still I am getting toomanySoql query error.

 

I am getting error at last two query.

 

Can someone teel me what is wrong in this code?

 


Thanks

 

I create html component on home page where someoen put text in textbox and hit go buttton,case will be created.

 

Issue: It says invalid session Id. (So I used login method nad gave my username and password) but when it create case ,it define my name for owner of case. I need owner who is logged in.

 

How to get logged in user info in html home component.

 

Here is my code.

 

<script src="/soap/ajax/14.0/connection.js"></script> <script language="JavaScript" type="text/javascript"> function submitSearchForm(){ var searchField = document.getElementById('advsearchfield'); var result = sforce.connection.login("myname@xxx.com.test", "password"); var newCase = new sforce.SObject("Case"); newCase.Description =searchField.value; newCase.Status="Closed"; newCase.Origin="Hot Button"; newCase.Subject="General Inquiry"; result = sforce.connection.create([newCase]);if (result[0].getBoolean("success")) {alert("new account created with id " + result[0].id);} else {alert("failed to create account " + result[0]);}} </script> <form name="advsrch" method="post" onsubmit="return submitSearchForm();"><input class="searchTextBox" id="advsearchfield" maxlength="80" size="18" name="sbstr">&nbsp;<input class="btn" value=" Go! " type="submit"></form>

 

 

any suggestion?

 

Thanks

trigger FindMarketTerritoryFromMarket on Territory_Market__c (after insert, after update) { String dealerProspect = 'Dealer - Prospect'; //dealer prospect recType1 String dealerCustomer = 'Dealer - Customer'; // dealer cusomter recType2 String formerCustomer = 'Dealer - Former Customer'; Map<Id,Territory_Market__c> territoryMarket= new Map<Id,Territory_Market__c>(); for(Territory_Market__c t : Trigger.new) { if (System.Trigger.isInsert){ if(t.Parent_Market__c!=null && t.Territory_County__c!=null && t.Territory_State__c!=null) { territoryMarket.put(t.Id,t); system.debug('new parent name'); } }else if(t.Parent_Market__c!=Trigger.oldMap.get(t.Id).Parent_Market__c){ territoryMarket.put(t.Id,t); system.debug('new parent name updated'); } } /***********************************/ List<String> countyCombo = new List<String>(); List<String> county =new List<String>(); for(Id idsOfTerritory : territoryMarket.KeySet()){ if(territoryMarket.get(idsOfTerritory).County_State_Combo__c!=null) countyCombo.add(territoryMarket.get(idsOfTerritory).County_State_Combo__c); county.add(territoryMarket.get(idsOfTerritory).Territory_County__c); } List<Account> iterateAccount = [Select a.Market_Territory__c,a.Id,a.Name,a.County_and_State_Combo__c From Account a where (a.RecordType.Name =: dealerProspect or a.RecordType.Name=:formerCustomer) and a.ShippingState!=null and a.Shipping_County__c !=null and a.County_and_State_Combo__c in :countyCombo and a.Shipping_County__c in:county and a.RecordTypeId!=null and a.Territory_Affiliate__c like'%Cars.com%']; List<Territory_Market__c> newMarket = [select t.Parent_Market__r.Name,t.Parent_Market__r.Market_Category__c,t.County_State_Combo__c,t.Id From Territory_Market__c t where t.Id in: territoryMarket.KeySet()]; List<Account> updateAccount = new List<Account>(); for(Territory_Market__c market : newMarket){ system.debug('account size'+iterateAccount.size()); for(Integer i=0;i<iterateAccount.size();i++){ system.debug('name'+ market.Parent_Market__r.Name+','+ market.Parent_Market__c); String name = market.Parent_Market__r.Name; if(iterateAccount.get(i).County_and_State_Combo__c==market.County_State_Combo__c){ if(name!=null && name!=''&& name.contains('/')){ List <String> nameOfTerritory = name.split('/'); for(Integer j=0;j<nameOfTerritory.size();j++){ if(nameOfTerritory.get(j).contains('Cars.com')){ system.debug('found cars.com market territory'+nameOfTerritory.get(j)); if(nameOfTerritory.get(j).contains('Cars.com - National')){ iterateAccount.get(i).Market_Territory__c = 'Cars.com - National'; iterateAccount.get(i).Market_Category__c = 'I'; }else{ iterateAccount.get(i).Market_Territory__c = nameOfTerritory.get(j); iterateAccount.get(i).Market_Category__c = market.Parent_Market__r.Market_Category__c; } } } }else{ system.debug('found cars.com without / market territory'+name); if(name!=null && name.contains('Cars.com - National')){ iterateAccount.get(i).Market_Territory__c = 'Cars.com - National'; iterateAccount.get(i).Market_Category__c = 'I'; }else{ iterateAccount.get(i).Market_Territory__c = name; iterateAccount.get(i).Market_Category__c = market.Parent_Market__r.Market_Category__c; } } system.debug('account anme'+iterateAccount.get(i).name+'territory name'+name); updateAccount.add(iterateAccount.get(i)); } } } update updateAccount; }

 

I am getting error while updating parent market in Market Territory object.

 

Error:Apex trigger FindMarketTerritoryFromMarket caused an unexpected exception, contact your administrator: FindMarketTerritoryFromMarket: execution of AfterUpdate caused by: System.Exception: Too many DML rows: 244: Trigger.FindMarketTerritoryFromMarket: line 80, column 5

 

I already put update statement outside of for loop nad array list. Can some one point me some work around this?

 

Thanks

Hi,

 

I am putting value of id and stirng in map.

 

 

account.put(a.Id,a.Shipping_County__c+a.ShippingState);

 

List<Territory_Market__c> territoryMarket = [Select t.Territory_State__c, t.Territory_Market__c, t.Territory_County__c,

t.Parent_Market__r.Name, t.Parent_Market__c,t.County_State_Combo__c From Territory_Market__c t

where t.County_State_Combo__c in : account.values()];

 

Now getting list from territory market on countystate combo can have multiple record.

 

In account.values() ,each value ahve multiple recrod from market territory object. and there is breaking limit.

I just need one recrod for each value( kind of distinct).

 

How to solve this issue?

 

If I write,

 

List<Territory_Market__c> territoryMarket = new List<Territory_Market__c>();

for(Id ids : account.keySet()){List<

Territory_Market__c> getterritoryMarket =

[Select t.Territory_State__c, t.Territory_Market__c, t.Territory_County__c,t.Parent_Market__r.

Name, t.Parent_Market__c,t.County_State_Combo__c From Territory_Market__c t

where t.County_State_Combo__c = : account.get(ids) limit 1];

if(getterritoryMarket.size()>0){

territoryMarket.add(getterritoryMarket[0]);

}

}

 

then again its failing with breaking limit.

 

Any suggestion one first choice to find distinct market territory based on each account value?

 

Thanks, 

 

trigger FindMarketTerritoryFromMarket on Territory_Market__c (before insert, before update) { Map<Id,Territory_Market__c> territoryMarket= new Map<Id,Territory_Market__c>(); for(Territory_Market__c t : Trigger.new) { if(t.Parent_Market__c!=Trigger.oldMap.get(t.Id).Parent_Market__c){ territoryMarket.put(t.Id,t); System.debug(t.Parent_Market__c); } } List<Account> updateAccount = new List<Account>(); Map<Id,String> setAccount= new Map<Id,String>(); for(Id ids : territoryMarket.KeySet()){ List<Account> account = new List<Account>(); account = [Select a.Name From Account a limit 1]; } }

 

this is my code. I removed update account code from this.

 

This is simple code not doing anything yet,still it fails at account = [Select a.Name From Account a limit 1]; line.

 

It giveme error :

 

Review all error messages below to correct your data.
Apex trigger FindMarketTerritoryFromMarket caused an unexpected exception, contact your administrator: FindMarketTerritoryFromMarket: execution of BeforeUpdate caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): Trigger.FindMarketTerritoryFromMarket: line 31, column 8

 

I tried to pass only not null value still same problem. Then I rmoved all where condition and trying very simple query,still didn't help.

 

Can someone let me know workaroud for this problem?

 

Thanks

Hi,

 

I have vf page with "PDF" command button on it.

 

When user hit this PDF button in controller renderPDF method call which redirect to another vf page.

 

I need this page should be open in new window instead of redirect to same window.

 

How I can do it with page reference?

 

Thanks, 

Hi,

 

How to get timestamp for static resource like this.

 

resource/1235794002000/stylesheet_red

 

In to databse time stamp is looks like 2009-07-27T21:28:30.000z and that was systemModstamp.

 

I am confuse with which timestamp I need to take and how to write in URL.

 

Thanks

Hi, 

 

I would like to use mail merge functionality which convert into PDF instead of Microsoft Word.

 

If any one cna suggest some way(development code) or some free tool which provide this functionality.

 

I do not want to buy paid tool for this functionality.

 

Any suggestion welcome.

 

Thanks!

 

 

Hi,

 

I have Style sheet in Static resource.

I would like to add that in home page html component.

 

I know how to add this style sheet in visual force but I am confuse for home page html component.

 

Any ideas,suggestion...?

 

 

 

Hi,

 

Here is my code.

trigger affiliateHierarchyChange on Account (after insert, after update) { List<Account> accountUpdate = new List<Account>(); Map<Id,String> newAccount= new Map<Id,String>(); for(Account a : Trigger.new) { if(System.Trigger.isInsert){ if((a.RecordTypeId=='012300000000AHF') && a.Territory_Affiliate__c !=null) newAccount.put(a.Id,a.Territory_Affiliate__c); }else{ //dealer-customer if(a.RecordTypeId=='012300000000AGr' && Trigger.oldMap.get(a.Id).Selling_Territory__c!=a.Selling_Territory__c && a.Selling_Territory__c !=null){ newAccount.put(a.Id,a.Selling_Territory__c); }else if((a.RecordTypeId=='012300000000AHC'||a.RecordTypeId=='012300000000AHF') && Trigger.oldMap.get(a.Id).Territory_Affiliate__c!=a.Territory_Affiliate__c && a.Territory_Affiliate__c !=null){ newAccount.put(a.Id,a.Territory_Affiliate__c); } } } Map<Id,String> test=new Map<Id,String>(); for(Id ids:newAccount.KeySet()){ List<Affiliate_Management__c> affiliateManagement = new List<Affiliate_Management__c>(); affiliateManagement = [Select a.Name, a.Id From Affiliate_Management__c a where a.Name=: newAccount.get(ids)]; if(affiliateManagement.size() > 0){ test.put(ids,affiliateManagement[0].Id); //Account accountSreach = [Select Affiliate_Sales_Manager__c,Id From Account WHERE Id =: ids]; //accountSreach.Affiliate_Sales_Manager__c =affiliateManagement[0].Id; //accountUpdate.add(accountSreach); } } for(Account accountSearch :[Select Affiliate_Sales_Manager__c,Id From Account WHERE Id in : test.keySet() ]){ // Account accountSreach = [Select Affiliate_Sales_Manager__c,Id From Account WHERE Id =: ids]; accountSearch.Affiliate_Sales_Manager__c =test.get(accountSearch.Id); accountUpdate.add(accountSearch); } update accountUpdate; }

 

I am getting system exception:Too many SOQL queries:21

 

Can some one point how to solve this.

 

I know that we can not write query in insert or update trigger,so I separate it out in for loop.

 

Still it fails at

 

for(Account accountSearch :[Select Affiliate_Sales_Manager__c,Id From Account WHERE Id in : test.keySet() ]){

 

-Thanks

Hi,

 

I have tabbed view on account page.I have two tabbed name summary(default tab) and oppotunity tab

 

when user click on summary to oppotunity tab,I need page should befresh.

 

So when user click on opportunity tab under acocunt tabbed view,and click on any opportunity under this tab new opportunity page will open and when user hit back button,it should be back to opportunity tab.(rihgt now if I user client as switch type in tabpanel,if back to summary tab)

 

So I tried server as swithch type,it was working fine with refresh but its not working with back and forowrd button of browser.

 

Initally url is https://xyz.salesforce.com/apex/tabbedaccounttest?id='xyz' and shows summary tab.

when I click on opportunity url become https://xyz.salesforce.com/apex/tabbedaccounttest and shows opportunity tab.

Afte that if I hit back button of brower,its not coming back to summary tab.

 

How to achive this senario?

 

-Thanks,

 

Message Edited by learnSF on 04-08-2009 08:32 AM

Hi,

 

I am trying to create task when account recrod type is dealer customer and manafer value polulate form null value.

 

Here is my code.

 

trigger assignTask on Account (before update) { List<Task> task = new List<Task>(); for (Integer i = 0; i < Trigger.new.size(); i++) { //System.debug('territorys'+territory); if(Trigger.new[i].RecordTypeId=='012300000000AGr'){ if ( (Trigger.old[i].Account_Manager__c != Trigger.new[i].Account_Manager__c)&&(Trigger.old[i].Account_Manager__c ==null)){ String taskname='New Dealer SAP '+Trigger.new[i].Name; if(taskname.length()>79){ taskname=taskname.substring(0,78); } task.add(new Task( RecordTypeId ='01240000000Ditr', // RecordTypeId ='012T00000004Uql', WhatId=Trigger.new[i].Id, OwnerId=Trigger.new[i].Account_Manager__c, Subject=taskname )); } } } }

 

 now if I change first recrod type dealer prospect to dealer customer- and saved it.

after that with same account edit it and add account manager it works fine.It jsut create one task.

 

 

anothe senario for update:account which is dealer prospect and I click on change recrod type and choose delaer cusomter as record type and hit next button and add manager info and saved it. It created two task.

 

Can some one points out why in second senarion it creates two task,while only one time upsate happens.

 

first seanrio working fine,but second it fails.

 

-thanks

 

 

Hi,

 

Here is my formula field say TaskFlag: IF( DAY( TODAY() ) =20, 'pass', 'fail')

 

Now I wrote one time based workflow that when TaskFlag become pass,fire flowflow immidiate and update Account.Net__c field inside account.

 

I have noticed that workflow didn't fire even TaskFlag set to 'pass'.

 

Can anyone drive me that how to achive this functionality?

Hi,

 

I wrote code for s-control and palce one button on this code.

 

now I want when user press this button second s-control/visual force page code should be executed.

 

How I can achive this funcitionality?

 

 

Hi,

 

I wrote trigger ,which work fine manualy but dind't work with data loader.

 

Here is my code.

 

trigger RateChangeContract on Account (before update) { List<Contract_History_Tracker__c> contractHistory = new List<Contract_History_Tracker__c>(); Map<String,Account> newAccount= new Map<String,Account>(); for (Integer i = 0; i < Trigger.new.size(); i++) { String territory=Trigger.new[i].Selling_Territory__c; if(territory!=null && territory.length() >3){ territory=territory.substring(0,4); } //System.debug('territorys'+territory); if(Trigger.new[i].RecordTypeId=='012300000000AGr' && Trigger.new[i].Type=='Dealership' && territory =='Cars'){ if ( (Trigger.old[i].Current_Contract_Date__c == Trigger.new[i].Current_Contract_Date__c)&& (Trigger.old[i].Total_Monthly_Rate__c != Trigger.new[i].Total_Monthly_Rate__c)) { newAccount.put(Trigger.new[i].Id,Trigger.new[i]); } } } for (Contract_History_Tracker__c contractHist : [Select Current_Rate__c, CreatedDate, Account__c,Id From Contract_History_Tracker__c where Account__c IN : newAccount.KeySet() Order By CreatedDate Desc limit 1]){ Account a= newAccount.get(contractHist.Account__c); contractHist.Current_Rate__c=a.Total_Monthly_Rate__c; contractHistory.add(contractHist); } update contractHistory; }

 

This works fine for first account and after that it didnot update contract hisotry.

 

I changed my code to this now and its works fine for every account but I have some thoughts that it may with breking limits of trigger as I am writing query inside trigger.

 

Here is working code.

 

trigger RateChangeContract on Account (before update) { //List<Contract_History_Tracker__c> contractHistory = new List<Contract_History_Tracker__c>(); Map<String,Account> newAccount= new Map<String,Account>(); for (Integer i = 0; i < Trigger.new.size(); i++) { String territory=Trigger.new[i].Selling_Territory__c; if(territory!=null && territory.length() >3){ territory=territory.substring(0,4); } //System.debug('territorys'+territory); if(Trigger.new[i].RecordTypeId=='012300000000AGr' && Trigger.new[i].Type=='Dealership' && territory =='Cars'){ if ( (Trigger.old[i].Current_Contract_Date__c == Trigger.new[i].Current_Contract_Date__c)&& (Trigger.old[i].Total_Monthly_Rate__c != Trigger.new[i].Total_Monthly_Rate__c)) { System.debug(Trigger.new[i].Total_Monthly_Rate__c); Contract_History_Tracker__c contractHistory= [Select Current_Rate__c, CreatedDate, Account__c,Id From Contract_History_Tracker__c where Account__c=:Trigger.new[i].Id Order By CreatedDate Desc limit 1]; contractHistory.Current_Rate__c=Trigger.new[i].Total_Monthly_Rate__c; update contractHistory; } } } }

 

I have two question now.

 

1. How to fix first code so that it gives same functionality which second code gives.

 

2. If I am using second code,for how many account tirgger will work fine without breaking limit and giving exception like(dml exception)

 

-Thanks,

hi,
 
I want to decode attahcment body into normal string.I wrote code like this.
I am getting attachment body from salesforce data base.
I have checked in DB that this attachment have body content in data base.
 
byte encoded[] = Base64.decodeBase64(fullAtt.getBody());

and I am using org.apache.commons.codec.binary.Base64.java class for decode.

Here code is failing and givng ArrayIndexOutofBound exception.

Can anyone give some suggestion on it?

Hi,

 

I have apex terriger and within trigger I have logic and three query  which is like this.

 

List<Account> allAccount = [Select Market_Territory__c,RecordTypeId,RecordType.Name,Territory_Affiliate__c,County_and_State_Combo__c,Affiliate_Sales_Manager__c, Id,Selling_Territory__c From Account where Id in :putallAccount.KeySet()]; List<Affiliate_Management__c> affiliateManagement = [Select Name, Id From Affiliate_Management__c where Name IN :affiliateName]; List<Territory_Market__c> territoryMarket = [Select t.Territory_State__c, t.Territory_Market__c, t.Territory_County__c,t.Name,t.Market_Category__c, t.Parent_Market__r.Name,t.Parent_Market__r.Market_Category__c, t.Parent_Market__c,t.County_State_Combo__c From Territory_Market__c t where t.Name in : account];

 

all this query is outside of for loop.

 

Still I am getting toomanySoql query error.

 

I am getting error at last two query.

 

Can someone teel me what is wrong in this code?

 


Thanks

 

Hello, This is Jeff and I represent Elite Innovative Solutions Inc. We currently have an urgent job requirement for our client of position SFDC (Salesforce.com) Developer located at New York, NY / Santa Clara, CA, which you may be suited or interested in. Please do send me a copy of your updated resume and the best time and # to jeff@eliteisinc.com

Job Title    :  SFDC (Salesforce.com) Developer
Location    :  New York, NY / Santa Clara, CA
Duration    :  FULL TIME

Ideal candidate should have 3 yrs experience in SFDC technical developer , must have experience in APEX , Visual Force  and Salesforce.com Integration. Must have good communication skills.

Thanks & Regards  Jeff Healey Elite Innovative Solutions, Inc. Irving, TX 75038 Office : 408-850-1453Fax:972.782.9215jeff@eliteisinc.comURL:www.eliteisinc.com

Hi All,

 

I am updating opportunities while updating the Account Owner.

 

Opportunities are more than 100 , so i divided into batches of 50 

 

but i am still getting the DML execption while updating 300 records ( max DML satatements should be 6)

 

\Error: Apex trigger PAMUpdate caused an unexpected exception, contact your administrator: PAMUpdate: execution of BeforeUpdate caused by: System.Exception: Too many DML rows: 147: Trigger.PAMUpdate: line 63, column 5

 

 Here is my complete snipped of code

 

trigger PAMUpdate on Account (before update) {

    Map <Id, String> acc = new Map <Id, String>();

    List<String> accountList = new List<String>();

    for (Account a : Trigger.new)

    {

        String oppOwner = Trigger.oldMap.get(a.Id).OwnerId;

        if (a.IsPartner == true && a.OwnerId != oppOwner)

        {           

            accountList.add(a.Id);

        }

    }
  //  System.debug(' Accounts are ' + accountList );
   // System.debug(' Account Size is =  ' + accountList.size() );
 
   
 List<Opportunity> oppList = new List<Opportunity>();

    if(accountList.size()>0)

    {  

        oppList  = [select PAM__c,PartnerAccountId from Opportunity

                                     where PartnerAccountId In : accountList limit 300];

        }
        for(Opportunity oppRec:oppList)

        {

            oppRec.PAM__c = Trigger.newMap.get(oppRec.PartnerAccountId).OwnerId;

        }

       
 if(oppList.size() > 50){
       List<Opportunity> subList = new List<Opportunity>();

for(Opportunity record : oppList){

subList.add(record);

if(subList.size()==49){

try{
    update subList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}
subList.clear();
}
}
if(subList.size() > 0){

try{
    update subList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}
}

}else{

try{
    update oppList;  }
    catch(Exception ex){
            System.debug(' Exception Occured' + ex);}

} }

 

Please suggest if i am doing any thing wrong while updating .

 

Thanks in advance

  • December 21, 2009
  • Like
  • 0

I create html component on home page where someoen put text in textbox and hit go buttton,case will be created.

 

Issue: It says invalid session Id. (So I used login method nad gave my username and password) but when it create case ,it define my name for owner of case. I need owner who is logged in.

 

How to get logged in user info in html home component.

 

Here is my code.

 

<script src="/soap/ajax/14.0/connection.js"></script> <script language="JavaScript" type="text/javascript"> function submitSearchForm(){ var searchField = document.getElementById('advsearchfield'); var result = sforce.connection.login("myname@xxx.com.test", "password"); var newCase = new sforce.SObject("Case"); newCase.Description =searchField.value; newCase.Status="Closed"; newCase.Origin="Hot Button"; newCase.Subject="General Inquiry"; result = sforce.connection.create([newCase]);if (result[0].getBoolean("success")) {alert("new account created with id " + result[0].id);} else {alert("failed to create account " + result[0]);}} </script> <form name="advsrch" method="post" onsubmit="return submitSearchForm();"><input class="searchTextBox" id="advsearchfield" maxlength="80" size="18" name="sbstr">&nbsp;<input class="btn" value=" Go! " type="submit"></form>

 

 

any suggestion?

 

Thanks

Does anyone know how I'd go about creating a trigger to convert a lead to an account contact and oppty, based upon a field in the lead?  For example, A lead score of > 30, I'd like to trigger the lead to automatically convert, and kick off a notification email. 

 

Has anyone done this before?

 

Thanks!

Chris

Where can I find code to create a custom link on the opportunity to pull up a map of the address?

 

I was hoping to find code somewhere then figure out how to add my fields to the address fields in Google.

 

Is it harder than I am making it sound? I have no coding experience other than some apex coding testing. Any suggestions?

  • December 08, 2009
  • Like
  • 0

trigger FindMarketTerritoryFromMarket on Territory_Market__c (before insert, before update) { Map<Id,Territory_Market__c> territoryMarket= new Map<Id,Territory_Market__c>(); for(Territory_Market__c t : Trigger.new) { if(t.Parent_Market__c!=Trigger.oldMap.get(t.Id).Parent_Market__c){ territoryMarket.put(t.Id,t); System.debug(t.Parent_Market__c); } } List<Account> updateAccount = new List<Account>(); Map<Id,String> setAccount= new Map<Id,String>(); for(Id ids : territoryMarket.KeySet()){ List<Account> account = new List<Account>(); account = [Select a.Name From Account a limit 1]; } }

 

this is my code. I removed update account code from this.

 

This is simple code not doing anything yet,still it fails at account = [Select a.Name From Account a limit 1]; line.

 

It giveme error :

 

Review all error messages below to correct your data.
Apex trigger FindMarketTerritoryFromMarket caused an unexpected exception, contact your administrator: FindMarketTerritoryFromMarket: execution of BeforeUpdate caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): Trigger.FindMarketTerritoryFromMarket: line 31, column 8

 

I tried to pass only not null value still same problem. Then I rmoved all where condition and trying very simple query,still didn't help.

 

Can someone let me know workaroud for this problem?

 

Thanks

Hi,

 

How to get timestamp for static resource like this.

 

resource/1235794002000/stylesheet_red

 

In to databse time stamp is looks like 2009-07-27T21:28:30.000z and that was systemModstamp.

 

I am confuse with which timestamp I need to take and how to write in URL.

 

Thanks

Hi, 

 

I would like to use mail merge functionality which convert into PDF instead of Microsoft Word.

 

If any one cna suggest some way(development code) or some free tool which provide this functionality.

 

I do not want to buy paid tool for this functionality.

 

Any suggestion welcome.

 

Thanks!

 

 

What is this LastActivityDate keep track on ?

  • July 24, 2009
  • Like
  • 0

Hi,

 

Here is my code.

trigger affiliateHierarchyChange on Account (after insert, after update) { List<Account> accountUpdate = new List<Account>(); Map<Id,String> newAccount= new Map<Id,String>(); for(Account a : Trigger.new) { if(System.Trigger.isInsert){ if((a.RecordTypeId=='012300000000AHF') && a.Territory_Affiliate__c !=null) newAccount.put(a.Id,a.Territory_Affiliate__c); }else{ //dealer-customer if(a.RecordTypeId=='012300000000AGr' && Trigger.oldMap.get(a.Id).Selling_Territory__c!=a.Selling_Territory__c && a.Selling_Territory__c !=null){ newAccount.put(a.Id,a.Selling_Territory__c); }else if((a.RecordTypeId=='012300000000AHC'||a.RecordTypeId=='012300000000AHF') && Trigger.oldMap.get(a.Id).Territory_Affiliate__c!=a.Territory_Affiliate__c && a.Territory_Affiliate__c !=null){ newAccount.put(a.Id,a.Territory_Affiliate__c); } } } Map<Id,String> test=new Map<Id,String>(); for(Id ids:newAccount.KeySet()){ List<Affiliate_Management__c> affiliateManagement = new List<Affiliate_Management__c>(); affiliateManagement = [Select a.Name, a.Id From Affiliate_Management__c a where a.Name=: newAccount.get(ids)]; if(affiliateManagement.size() > 0){ test.put(ids,affiliateManagement[0].Id); //Account accountSreach = [Select Affiliate_Sales_Manager__c,Id From Account WHERE Id =: ids]; //accountSreach.Affiliate_Sales_Manager__c =affiliateManagement[0].Id; //accountUpdate.add(accountSreach); } } for(Account accountSearch :[Select Affiliate_Sales_Manager__c,Id From Account WHERE Id in : test.keySet() ]){ // Account accountSreach = [Select Affiliate_Sales_Manager__c,Id From Account WHERE Id =: ids]; accountSearch.Affiliate_Sales_Manager__c =test.get(accountSearch.Id); accountUpdate.add(accountSearch); } update accountUpdate; }

 

I am getting system exception:Too many SOQL queries:21

 

Can some one point how to solve this.

 

I know that we can not write query in insert or update trigger,so I separate it out in for loop.

 

Still it fails at

 

for(Account accountSearch :[Select Affiliate_Sales_Manager__c,Id From Account WHERE Id in : test.keySet() ]){

 

-Thanks

Hi,

 

I am trying to create task when account recrod type is dealer customer and manafer value polulate form null value.

 

Here is my code.

 

trigger assignTask on Account (before update) { List<Task> task = new List<Task>(); for (Integer i = 0; i < Trigger.new.size(); i++) { //System.debug('territorys'+territory); if(Trigger.new[i].RecordTypeId=='012300000000AGr'){ if ( (Trigger.old[i].Account_Manager__c != Trigger.new[i].Account_Manager__c)&&(Trigger.old[i].Account_Manager__c ==null)){ String taskname='New Dealer SAP '+Trigger.new[i].Name; if(taskname.length()>79){ taskname=taskname.substring(0,78); } task.add(new Task( RecordTypeId ='01240000000Ditr', // RecordTypeId ='012T00000004Uql', WhatId=Trigger.new[i].Id, OwnerId=Trigger.new[i].Account_Manager__c, Subject=taskname )); } } } }

 

 now if I change first recrod type dealer prospect to dealer customer- and saved it.

after that with same account edit it and add account manager it works fine.It jsut create one task.

 

 

anothe senario for update:account which is dealer prospect and I click on change recrod type and choose delaer cusomter as record type and hit next button and add manager info and saved it. It created two task.

 

Can some one points out why in second senarion it creates two task,while only one time upsate happens.

 

first seanrio working fine,but second it fails.

 

-thanks

 

 

I have a PDF form with various checkbox, text and dropdown controls.


I need to populate some of these fields before view it to user and then the user needs to fill out the rest of the fields left empty.

 

Standard Visualforce "RenderAs" PDF does not seem to be the solution.

 

 

Has anyone had any exprience with the above problem?

Hi,

 

I wrote trigger ,which work fine manualy but dind't work with data loader.

 

Here is my code.

 

trigger RateChangeContract on Account (before update) { List<Contract_History_Tracker__c> contractHistory = new List<Contract_History_Tracker__c>(); Map<String,Account> newAccount= new Map<String,Account>(); for (Integer i = 0; i < Trigger.new.size(); i++) { String territory=Trigger.new[i].Selling_Territory__c; if(territory!=null && territory.length() >3){ territory=territory.substring(0,4); } //System.debug('territorys'+territory); if(Trigger.new[i].RecordTypeId=='012300000000AGr' && Trigger.new[i].Type=='Dealership' && territory =='Cars'){ if ( (Trigger.old[i].Current_Contract_Date__c == Trigger.new[i].Current_Contract_Date__c)&& (Trigger.old[i].Total_Monthly_Rate__c != Trigger.new[i].Total_Monthly_Rate__c)) { newAccount.put(Trigger.new[i].Id,Trigger.new[i]); } } } for (Contract_History_Tracker__c contractHist : [Select Current_Rate__c, CreatedDate, Account__c,Id From Contract_History_Tracker__c where Account__c IN : newAccount.KeySet() Order By CreatedDate Desc limit 1]){ Account a= newAccount.get(contractHist.Account__c); contractHist.Current_Rate__c=a.Total_Monthly_Rate__c; contractHistory.add(contractHist); } update contractHistory; }

 

This works fine for first account and after that it didnot update contract hisotry.

 

I changed my code to this now and its works fine for every account but I have some thoughts that it may with breking limits of trigger as I am writing query inside trigger.

 

Here is working code.

 

trigger RateChangeContract on Account (before update) { //List<Contract_History_Tracker__c> contractHistory = new List<Contract_History_Tracker__c>(); Map<String,Account> newAccount= new Map<String,Account>(); for (Integer i = 0; i < Trigger.new.size(); i++) { String territory=Trigger.new[i].Selling_Territory__c; if(territory!=null && territory.length() >3){ territory=territory.substring(0,4); } //System.debug('territorys'+territory); if(Trigger.new[i].RecordTypeId=='012300000000AGr' && Trigger.new[i].Type=='Dealership' && territory =='Cars'){ if ( (Trigger.old[i].Current_Contract_Date__c == Trigger.new[i].Current_Contract_Date__c)&& (Trigger.old[i].Total_Monthly_Rate__c != Trigger.new[i].Total_Monthly_Rate__c)) { System.debug(Trigger.new[i].Total_Monthly_Rate__c); Contract_History_Tracker__c contractHistory= [Select Current_Rate__c, CreatedDate, Account__c,Id From Contract_History_Tracker__c where Account__c=:Trigger.new[i].Id Order By CreatedDate Desc limit 1]; contractHistory.Current_Rate__c=Trigger.new[i].Total_Monthly_Rate__c; update contractHistory; } } } }

 

I have two question now.

 

1. How to fix first code so that it gives same functionality which second code gives.

 

2. If I am using second code,for how many account tirgger will work fine without breaking limit and giving exception like(dml exception)

 

-Thanks,

I wonder if it is possible to go back to the tab that you were previously on if you access a related list from the tabbed layout.
 
Like I have two tab on page layout. first is summary and second is opportunity.
 
when user click on opportunity tab and click on any of opportunity form tabeed page,it will redirect to opportunity page.when user click back button on browser,the tabeed apge view summary tab.
 
I want when user click back button,opportunity page should be redirect to opportunity tab instead of summary tab.
 
Can it be possible in visual force page?