• Shadow8002
  • NEWBIE
  • 50 Points
  • Member since 2008

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

hi people,

 

i have a case. in that case there is a related list 'Activity History'.....

in that related list the activities are saved as tasks...i need to parse the task for getting things written in the 'body' field(in that task)..and take these entries and use it in the controller of the close case.

does any of you have any idea how to do this..

 

thanks in advance...

 

 

Todd

Hi,

I have a requirement where i need to issue more then 100 DML statements in a trigger. But as per the trigger governor limits only 100 DML statements are allowed.

I also tried calling the trigger recursively, i.e. issuing 90 DML statements in a trigger and updating the record again, so that the trigger executes again on that record issuing another 90 DML statements until the processing completes.

But i noticed that calling the trigger recursively uses the same context and the DML statements keeps on adding to the same context.

Is there any other workaround for this where i can process more then 100 records.

GreatG
  • November 16, 2008
  • Like
  • 0
There is a lot of excitement around the launch of the newly announced 'SalesForce Sites'. The main power of Visual Force (which is the primary UI for sites) is the custom Apex controllers and extensions we write. Being in a multi-tenant environment, I am not sure how SalesForce would allow Apex to be attached to the VisualForce pages that are published as Sites.

Can you have custom Apex controllers for VisualForce pages published as Sites? Does anyone have more information on this??

Thanks.
Hi All,

I am using :
tabstyle="Member_Value_Plan__c" title="Member Value Plan"
sidebar="false" showHeader="false" standardStylesheets="true"
contenttype="application/msword" cache="true">


I have used the following formats:
contenttype="application/msword"
contenttype="application/rtf",
contenttype="application/vnd.openxmlformats-officedocument.wordprocessingml.document"



Actually, everything is fine if the file can be opened or saved in the doc format not into the web format.

In 2003, the page contents displays as in the HTML format like everything comes into the table format.

If I open the file and try to save it this file by default saved in web format,
But if I choose ms word format (Word 97 – 2003 Document) from the Save as Type list than
the new file gets open in correct ms-word format without showing contents into the table.


Any suggestions please.


Thanks,
Nitin Gupta
Message Edited by NT on 05-13-2009 07:44 AM
  • May 13, 2009
  • Like
  • 0

hi people,

 

i have a case. in that case there is a related list 'Activity History'.....

in that related list the activities are saved as tasks...i need to parse the task for getting things written in the 'body' field(in that task)..and take these entries and use it in the controller of the close case.

does any of you have any idea how to do this..

 

thanks in advance...

 

 

Todd

I have a trigger that calls a class which establishes record sharing for an object based on the record owner and their role. Essentially I am sharing the record with the owner's role. The org has entirely too many roles that will quickly exceed the number of predefined sharing rules that can be established so this trigger/class solution is necessary across a number of private objects to ensure members of the same role share the same access to records anyone in the same role owns.

My challenge comes in establishing the data set needed to create the sharing in the custom object's sharing object (in this case Team__Share). Specifically, because I am sharing with a Role I need to first grab the record owner, determine their role, and then query the Group object to get the Group Id to pass back into the Team__Share object to set the UserOrGroupId (using the Role Id to set UserOrGroupId causes an error as it is looking for either a User Id or Group Id).

Here is my code for both the trigger and the class with the SOQL that is generating the governor limit execution error commented. This works like a charm if it is just one record being updated/inserted, but obviously fails once testing with larger sets of data.
Code:
trigger TeamSharingTrigger on Team__c (after insert, after update) {
 
 List<ID> ownerId = new List<ID>();
 
 for (Team__c teamNew1: Trigger.New){
  ownerId.add(teamNew1.OwnerId);
 }
 
 Map<ID,User> u = new Map<ID,User>([Select Id, UserRoleId From User where Id in :ownerId]);
 
 ID roleId;
 for (Team__c teamNew2: Trigger.New){
  roleId = u.get(teamNew2.OwnerId).UserRoleId;
  if(roleid != null){
   TeamSharingClass.manualShareAll(teamNew2.Id,roleId);
  }
 }
 
}





public class TeamSharingClass {
 
