• anil87
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Hi ,

 
I have a trigger  which updates  lead fields from event which is working fine.But whenever i'm working on Business Account records i'm getting an error like  
 
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Trigger.NewEventLeadUpdate: line 16, column 1
 
However it is working fine with person accounts as well.For opportunities also it is working fine with which are associated with person accounts only not with business accounts. 
 
Kindly let me know where i'm going wrong  any help greatly appreciated.
 
trigger NewEventLeadUpdate on Event (before insert, before update) {
 
 lead[] leads = new lead[ 0 ];
   
  for( event event : trigger.new ) {
   
 try{
    if( (lead.Next_Event__c == null && event.whoid != null)||(string.valueOf(event.StartDateTime) < string.valueOf(lead.Next_Event__c))){
     leads.add( new lead( id = event.whoid,Next_Event__c = event.StartDateTime ) );
    }
    }
    catch(exception e){
    // to capture the error during editing the event
    }
  }
  update leads; ///line 16, column 1
}
  • February 28, 2013
  • Like
  • 0

Hi All.

          i want  When opportunity is updated & Email or Fax fields are changed

 
if Account - Record type is Person Account, 
then update Email & Fax fields on the Person Account Record.
 
else
 
if Account - Record type is Business Account, 
then update Email & Fax fields on the contact record on the Account.
 
Here is my approach but  i'm getting the folloeing error
 
System.DmlException: Update failed. First exception on row 0 with id 001c0000008xwoaAAA; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Business Account may not use Person Account field PersonEmail: [PersonEmail]: Trigger.UpdateEmailFax: line 37, column 1

 

trigger UpdateEmailFax on Opportunity (after update)
{
    List<Account> acc = new List<Account>();
    List<Contact> con = new List<Contact>();
    List<Id> aid = new List<Id>();
    Map<Id,Opportunity> accMap = new Map<Id,Opportunity>();
    Integer i = 0;
    for(Opportunity o : trigger.new)
    {
        system.debug('Inside For loop : ' + i + ' Account id : ' + o.AccountId);
        if(o.AccountId!=null)
        {
            system.debug('Old value - Email : ' + trigger.old[i].Email__c + ', Fax : ' + trigger.old[i].Fax__c);
            if((trigger.old[i].Email__c!=o.Email__c) || (trigger.old[i].Fax__c!=o.Fax__c))
            {
                if(o.Account.RecordType.Name == 'Business_Account')
                {
                    system.debug('Business_Account - Record Type : ' + o.Account.RecordType.Name);
                    accMap.put(o.AccountId,o);
                    aid.add(o.Account.id);
                }
                else
                {
                    system.debug('Person_Account  - Record Type : ' + o.Account.RecordType.Name);
                    Account a = new Account();
                    //o.Account.PersonEmail = o.Email__c;
                    //o.Account.Fax = o.Fax__c;
                    a.id = o.AccountId;
                    a.PersonEmail = o.Email__c;
                    a.Fax = o.Fax__c;
                    acc.add(a);
                }
            }
        }
       i++;
    }
    update acc; // ERROR IS HERE
    //con = [select id,name,Account.id, Email , Fax from Contact where Account.id in :aid];
    for(Contact c : [select id,name,Account.id, Email , Fax from Contact where Account.id in :aid])
    {
        if(c.Account!=null)
        {
            c.Email  = accMap.get(c.Account.id).Email__c;  
            c.Fax = accMap.get(c.Account.id).Fax__c;
            con.add(c);
        }
    }
    update con;
}

  • February 27, 2013
  • Like
  • 0

Hi Everyone.

 

When a Sales user from my production is viewing their Events on the calendar, it only links to the Account... is there a way to just have it link to the opportunity?

 

Anil

  • February 27, 2013
  • Like
  • 0

Hi Everyone.

 

When a Sales user from my production is viewing their Events on the calendar, it only links to the Account... is there a way to just have it link to the opportunity?

 

Anil

  • February 27, 2013
  • Like
  • 0

Hi Everyone.

 

When a Sales user from my production is viewing their Events on the calendar, it only links to the Account... is there a way to just have it link to the opportunity?

 

Anil

  • February 27, 2013
  • Like
  • 0
Hi Everyone,
 
