• CoolSuren
  • NEWBIE
  • 55 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 12
    Replies

Hi Everyone, I was hoping I could get some insights as to what might be wrong with my trigger.  I have the following trigger I would like to run when a lead status within the lead is changed to a particular value.  When the value is changed, I would like to create a new activity on the lead record.  

 

Here is my code below, and the error I get back is:

 

Error: Compile Error: No access to entity: Activity at line 1 column 1

 

Any help would be greatly appreciated!

 

 

trigger createLeadActivity on Lead (after update) { 

    //make a set to hold opportunity ids that we need
    Set<Id> leadIds = new Set<Id>();
    
    for(Lead l : trigger.new)
        {
        //check to see if our field has been changed
        if(l.status != trigger.oldMap.get(l.Id).Status){
            
            leadIds.add(l.Id);
            
        }

       }
    
    if(!leadIds.isEmpty()){
        
       
        
        List<Lead> leadList = 
            [SELECT Id,Status
            FROM Lead
            WHERE Status = '4 - SAL Engaged' AND Id IN :leadIds ];
        
        
        
        for(Lead leadly: leadList){
        Lead led = new Activity();
        
       
        
        
       
        Activity newActivity = new Activity(Subject='LeadPassed',OwnerId=leadMap.get( record.WhoId ).OwnerId,Status='Not Started',Priority='Normal',WhoId=leadMap.get( record.WhoId ).id);

        ActList.add(newActivity);
        }
       
    }


}

 

Hey there,

 

I have this trigger, except it will not let me deploy it via changesets without testing the code coverage. I need to test for this, I was wondering if someone could help me out with some code in order to test the trigger?

 

The trigger is written as:

 

trigger ConvertLead on Lead (after insert, after update) {
    for (Lead lead : Trigger.new) {
      if (lead.isConverted == false) //to prevent recursion
      {
      
        Database.LeadConvert lc = new Database.LeadConvert();
        lc.setLeadId(lead.Id);
      
        String oppName =  lead.Name;
        lc.setOpportunityName(oppName);
      
        LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
        lc.setConvertedStatus(convertStatus.MasterLabel);
      
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        System.assert(lcr.isSuccess());
      
            
    }
  }
}

 

How would I also go about removing the creation of an opportunity? Do i just remove the section that goes:

 

      
        String oppName =  lead.Name;
        lc.setOpportunityName(oppName);

 

Any help I can get would be very much appreciated.

 

Mikie

 

Hi All,

 

 I am trying to integrate salesforce with OTRS(open source ticket request system) system. if any one have a idea in this, please give me a procedure. its urgent task. 

 
 
 
 
Suren k
Orbit Innovations pvt ltd

Hi All,

 

 I am trying to integrate salesforce with OTRS(open source ticket request system) system. if any one have a idea in this, please give me a procedure. its urgent task. 

Suren k
Orbit Innovations pvt ltd

Hi All,

 

 I am trying to integrate salesforce with OTRS(open source ticket request system) system. if any one have a idea in this, please give me a procedure. its urgent task. 

Hi All,

 

 I am trying to integrate salesforce with OTRS(open source ticket request system) system. if any one have a idea in this, please give me a procedure. its urgent task. 

Suren k
Orbit Innovations pvt ltd


Hi,

I am new to apex.  

I am trying to perform upsert operation using an external id
What changes should i make in below code, so that the following error will be resolved.
Error: "Upsert with a field specification requires a concrete SObject type"


List<SObject> accstoupload;
accstoupload = new List<SObject>();


 //Code to fetch external_id Field names for the Selected object
 Schema.SObjectType targetType = Schema.getGlobalDescribe().get(selectedValue); //Selected value is the object name selected from picklist
 Map<String, Schema.SObjectField> M = targetType.getDescribe().fields.getMap();
       
         for (String k : M.keySet())
          {
          if(M.get(k).getDescribe().isExternalID())
           {
            externalIdFields.add(k);
            
           }
            }
         
     // code to upsert
                      
        for( Integer j = 0; j < externalIdFields.size(); j++) {
          
         
 try{
        upsert accstoupload externalIdFields; // Getting error on this line
        }
catch (Exception e)
       {
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured. Please check the template or try again later');
           ApexPages.addMessage(errormsg);
        }     
         }

Please help.

  • July 03, 2013
  • Like
  • 0

Hi Everyone, I was hoping I could get some insights as to what might be wrong with my trigger.  I have the following trigger I would like to run when a lead status within the lead is changed to a particular value.  When the value is changed, I would like to create a new activity on the lead record.  

 