 public static boolean manualShareAll(Id recordId, Id userOrGroupId){

   /*Since this is a Role and not a User that I am trying to share with I 
     need to grab the Id of the Group for that role.
     This is the SOQL that causes the governor limits (executed for each call)*/
      ID groupID = [Select g.Id From Group g where g.RelatedId=:userOrGroupId and g.Type='Role'].Id;
      
      Team__Share teamShr = new Team__Share();
   teamShr.ParentId = recordId;
   teamShr.UserOrGroupId = groupID;
   teamShr.AccessLevel = 'Edit';
   teamShr.RowCause = Schema.Team__Share.RowCause.Manual;
   Database.SaveResult sr = Database.insert(teamShr,false);
         
      // Process the save results.
      if(sr.isSuccess()){
         // Indicates success
         return true;
      }
      else {
         // Get first save result error.
         Database.Error err = sr.getErrors()[0];
         
         // These sharing records are not required and thus an insert exception is acceptable. 
         if(err.getStatusCode() == StatusCode.FIELD_INTEGRITY_EXCEPTION  &&  
                  err.getMessage().contains('AccessLevel')){
            // Indicates success.
            return true;
         }
         else{
            // Indicates failure.
            return false;
         }
       }
   }
   
}

 



Any help/idea will be more than appreciated! I have a trigger that inserts a new opportunity record once stage is set to closedwon, it works fine until i try to set the newly inserted record to closewon. I get the following error message
 
System.NullPointerException: Attempt to de-reference a null object: Trigger.RenewalOpportunity: line 9, column 48
 
contract_length__c is a number field while contract_activation_date is a date field. below is the code I have so far
 
Trigger
Code:
trigger RenewalOpportunity on Opportunity (after update) {
                        
    for (Integer i = 0; i < Trigger.new.size(); i++) {
               
       if (Trigger.new[i].isWon == true && Trigger.old[i].isWon == false && Trigger.new[i].RenewalOpportunity__c == null) {
            
            Opportunity renewalOpp = Trigger.new[i].clone(false);

            Double x = Trigger.old[i].Contract_Length__c;
            Integer y = x.intValue();
            
            renewalOpp.Name = 'Renewal - '+  Trigger.old[i].Name;
            renewalOpp.closedate = Trigger.old[i].Contract_Activation_Date__c.addmonths(y);
            renewalOpp.stagename = '0 - Very Early Stage';
            renewalOpp.probability = 0;
            renewalOpp.ForecastCategoryName = 'Pipeline';
            renewalOpp.Contract_Activation_Date__c = null;
            renewalOpp.Contract_Length__c = null;


            insert renewalOpp;
            
      if (Trigger.old[i].Name.startsWith('Renewal - ')) {
          renewalOpp.Name = Trigger.old[i].Name;
          update renewalOpp;
          }

      if (Trigger.new[i].isWon == true && Trigger.old[i].isWon == false && Trigger.new[i].RenewalOpportunity__c == null) {
            Opportunity newOpp = [select ID from Opportunity where id = :Trigger.new[i].ID];
            newOpp.RenewalOpportunity__c = renewalOpp.ID;
            update newOpp;
            }            
      }
   }
}

 
Unit Test
 
Code:
public class CreateOpportunity {