We'd like to convert multiple leads into Multiple Person Account & Opportunities. They should also be assigned the correct name. 
ex: Lead Name: Marc benioff could be converted into a Person account with the name of Marc benioff and Opp name of Marc benioff.
i came across "Mass Lead Converter by Force.com Labs" it has a limitation of  100 records for click i need to overcome this too..Any help greatly apreciated..

 

  • February 20, 2013
  • Like
  • 0

Hi Everyone,

 

I created a VF which will converts a lead into account.contact and opportunity then i overrided my standard convert button with my VF,it is working in my sandbox but when coming to my production it is not working properly . here is my debug log code

 

27.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO 10:54:52.083 (83078000)|EXECUTION_STARTED

10:54:52.083 (83127000)|CODE_UNIT_STARTED|[EXTERNAL]|066E0000001JfHV|VF: /apex/ConvertLead 10:54:52.089 (89230000)|CODE_UNIT_STARTED|[EXTERNAL]|01pE0000001yDGg|ConvertLeadsController <init> 10:54:52.089 (89255000)|SYSTEM_MODE_ENTER|true

10:54:52.090 (90047000)|METHOD_ENTRY|[8]|01pE0000001yDGg|ConvertLeadsController.ConvertLeadsController() 10:54:52.090 (90166000)|SYSTEM_MODE_ENTER|false 10:54:52.090 (90180000)|SYSTEM_MODE_EXIT|false 10:54:52.090 (90191000)|METHOD_EXIT|[8]|ConvertLeadsController 10:54:52.090 (90283000)|SYSTEM_MODE_ENTER|false

10:54:52.090 (90334000)|SYSTEM_METHOD_ENTRY|[14]|ApexPages.StandardController.getRecord()

10:54:52.121 (121336000)|SYSTEM_METHOD_EXIT|[14]|ApexPages.StandardController.getRecord()

10:54:52.121 (121384000)|METHOD_ENTRY|[14]|01pE0000001yDGg|ConvertLeadsController.__sfdc_objLead(Lead) 10:54:52.121 (121406000)|METHOD_EXIT|[14]|01pE0000001yDGg|ConvertLeadsController.__sfdc_objLead(Lead) 10:54:52.121 (121419000)|SYSTEM_MODE_EXIT|false

10:54:52.121 (121440000)|CODE_UNIT_FINISHED|ConvertLeadsController <init>

10:54:52.121 (121545000)|CODE_UNIT_STARTED|[EXTERNAL]|01pE0000001yDGg|ConvertLeadsController invoke(convertLead)

10:54:52.121 (121624000)|SYSTEM_MODE_ENTER|false

10:54:52.122 (122141000)|METHOD_ENTRY|[22]|01pE0000001yDGg|ConvertLeadsController.__sfdc_objLead() 10:54:52.122 (122179000)|METHOD_EXIT|[22]|01pE0000001yDGg|ConvertLeadsController.__sfdc_objLead() 10:54:52.122 (122370000)|SYSTEM_METHOD_ENTRY|[25]|system.UserInfo.getUserId()

10:54:52.122 (122424000)|SYSTEM_METHOD_EXIT|[25]|system.UserInfo.getUserId()

10:54:52.125 (125257000)|SOQL_EXECUTE_BEGIN|[25]|Aggregations:0|select Id, username from User where Id = :tmpVar1

10:54:52.163 (163121000)|SOQL_EXECUTE_END|[25]|Rows:1

10:54:52.164 (164763000)|SOQL_EXECUTE_BEGIN|[29]|Aggregations:0|select Id, MasterLabel from LeadStatus where IsConverted = true limit 1

10:54:52.185 (185106000)|SOQL_EXECUTE_END|[29]|Rows:1

10:54:52.186 (186522000)|METHOD_ENTRY|[35]|01pE0000001yDGg|ConvertLeadsController.__sfdc_objLead() 10:54:52.186 (186564000)|METHOD_EXIT|[35]|01pE0000001yDGg|ConvertLeadsController.__sfdc_objLead() 10:54:52.186 (186662000)|SYSTEM_METHOD_ENTRY|[38]|Database.convertLead(Database.LeadConvert) 10:54:52.186 (186829000)|DML_BEGIN|[38]|Op:ConvertLead|Type:LeadConvertResult|Rows:1

