• Jvallee
  • NEWBIE
  • 0 Points
  • Member since 2008

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

I'm currently getting this error:

 

Severity and Description    Path    Resource    Location    Creation Time    Id
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityBeforeInsertBeforeUpdate: execution of BeforeInsert

caused by: System.StringException: Invalid id:

Trigger.OpportunityBeforeInsertBeforeUpdate: line 33, column 34        Production2    line 1    1241789768961    3500

 

 

I'm guessing that it is actually line 36 that is causing the error, but I'm not sure.  the code that is causing the problem starts on line 27 and end on 69.  In this code, we are trying to decide if anything has changed in fields Opp_Last_Result_Detail__c, Opp_Last_Result_Category__c, Notes_Update__c, which are custom.  And save this to a list in a helper class "WithinATrigger" to save for the Aftet Insert/Update trigger any ideas would be helpful.

 

 

 <CODE>

 

1  trigger OpportunityBeforeInsertBeforeUpdate on Opportunity (before insert, before update) {
2   
3     Opportunity savedOpp = null;
4     //List of Ids that should be updated.
5     List<ID> oppsToSaveNotes = new List<ID>();
6    
7     //Loop  through all Opportunities being inserted or updated.  
8      for( Opportunity currentOpp : Trigger.new){
9         
10           //set the Default Stage if none is set.
11          if( currentOpp.StageName == null ){
12              
13             currentOpp.StageName = 'New';    
14           }
15          
16           //Handle upload scenario
17           if( currentOpp.upload__c == true){
18             
19              //Set the already updated flag and clear upload
20              currentOpp.upload__c = false;
21             
22              //Set the value to show we started a trigger already
23            WithinATrigger.setAlreadyUpdatedOpportunity( true );
24                 
25           }
26          
27           if( currentOpp.upload__c == null ||
28               currentOpp.upload__c != true){
29             
30              //Save list of Opp Ids which the LR Category or LR Detail have changed.
31              //Get Saved version of
32              if( currentOpp != null &&
33                  currentOpp.Id != null ){
34                                                                 
35               //Get savedOpp the version current in the DB
36               savedOpp = [SELECT Opp_Last_Result_Detail__c, Opp_Last_Result_Category__c,             Notes_Update__c FROM Opportunity WHERE id = :currentOpp.Id LIMIT 1];

37
38              
39               //if we have found a saved version, we can compare.

40               if( savedOpp != null ){
41                  
42                      //If the Category or Id have Changed, add Id to list.
43                      if( (currentOpp.Opp_Last_Result_Category__c != null &&
44                           currentOpp.Opp_Last_Result_Detail__c != null &&
45                           savedOpp.Opp_Last_Result_Category__c != null &&
46                           savedOpp.Opp_Last_Result_Detail__c != null) &&
47                           currentOpp.Opp_Last_Result_Category__c != savedOpp.Opp_Last_Result_Category__c ||
48                        currentOpp.Opp_Last_Result_Detail__c != savedOpp.Opp_Last_Result_Detail__c){
49                  
50                          //Add current opp's id to the list
51                          oppsToSaveNotes.add(savedOpp.Id);
52                          
53                   }
54                     
55               }
56               else{ //Didn't find one, but we should write anyway.
57                  
58                  //Add current opp's id to the list
59                  if( currentOpp.Id != null){
60                     oppsToSaveNotes.add(currentOpp.Id);
61                  }
62               }
63            }
64            
65           
66            //Save list to helper class
67            if( !oppsToSaveNotes.isEmpty() ){
68               WithinATrigger.setIdsToUpdateNotes(oppsToSaveNotes);
69            }
70           }
71         
72      }
73    
74 }

 

</CODE>

 

 

 

 

I have been able to successfully able to get the zip file generated by the Metadata API's Retrieve() function, write it to a file and open with the Windows Zip Utility.  I need to parse the information contained within the Zip file. The only .NET 2.0 library that works with zip files is GZipStream, which unfortunately does not support zip archives which contain multiple files, or diectories.  Does anyone have any suggestion of a third party library that will solve this.  Or better yet something in .Net that I am missing.
I can't find a way to get a layout object back from the API.  I have been able to successfully create a page layout with the API, but I would like to read exisiting layouts to use for updates.  I have tried to use the Describe objects from the Data API, but they don't seem to have all of the information that I need to build a new layout.  I started with the DescribeLayoutResult object and drilled down to try to do a deep copy, but it's not a copy because the objects are so different, infact, I don't think that the Describe objects have all the information needed to create a new Object. Anyone know how to get a Layout object back from Salesforce?
I have been able to create a custom field through the Metadata API, which is great. But now to be able to use it, I need to be able to add it to all appropriate Page Layouts and Make it available in the WSDL.

So first question, how can I add a custom field to a Page Layout with the API?  I tried creating a Layout object (inherits from Metadata) and using the Metadata API call create to create the new object which causes a "Field Integrity Exception" with a message of  "Parent entity failed to deploy" so I think that I'm close, but the message doesn't really mean much to me.