Here is my code below, and the error I get back is:

 

Error: Compile Error: No access to entity: Activity at line 1 column 1

 

Any help would be greatly appreciated!

 

 

trigger createLeadActivity on Lead (after update) { 

    //make a set to hold opportunity ids that we need
    Set<Id> leadIds = new Set<Id>();
    
    for(Lead l : trigger.new)
        {
        //check to see if our field has been changed
        if(l.status != trigger.oldMap.get(l.Id).Status){
            
            leadIds.add(l.Id);
            
        }

       }
    
    if(!leadIds.isEmpty()){
        
       
        
        List<Lead> leadList = 
            [SELECT Id,Status
            FROM Lead
            WHERE Status = '4 - SAL Engaged' AND Id IN :leadIds ];
        
        
        
        for(Lead leadly: leadList){
        Lead led = new Activity();
        
       
        
        
       
        Activity newActivity = new Activity(Subject='LeadPassed',OwnerId=leadMap.get( record.WhoId ).OwnerId,Status='Not Started',Priority='Normal',WhoId=leadMap.get( record.WhoId ).id);

        ActList.add(newActivity);
        }
       
    }


}

 

Hi,

 

 

I have a static resource with image. I am trying to display one email template with this static resource image. But i am unable to get the image in to my inbox. Please help me out how to solve this.

 

 

Thanks,

Laskhmi

I have custom objects A,B,C,D which has look up relation in another object E. Now I want to create one VF page in which all all the fields of each object will come and on click of save all record will be saved. Means on one VF page I wnt to save multiple objects record. I know that I need to create the controller. Please explain in detail with code.

 

regards

Raman

Hello,

 

I am trying to write the test class for my trigger. But I can't get further then 60%. 

Can someone help me with this?

 

trigger updateAcct onEvent (afterupdate) {

   

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

for(Event e: [SELECT Subject,WhatId, Sales_Reps__c FROM EVENT WHERE ID IN:trigger.new]){

String wId = e.WhatId;

if(wId!=null && wId.startsWith('001') && !acctIds.contains(e.WhatId) && e.Sales_Reps__c == '1-5'){

acctIds.add(e.WhatId);   

}     

}

    for(Account a:[SELECT Sales_Reps__c FROM Account WHERE ID IN:acctIds]){

                 a.Sales_Reps__c = '1-5';

        update a;  

    }        

}    

 

Test class:

public class TestClass {

 

    static testMethod void myUnitTest() {

        //Create new Account

        Account acc = new Account(Name ='test');

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

            insert acc;

 

        // Create new Event with fiction data

        Event c = new Event(WhatId=acc.ID, Subject='test',Sales_Reps__c='1-5',durationinminutes = 1440,isalldayevent = true,activitydate = System.today());

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

        String wId = c.WhatId;

            if(c.Update_Event__c ==true){

    acctIds.add(c.WhatId);

}

insert c;

        Test.startTest();

        try {

        Account a = [SELECT Name, Sales_Reps__c,Sales_LY__c, Description FROM Account WHERE ID =:acc.Id];

        a.Name='test';

        a.Sales_Reps__c ='1-5';

        a.Sales_LY__c = '1.750.000 - 2.000.000';

        a.Description='test';

        update a;

}

 

 catch (System.DmlException e) {

    System.debug('Event record could not be updated.');

    

    }

        Test.stopTest();   

    }

}

 

Looking forward to the answer!

 

Kind regards,

I am trying to build a simple VF page to allow users to maintain ForecastingQuota in the UI when using  Collaborative Forecasting (similar to how it is done in Customizable Forecasting).

 

My page allows me to select a Forecasting enabled user, view their quotas and a form allows me to update QuotaAmount or QuotaQuantity and StartDate for that user

 

When trying to save the record, however, I get the following error:

 

  • Quota Month: Required quota field missing

I have a separate VF page to allow me to insert ForecastingQuotas and this is working fine

 

Any ideas why this is so?

  • July 02, 2013
  • Like
  • 0

Hi there,

 

what can be changed in this to avoid 'Too many SOQL queries: 101' issue?

 

thanks

Manohar

 

 