10:54:52.194 (194410000)|DML_END|[38]

10:54:52.194 (194545000)|EXCEPTION_THROWN|[38]|System.DmlException: ConvertLead failed. First exception on row 0; first error: UNAVAILABLE_RECORDTYPE_EXCEPTION, Unable to find default record type: []

10:54:52.195 (195999000)|SYSTEM_METHOD_EXIT|[38]|Database.convertLead(Database.LeadConvert)

10:54:52.196 (196242000)|SYSTEM_METHOD_ENTRY|[50]|System.DmlException.getMessage()

10:54:52.196 (196289000)|SYSTEM_METHOD_EXIT|[50]|System.DmlException.getMessage()

10:54:52.196 (196378000)|SYSTEM_METHOD_ENTRY|[50]|ApexPages.addMessage(ApexPages.Message) 10:54:52.196 (196409000)|VF_PAGE_MESSAGE|ConvertLead failed. First exception on row 0; first error: UNAVAILABLE_RECORDTYPE_EXCEPTION, Unable to find default record type: []

10:54:52.196 (196423000)|SYSTEM_METHOD_EXIT|[50]|ApexPages.addMessage(ApexPages.Message)

10:54:52.196 (196437000)|SYSTEM_MODE_EXIT|false

10:54:52.197 (197050000)|CODE_UNIT_FINISHED|ConvertLeadsController invoke(convertLead)

10:54:52.197 (197099000)|VF_APEX_CALL|j_id0|{!convertLead}|PageReference: none

10:54:52.255 (255980000)|VF_SERIALIZE_VIEWSTATE_BEGIN|066E0000001JfHV

10:54:52.258 (258363000)|VF_SERIALIZE_VIEWSTATE_END

10:54:52.393 (262891000)|CUMULATIVE_LIMIT_USAGE

10:54:52.393|LIMIT_USAGE_FOR_NS|(default)|

Number of SOQL queries: 2 out of 100

Number of query rows: 2 out of 50000

Number of SOSL queries: 0 out of 20

Number of DML statements: 1 out of 150

Number of DML rows: 1 out of 10000

Number of code statements: 15 out of 200000

Maximum heap size: 0 out of 6000000

Number of callouts: 0 out of 10

Number of Email Invocations: 0 out of 10

Number of fields describes: 0 out of 100

Number of record type describes: 0 out of 100

Number of child relationships describes: 0 out of 100

Number of picklist describes: 0 out of 100

Number of future calls: 0 out of 10 10:54:52.393|CUMULATIVE_LIMIT_USAGE_END

10:54:52.262 (262933000)|CODE_UNIT_FINISHED|VF: /apex/ConvertLead

10:54:52.262 (262946000)|EXECUTION_FINISHED

  • February 18, 2013
  • Like
  • 0

Hi Everyone,

 

I Have to  add the owner change to the below Trigger that updated Last Call Result and Notes field.Now i want to change  owner to user who created/modified the activity that Triggered? 
 
this is my trigger
 
trigger StatusChangesAccount on Task (after insert,after update)
{
    List<Contact> cons = new List<Contact>();
    List<Opportunity> opps = new List<Opportunity>();
    List<Account> accs = new List<Account>();
    List<Creditor__c> creds = new List<Creditor__c>();
    for(Task t : trigger.new )
    {
        String wtid = t.whatid;
        system.debug('*** What ID : ' + wtid);
        String whid = t.whoid;
        system.debug('*** Who ID : ' + whid);
        if(whid != null)
        {
             try
             {
                 cons.add( new Contact( id = whid, Last_Call_Result__c = t.CallDisposition) );
                 system.debug('*** Contact Inserted in first IF ');
             }
             catch(Exception e){}
        }
        if(wtid != null)
        {
            
            try
            {
            creds.add(new Creditor__c(id = wtid, Last_Call_Result__c = t.CallDisposition ));
            system.debug('*** Creditor__c Inserted in first IF ');
            }
            catch(Exception e){}
            try
            {
            accs.add(new Account(id = wtid, Last_Call_Result__c = t.CallDisposition ));
            system.debug('*** Account Inserted in first IF ');
            }
            catch(Exception e){}
            
            
            
            try
            {
            opps.add(new Opportunity(id = wtid, Last_Call_Result__c = t.CallDisposition ));
            system.debug('*** Oppurtunity Inserted in first IF ');
            }
            catch(Exception e){}
        }
    }
    try{update accs;system.debug('Account Update');}catch(Exception e){}
    try{update opps;system.debug('Oppurtunity Update');}catch(Exception e){}
    try{update cons;system.debug('Contact Update');}catch(Exception e){}
    try{update creds;system.debug('Creditor Update');}catch(Exception e){}
}
  • February 13, 2013
  • Like
  • 0