Second, once I create a new field, I want to be able to query for it.  Is there a way to dynamically update the WDSL to reflect the new field?

I am working with the Metadata API, and am having trouble figuring out how to programmatically create a custom field to a standard object.  The only documentation that I have been able to find is:

http://www.salesforce.com/us/developer/docs/api_meta/index_Left.htm#StartTopic=Content/meta_listview.htm

The sample here is Java only and it has been a struggle to work with since the objects that I am working with are so different than the ones used in sample.  I want to add a custom field to the Lead standard object, but I'm not sure how to.

Based on the sample above, I believe I need to pass a complete object to the create function to get this to work, since if I pass just a custom field there is no property to associate the type that the field belongs to.  Therefore, I think that create will only work if I pass the standard object with the Custom Field.  Also, I'm not sure how to create an instance of a standard object with all of the properties populated.

Any help would be great.
I'm still new to this, so hopefully I am using the right terms:
 
I have created a Controller Extention as an Apex class that will in effect override the !save of the standard controller.  What I was hoping to do is save a field to a related object in this method, which I have been able to do, but I need to get the value that I will write from an <apex:inputField> page component.  Is this possible? I can't seem to find a way to reference these components in Apex.
Code:
public class LeadTouchExtension{

   public final Lead_Touch__c leadTouch;
                
   //Create a new save action
   ApexPages.Action saveAction = new ApexPages.Action('{!LeadTouchSave( string )}');
   
   public LeadTouchExtension ( ApexPages.StandardController stdController )
   {
      this.leadTouch = (Lead_Touch__c)stdController.getRecord();
   }
     
   public void LeadTouchSave()
   {
      try{
         
         for( Lead relatedLead : [Select ID, Salutation, FirstName, LastName FROM lead WHERE Lead.ID = :leadTouch.Lead__c LIMIT 1 ] )
         {
            //this needs to reference the Form and any pageBlock (maybe page block section) by name.                
            relatedLead.FirstName = ***Need to reference page component here!***  
         
            update relatedLead;
        
         }
      
      }
      catch( DmlException ex )
      {
         ApexPages.addMessages(ex);
      }

      
   }

}

 

I'm currently getting this error:

 

Severity and Description    Path    Resource    Location    Creation Time    Id
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityBeforeInsertBeforeUpdate: execution of BeforeInsert

caused by: System.StringException: Invalid id:

Trigger.OpportunityBeforeInsertBeforeUpdate: line 33, column 34        Production2    line 1    1241789768961    3500

 

 

I'm guessing that it is actually line 36 that is causing the error, but I'm not sure.  the code that is causing the problem starts on line 27 and end on 69.  In this code, we are trying to decide if anything has changed in fields Opp_Last_Result_Detail__c, Opp_Last_Result_Category__c, Notes_Update__c, which are custom.  And save this to a list in a helper class "WithinATrigger" to save for the Aftet Insert/Update trigger any ideas would be helpful.

 

 

 <CODE>

 

1  trigger OpportunityBeforeInsertBeforeUpdate on Opportunity (before insert, before update) {
2   
3     Opportunity savedOpp = null;
4     //List of Ids that should be updated.
5     List<ID> oppsToSaveNotes = new List<ID>();
6    
7     //Loop  through all Opportunities being inserted or updated.  
8      for( Opportunity currentOpp : Trigger.new){
9         
10           //set the Default Stage if none is set.
11          if( currentOpp.StageName == null ){
12              
13             currentOpp.StageName = 'New';    
14           }
15          
16           //Handle upload scenario
17           if( currentOpp.upload__c == true){
18             
19              //Set the already updated flag and clear upload
20              currentOpp.upload__c = false;
21             
22              //Set the value to show we started a trigger already
23            WithinATrigger.setAlreadyUpdatedOpportunity( true );
24                 
25           }
26          
27           if( currentOpp.upload__c == null ||
28               currentOpp.upload__c != true){
29             
30              //Save list of Opp Ids which the LR Category or LR Detail have changed.
31              //Get Saved version of
32              if( currentOpp != null &&
33                  currentOpp.Id != null ){
34                                                                 
35               //Get savedOpp the version current in the DB
36               savedOpp = [SELECT Opp_Last_Result_Detail__c, Opp_Last_Result_Category__c,             Notes_Update__c FROM Opportunity WHERE id = :currentOpp.Id LIMIT 1];

37
38              
39               //if we have found a saved version, we can compare.

40               if( savedOpp != null ){
41                  
42                      //If the Category or Id have Changed, add Id to list.
43                      if( (currentOpp.Opp_Last_Result_Category__c != null &&
44                           currentOpp.Opp_Last_Result_Detail__c != null &&
45                           savedOpp.Opp_Last_Result_Category__c != null &&
46                           savedOpp.Opp_Last_Result_Detail__c != null) &&
47                           currentOpp.Opp_Last_Result_Category__c != savedOpp.Opp_Last_Result_Category__c ||
48                        currentOpp.Opp_Last_Result_Detail__c != savedOpp.Opp_Last_Result_Detail__c){
49                  
50                          //Add current opp's id to the list
51                          oppsToSaveNotes.add(savedOpp.Id);
52                          
53                   }
54                     
55               }
56               else{ //Didn't find one, but we should write anyway.
57                  
58                  //Add current opp's id to the list
59                  if( currentOpp.Id != null){
60                     oppsToSaveNotes.add(currentOpp.Id);
61                  }
62               }
63            }
64            
65           
66            //Save list to helper class
67            if( !oppsToSaveNotes.isEmpty() ){
68               WithinATrigger.setIdsToUpdateNotes(oppsToSaveNotes);
69            }
70           }
71         
72      }
73    
74 }

 