    static testMethod void testCreateOpportunityRenewal(){
    // Test opportunities moving from isWon = false to isWon = true
    try {
        
        Double Contract_Length = 13;
        Double x = Contract_Length;
        Integer y = x.intValue();
        
        Date today = System.today();
        Date contract_activation_date = System.today();
        Date closeDate = contract_activation_date.addmonths(y);
                 
        Opportunity opportunity = new Opportunity();
        
        opportunity.name = 'old opportunity name';
        opportunity.Contract_Length__c = 13;
        opportunity.contract_activation_date__c = today;
        opportunity.closedate = today;
        opportunity.stagename = 'Closed Lost';
        opportunity.probability = 1;
        opportunity.ForecastCategoryName = 'Closed';
                
        insert opportunity;
        
        System.assertEquals(opportunity.name, 'old opportunity name');

        opportunity.stagename = 'Closed Won';
        update opportunity;
        
        Opportunity updatedOpportunity = [select ID,RenewalOpportunity__c from Opportunity where id = :opportunity.ID];
        
        // go get new opportunity
        System.debug('opportunityId: ' + updatedOpportunity.RenewalOpportunity__c);
        Opportunity newOpportunity = [select ID, Name, Contract_Length__c, contract_activation_date__c, closedate, stagename, probability, forecastCategoryName from Opportunity where id = :updatedOpportunity.RenewalOpportunity__c];
        
        System.assertNotEquals(newOpportunity, null);
        
        System.assertEquals(newOpportunity.name, 'Renewal - old opportunity name');
        System.assertEquals(newOpportunity.Contract_Length__c, 12);        
        System.assertEquals(newOpportunity.contract_activation_date__c, today);
        System.assertEquals(newOpportunity.closedate, closeDate);
        System.assertEquals(newOpportunity.stagename, '0 - Very Early Stage');
        System.assertEquals(newOpportunity.probability, 0);
        System.assertEquals(newOpportunity.ForecastCategoryName, 'Pipeline');
        
        delete opportunity;
    }    
    catch (DmlException e) {
        System.assert(false);
    }

    // Test opportunities moving from isWon = false to isWon = false
    try {

        Double Contract_Length = 13;
        Double x = Contract_Length;
        Integer y = x.intValue();
        
        Date today = System.today();
        Date contract_activation_date = System.today();
        Date closeDate = contract_activation_date.addmonths(y);
            
        Opportunity opportunity = new Opportunity();
        opportunity.Contract_Length__c = 13;
        opportunity.contract_activation_date__c = today;
        opportunity.name = 'old opportunity name';
        opportunity.closedate = today;
        opportunity.stagename = 'Closed Lost';
        opportunity.probability = 1;
        opportunity.ForecastCategoryName = 'Closed';

        insert opportunity;
        
        System.assertEquals(opportunity.name, 'old opportunity name');
        
        opportunity.stagename = 'Final Steps';
        update opportunity;
        
        Opportunity updatedOpportunity = [select ID,RenewalOpportunity__c from Opportunity where id = :opportunity.ID];
        try
        {
            Opportunity newOpportunity = [select ID from Opportunity where id = :updatedOpportunity.RenewalOpportunity__c];
            System.assert(false);
        }
        catch (Exception e) {
        }
    
        delete opportunity;
    }    
    catch (DmlException e) {
        System.assert(false);
    }
  }
}

 
Thanks in adavance :)
I want to write a trigger that will auto populate a date field when another date field from another object is filled in.  One field is from a custom object the other from a standard Contract object. The account name that is attached to both objects has to match so that the correct date is passed into the field that I have created.
 
So, I want to take a date from the contract object and put it in a field in the custom object, where their accounts match. There is a little hiccup in this that I do not know how to handle. in the standard Contract object the Account field is a standard lookup field. But in the custom object the the Account Name field is a custom field that has a master detail relationship to Account. - how do I deal with that? I just want to make sure that the accounts being referenced in the two different objects are the same Account.
 
Does anyone have an idea of how to start this trigger? or even pseudo code would be helpful because I cannot wrap my head around this right now.
  • November 20, 2008
  • Like
  • 0
I have a trigger set up on an object to trigger after an update.  If I do the update manually it works just fine.  However, if I do a mass update using the Data Loader the trigger doesn't get invoked.
 
Is there a way to force the trigger while using the Apex Data Loader?
  • November 18, 2008
  • Like
  • 0
Hi,

I have a requirement where i need to issue more then 100 DML statements in a trigger. But as per the trigger governor limits only 100 DML statements are allowed.

I also tried calling the trigger recursively, i.e. issuing 90 DML statements in a trigger and updating the record again, so that the trigger executes again on that record issuing another 90 DML statements until the processing completes.

But i noticed that calling the trigger recursively uses the same context and the DML statements keeps on adding to the same context.

Is there any other workaround for this where i can process more then 100 records.

GreatG
  • November 16, 2008
  • Like
  • 0