Hi,

 

We like to have a Custom Lead Accept button which would be used on the Search Results Page.

 

When the user selects the Leads and clicks the button, it should assign the Lead ownership to the Person who clicked the button.how i can achieve this any help appriciate greatly

  • February 08, 2013
  • Like
  • 0

HI Everyone ,

 

I want to caliculate  the open activities on lead object i included  yhe yasks which are isclosed = false which gives open tasks

like wise how i get open events to inclede in my count...

  • February 07, 2013
  • Like
  • 0

Hi Everyone,

 

We want to capture the Total Open Activities Events & Task) on the Lead & Opportunity objects, When there are no Open Activities the Total Open Activities field should be 0..How can i achieve this

  • February 07, 2013
  • Like
  • 0

Hi Everyone,

 

I have a trigger (statuschanges) running right now that updates a custom field on the lead "LastCallResult__c" with the CallResult/CallDisposition from the call activity.(Tasl Object)

 

Now that we'll be using Opportunity, Acct, Contact, etc... We will need this trigger updated based on the WhoId/WhatID on the Activity.
 
Any help appreciated greatly.
  • January 30, 2013
  • Like
  • 0

Hi Everyone

 

i need to erite test class for the following trigger tell me how to write test class with this trigger

 

trigger capturingoppproducts on Opportunity (after insert,after update) {

List<OpportunityLineItem> oli=new List<OpportunityLineItem>();
List<product2> pro=new List<product2>();
List<FullFillment_Part__c> ffp=new List<FullFillment_Part__c>();
Set<ID> prodids =new Set<ID>();

for(Opportunity o:trigger.new){
if(o.Design_Win_Approval_Process__c=='Approved')
{
oli=[select PricebookEntryId,PricebookEntry.Product2Id from OpportunityLineItem
where Opportunityid =: o.id];
}

for(OpportunityLineItem ol:oli){

prodids.add(ol.PricebookEntry.Product2Id);
}
System.Debug('Product Ids are '+prodids);

pro=[select id,name,ProductCode from Product2
where id in: prodids];

for(product2 p:pro){

FullFillment_Part__c fp=new FullFillment_Part__c();
fp.Opportunity__c=o.id;
fp.product__c=p.id;
fp.Fullfillment_Part__c=p.id;

list<OpportunityLineItem> ol=[select PricebookEntryId,PricebookEntry.Product2Id,Product_Design_Win_Value_USD_1__c,Product_Design_Win_Value_USD_2__c from OpportunityLineItem
where PricebookEntry.Product2Id =:p.id and Opportunityid =: o.id];
for(OpportunityLineItem oli1:ol){

fp.Product_Design_Win_Value_USD__c=oli1.Product_Design_Win_Value_USD_1__c;
fp.Product_Design_Win_Value_USD_Adjust__c=oli1.Product_Design_Win_Value_USD_2__c;

}
ffp.add(fp);
}
insert ffp;
}
}

  • January 18, 2013
  • Like
  • 0

Hi Everyone  

                    I'm writing a trigger on the Oppotunity object, which would capture the Opp Products into the Fullfillment Parts object (custom object).i have value1,value2 fields in opp product i need to copy these two fields into fullfillment part object on fullfillment object the value1 field should be readonly and value2 should be editable...how can i do this

  • January 17, 2013
  • Like
  • 0

Hi Everyone ,

 

             I want to a trigger on the Oppotunity object, which would capture the Opp Products into the Fullfillment Parts object (custom object). This should happen when the opp status is changed to "Approved"( custom field on opportunity) my custom object has a master detail relation with opportunity..help me in this regard..how i can proceed

  • January 16, 2013
  • Like
  • 0