</CODE>

 

 

 

 

I can't find a way to get a layout object back from the API.  I have been able to successfully create a page layout with the API, but I would like to read exisiting layouts to use for updates.  I have tried to use the Describe objects from the Data API, but they don't seem to have all of the information that I need to build a new layout.  I started with the DescribeLayoutResult object and drilled down to try to do a deep copy, but it's not a copy because the objects are so different, infact, I don't think that the Describe objects have all the information needed to create a new Object. Anyone know how to get a Layout object back from Salesforce?
I have been able to create a custom field through the Metadata API, which is great. But now to be able to use it, I need to be able to add it to all appropriate Page Layouts and Make it available in the WSDL.

So first question, how can I add a custom field to a Page Layout with the API?  I tried creating a Layout object (inherits from Metadata) and using the Metadata API call create to create the new object which causes a "Field Integrity Exception" with a message of  "Parent entity failed to deploy" so I think that I'm close, but the message doesn't really mean much to me.

Second, once I create a new field, I want to be able to query for it.  Is there a way to dynamically update the WDSL to reflect the new field?

I am working with the Metadata API, and am having trouble figuring out how to programmatically create a custom field to a standard object.  The only documentation that I have been able to find is:

http://www.salesforce.com/us/developer/docs/api_meta/index_Left.htm#StartTopic=Content/meta_listview.htm

The sample here is Java only and it has been a struggle to work with since the objects that I am working with are so different than the ones used in sample.  I want to add a custom field to the Lead standard object, but I'm not sure how to.

Based on the sample above, I believe I need to pass a complete object to the create function to get this to work, since if I pass just a custom field there is no property to associate the type that the field belongs to.  Therefore, I think that create will only work if I pass the standard object with the Custom Field.  Also, I'm not sure how to create an instance of a standard object with all of the properties populated.

Any help would be great.
How to Add custom field from Accounts custom field & Relation to Accounts layout page using web service API?? 

          It's Urgent.....


Thanks.




  • October 20, 2008
  • Like
  • 0
I'm still new to this, so hopefully I am using the right terms:
 
I have created a Controller Extention as an Apex class that will in effect override the !save of the standard controller.  What I was hoping to do is save a field to a related object in this method, which I have been able to do, but I need to get the value that I will write from an <apex:inputField> page component.  Is this possible? I can't seem to find a way to reference these components in Apex.
Code:
public class LeadTouchExtension{

   public final Lead_Touch__c leadTouch;
                
   //Create a new save action
   ApexPages.Action saveAction = new ApexPages.Action('{!LeadTouchSave( string )}');
   
   public LeadTouchExtension ( ApexPages.StandardController stdController )
   {
      this.leadTouch = (Lead_Touch__c)stdController.getRecord();
   }
     
   public void LeadTouchSave()
   {
      try{
         
         for( Lead relatedLead : [Select ID, Salutation, FirstName, LastName FROM lead WHERE Lead.ID = :leadTouch.Lead__c LIMIT 1 ] )
         {
            //this needs to reference the Form and any pageBlock (maybe page block section) by name.                
            relatedLead.FirstName = ***Need to reference page component here!***  
         
            update relatedLead;
        
         }
      
      }
      catch( DmlException ex )
      {
         ApexPages.addMessages(ex);
      }

      
   }

}

 
Hello-

Is there a way to create a custom object that would show up on the leads tab, and then when the lead is converted the information would transfer over to the Account/Contact record?

We track a substantial amount of marketing information pertained to each lead/contact account ranging from resource material, referal program, book purchases etc.  We currently are tracking this stuff in Activity/History, but this information is so specific and crticial to our organization that I would like to pull it out of the mass of information tracked in Activity/History and have a specific area where marketing activies are tracked.  My thought was to create a custom object for this type of material but have noticed that a related list custom object is not available in the Lead Page Format View.

If this isnt possible, does anyone have any suggestions for tracking this type of information some where else other than Acitivy History?

Thanks,
  • September 26, 2008
  • Like
  • 0