trigger UpdateApprovalPercentForRest on Opportunity (after delete, after undelete, after update) {

    List<Opportunity> buildsToUpdate = new List<Opportunity>{};

    for( Opportunity parent: Trigger.new)
    {                                                    
        List<Opportunity> restBuildswiththePartner =[SELECT Partner_Cap_Reached__c , Build_Partner__c,Construction_Approval_Payment__c,
                                                                StageName,Substantial_Completion_Payment__c 
                                                                FROM Opportunity WHERE Build_Partner_ID__c = :parent.Build_Partner_ID__c AND 
                                                                StageName NOT IN ('Construction Approved', 'Substantial Completion Pending Approval',
                                                                    'Substantial Completion', 'Final Completion Pending Approval', 
                                                                    'Final Completion', 'Cancelled - Customer', 'Cancelled - SCF') ];
 
        for(Opportunity o : restBuildswiththePartner){
            if (o.Partner_Cap_Reached__c == true && (o.Construction_Approval_Payment__c != 0.00 && o.Substantial_Completion_Payment__c != 0.80 ) && (o.StageName != 'Construction Approved' && o.StageName != 'Substantial Completion Pending Approval' && o.StageName != 'Substantial Completion' && o.StageName != 'Final Completion Pending Approval' && o.StageName != 'Final Completion' && o.StageName != 'Cancelled - Customer' && o.StageName != 'Cancelled - SCF')) {
                  o.Construction_Approval_Payment__c = 0.00;
                  o.Substantial_Completion_Payment__c = 0.80;
                  o.Final_Completion_Payment__c = 0.20;
                  buildsToUpdate.add(o);
            }
        
            if (o.Partner_Cap_Reached__c == false && (o.Construction_Approval_Payment__c != 0.40 && o.Substantial_Completion_Payment__c != 0.40 ) && (o.StageName != 'Construction Approved' && o.StageName != 'Substantial Completion Pending Approval' && o.StageName != 'Substantial Completion' && o.StageName != 'Final Completion Pending Approval' && o.StageName != 'Final Completion' && o.StageName != 'Cancelled - Customer' && o.StageName != 'Cancelled - SCF')) {
                  o.Construction_Approval_Payment__c = 0.40;
                  o.Substantial_Completion_Payment__c = 0.40;
                  o.Final_Completion_Payment__c = 0.20;
                  buildsToUpdate.add(o);
            }
        }
    
        if (!buildsToUpdate.isEmpty()){
            update buildsToUpdate;
        }                                                                                                                    
   }
}

 

 

 

Hi I am facing trouble to set values in wrapper class.. I don't know what is happening.. or what I am missing that its not setting the values.. Ny help!!

Hey there,

 

I have this trigger, except it will not let me deploy it via changesets without testing the code coverage. I need to test for this, I was wondering if someone could help me out with some code in order to test the trigger?

 

The trigger is written as:

 

trigger ConvertLead on Lead (after insert, after update) {
    for (Lead lead : Trigger.new) {
      if (lead.isConverted == false) //to prevent recursion
      {
      
        Database.LeadConvert lc = new Database.LeadConvert();
        lc.setLeadId(lead.Id);
      
        String oppName =  lead.Name;
        lc.setOpportunityName(oppName);
      
        LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
        lc.setConvertedStatus(convertStatus.MasterLabel);
      
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        System.assert(lcr.isSuccess());
      
            
    }
  }
}

 

How would I also go about removing the creation of an opportunity? Do i just remove the section that goes:

 

      
        String oppName =  lead.Name;
        lc.setOpportunityName(oppName);

 

Any help I can get would be very much appreciated.

 

Mikie

 

 how to get Application name using Apex?

 

Regards,

Magulan D

Quick (hopefully) question. I need to add a specific user to a public group. Ids for both are listed within an object called Fund Document Entitlments, so all I have to do is use those two ids, but I'm not sure how. Here's my code so far:

 

 

public static void AddUserToPublicGroup(List<Fund_Document_Entitlement__c> items){
	Set<Id> portalIds = new Set<Id>();
	Set<Id> publicGroupIds = new Set<Id>();
	for(Fund_Document_Entitlement__c fde : items){
		portalIds.add(fde.Customer_Portal_User_ID__c);
		publicGroupIds.add(fde.Public_Group_ID__c);
	}
		
	List<Group> pgList = [select Id from Group where Id in: publicGroupIds];
	List<User> uList = [select Id from User where Id in: portalIds];
		
	for(Fund_Document_Entitlement__c fde : items){
		for(Group pgroup : pgList){
			for(User u : uList){
				if(fde.Customer_Portal_User_ID__c == u.Id && fde.Public_Group_ID__c == pgroup.Id){
					//what do I put here
				}
			}
		}
	}
}

 Somehow I need to say "add the user with user Id u.Id into group pgroup.Id. How do I do that? Thanks!

 

  • April 07, 2010
  • Like
  • 0