Hi Everyone,

 

                       I have a custom object maildetails__c and it has the fields like Body__c,To__c,subject__c now i want to send an email to the mail id mentioned in the TO__c.i created i visualforce page with all these fields along with send button i have to send an email with body as Body__c, subject as Subject__c to To__c.any help would appreciated

  • January 08, 2013
  • Like
  • 0

Hi ,

 
I have a trigger  which updates  lead fields from event which is working fine.But whenever i'm working on Business Account records i'm getting an error like  
 
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []: Trigger.NewEventLeadUpdate: line 16, column 1
 
However it is working fine with person accounts as well.For opportunities also it is working fine with which are associated with person accounts only not with business accounts. 
 
Kindly let me know where i'm going wrong  any help greatly appreciated.
 
trigger NewEventLeadUpdate on Event (before insert, before update) {
 
 lead[] leads = new lead[ 0 ];
   
  for( event event : trigger.new ) {
   
 try{
    if( (lead.Next_Event__c == null && event.whoid != null)||(string.valueOf(event.StartDateTime) < string.valueOf(lead.Next_Event__c))){
     leads.add( new lead( id = event.whoid,Next_Event__c = event.StartDateTime ) );
    }
    }
    catch(exception e){
    // to capture the error during editing the event
    }
  }
  update leads; ///line 16, column 1
}
  • February 28, 2013
  • Like
  • 0

Hi Everyone.

 

When a Sales user from my production is viewing their Events on the calendar, it only links to the Account... is there a way to just have it link to the opportunity?

 

Anil

  • February 27, 2013
  • Like
  • 0

Hi,

 

We like to have a Custom Lead Accept button which would be used on the Search Results Page.

 

When the user selects the Leads and clicks the button, it should assign the Lead ownership to the Person who clicked the button.how i can achieve this any help appriciate greatly

  • February 08, 2013
  • Like
  • 0

I'm having issues writing a trigger that will insert a Contact record from information based on the Account.

 

Basically, if it's an account is inserted, I want it to create a Contact.  That part is easy.  The next part that I am having trouble writing is if the account is updated part.   If it's an update, I want it to look to see if there are any Contacts with the Contact_Type__c = General.  If not, then it needs to create a Contact like in the insert portion.  Thought it was simple enough but I can't get it work correctly.  I also need to make sure that this bulk safe since we load accounts nightly.

 

 

I marked the line it's failing on in red.

 

 

 

trigger CreateAccountContact on Account (after insert, after update){

    if(Trigger.isInsert){
    
        List<Contact> ct = new List <Contact>();
        
        for(Account acc : trigger.new){

        Contact c = new Contact(LastName = acc.name,
                        AccountId=acc.id,
                        Fax=acc.Fax,
                        MailingStreet=acc.BillingStreet,
                        MailingCity=acc.BillingCity,
                        MailingState=acc.BillingState,
                        MailingPostalCode=acc.BillingPostalCode,
                        MailingCountry=acc.BillingCountry,
                        Phone=acc.Phone);

        ct.add(c);
        
        }
        
        if(!ct.isEmpty())
            insert ct; 
    }
    
    else{
        
        List<contact> cntsload = new List <Contact>();
        
        for(Account acc : trigger.new){
                List<Contact> cnt = new List<Contact>([select id, Contact_Type__c from Contact where AccountId = acc.id and Contact_Type__c = 'General']);
        
        if(cnt.isEmpty()){

        Contact c = new Contact(LastName = acc.name,
                        AccountId=acc.id,
                        Fax=acc.Fax,
                        MailingStreet=acc.BillingStreet,
                        MailingCity=acc.BillingCity,
                        MailingState=acc.BillingState,
                        MailingPostalCode=acc.BillingPostalCode,
                        MailingCountry=acc.BillingCountry,
                        Phone=acc.Phone);

        cntsload.add(c);
        
        }
        }
        
        if(!cntsload.isEmpty())
            insert cntsload; 
    
    
    }
    
}

 

Hi Everyone ,

 

             I want to a trigger on the Oppotunity object, which would capture the Opp Products into the Fullfillment Parts object (custom object). This should happen when the opp status is changed to "Approved"( custom field on opportunity) my custom object has a master detail relation with opportunity..help me in this regard..how i can proceed

  • January 16, 2013
  • Like
  • 0