• mikeegar
  • NEWBIE
  • 0 Points
  • Member since 2007

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

Hi Folks,

It should be possible to default the related object and recipient fields using email URL parameters e.g. open up the standard email page with an email template using merge fields from a custom object and a lead as a recipient. This does not appear to work. It does work for contacts however.

With a custom object and a lead recipient, this does not work:
https://na15.salesforce.com/_ui/core/email/author/EmailAuthor?p3_lkid=<Custom ObjectId>&p2_lkid=<Lead Id>&rtype=00Q

Using the same syntax and a contact recipient, this does work:
https://na15.salesforce.com/_ui/core/email/author/EmailAuthor?p3_lkid=<Custom ObjectId>&p2_lkid=<Contact Id>&rtype=003

Is this a known bug?

 

I know there are a million posts about email URL hacking out there. I've read most of them at this point.

Thanks,
Mike

 

Excellent experience developing apex, visualforce, triggers and customizing the application. Have worked with major Salesforce clients and many complex projects.

 

Please reply to this post for more information.

Hi,
    I have a trigger that converts a lead to an opportunity when the owner is set to a specific queue. When I test it out, everything appears to go fine.  I get the page saying that the lead has been converted and has a link to the old lead. If I go to the lead however, it isn't converted. The opportunity isn't created either. According to the logs, the call is successfull and the opportunity is created. The id of the opportunity in the logs is not valid when I try to query for it.
 
I don't see any errors or anything to indicate the operation got rolledback somehow?
 
I have tried changing the 'Enforce Validation and Triggers from Lead Convert' setting for Leads but it doesn't seem to make any difference.
 
Thanks,
Mike
 
The logs are below. The result of the conversion is can be seen by searching for 'Database.LeadConvertResult'
 
*** Beginning LeadAutoConversion on Lead trigger event AfterUpdate for 00Q3000000LS5eX

20080929214915.307:Class.Config.getInstance: line 46, column 22:     returning from end of method Config<Constructor>() in 0 ms
20080929214915.307:Class.Config.initialize: line 59, column 24: SOQL query with 1 row finished in 4 ms
20080929214915.307:Class.Config.initialize: line 66, column 27: SOQL query with 1 row finished in 32 ms
20080929214915.307:Class.Config.getInstance: line 47, column 9:     returning from end of method private void initialize() in 37 ms
20080929214915.307:Trigger.LeadAutoConversion: line 4, column 18:     returning Config from method public static Config getInstance() in 37 ms
20080929214915.307:Trigger.LeadAutoConversion: line 5, column 19:     returning String from method public String getAutoConversionQueue() in 3 ms
20080929214915.307:Trigger.LeadAutoConversion: line 6, column 43:     returning String from method public String getAutoConversionQueue() in 1 ms
20080929214915.307:Trigger.LeadAutoConversion: line 6, column 5: AutoConversionQueue:00G30000001H1R2EAK
20080929214915.307:Trigger.LeadAutoConversion: line 12, column 9: SelectLoop:LIST:SOBJECT:Lead
20080929214915.307:Trigger.LeadAutoConversion: line 13, column 13: l.ownerId: 00G30000001H1R2EAK
20080929214915.307:Class.LeadAutoConversion: line 13, column 34:     returning Config from method public static Config getInstance() in 0 ms
20080929214915.307:Class.LeadAutoConversion.<init>: line 26, column 5: SelectLoop:LIST:SOBJECT:Lead
20080929214915.307:Class.LeadAutoConversion.<init>: line 35, column 9: SelectLoop:LIST:SOBJECT:Lead
20080929214915.307:Class.PartnerUsers.<init>: line 14, column 9: SelectLoop:LIST:SOBJECT:User
20080929214915.307:Class.PartnerUsers.<init>: line 14, column 23: SOQL query with 0 rows finished in 7 ms
20080929214915.307:Class.LeadAutoConversion.<init>: line 39, column 22:     returning from end of method public PartnerUsers<Constructor>(SET:Id) in 7 ms
20080929214915.307:Class.LeadAutoConversion.<init>: line 40, column 42:     returning SET:Id from method public SET:Id getPartners() in 0 ms
20080929214915.307:Class.LeadAutoConversion.<init>: line 40, column 81:     returning SET:Id from method public SET:Id getPartners() in 0 ms
20080929214915.307:Class.LeadAutoConversion.<init>: line 40, column 5: m_partnerUsers/CAMs{} / {}
20080929214915.307:Trigger.LeadAutoConversion: line 27, column 38:     returning from end of method public LeadAutoConversion<Constructor>(MAP:Id,SOBJECT:Lead, MAP:Id,SOBJECT:Lead) in 8 ms
20080929214915.307:Class.LeadAutoConversion.process: line 50, column 31:     returning String from method public String getPartnerTeamMemberAccess() in 3 ms
20080929214915.307:Class.LeadAutoConversion.process: line 51, column 31:     returning String from method public String getPartnerTeamMemberRole() in 3 ms
20080929214915.307:Class.LeadAutoConversion.process: line 52, column 31:     returning Integer from method public Integer getAssignmentMode() in 4 ms
20080929214915.307:Class.LeadAutoConversion.process: line 54, column 5: assgnMode--------4
20080929214915.307:Class.LeadAutoConversion.process: line 55, column 5: m_Leads--------{00Q3000000LS5eXEAT=Lead:{Status=Open - Not Contacted, SystemModstamp=2008-09-29 21:49:15, LastModifiedByID=00530000001UByQ, IsUnreadByOwner=true, OwnerId=00G30000001H1R2EAK, LastModifiedById=00530000001UByQAAW, LastTransferDate=2008-09-29 00:00:00, IsDeleted=false, CreatedDate=2008-09-29 20:59:55, HasOptedOutOfEmail=false, LastModifiedDate=2008-09-29 21:49:15, DoNotCall=false, HasOptedOutOfFax=false, IsConverted=false, RecordTypeId=0123000000024l4AAA, CreatedByID=00530000001UByQ, Company=test, Id=00Q3000000LS5eXEAT, LastName=test, CreatedById=00530000001UByQAAW}}
20080929214915.307:Class.LeadAutoConversion.getMatches: line 169, column 5: SelectLoop:LIST:SOBJECT:Lead
20080929214915.307:Class.LeadAutoConversion.getMatches: line 175, column 5: SelectLoop:LIST:SOBJECT:Contact
20080929214915.307:Class.LeadAutoConversion.getMatches: line 175, column 22: SOQL query with 0 rows finished in 3 ms
20080929214915.307:Class.LeadAutoConversion.process: line 59, column 39:     returning MAP:String,SOBJECT:Contact from method private static MAP:String,SOBJECT:Contact getMatches(LIST:SOBJECT:Lead) in 5 ms
20080929214915.307:Class.LeadAutoConversion.process: line 61, column 32: SOQL query with 1 row finished in 2 ms
20080929214915.307:Class.LeadAutoConversion.process: line 68, column 9: SelectLoop:LIST:SOBJECT:Lead
20080929214915.307:Class.LeadAutoConversion.getNewOwner: line 145, column 35:     returning Integer from method public Integer getAssignmentMode() in 0 ms
20080929214915.307:Class.LeadAutoConversion.getNewOwner: line 149, column 24:     returning MAP:Id,Id from method public MAP:Id,Id getCAMs() in 0 ms
20080929214915.307:Class.LeadAutoConversion.getNewOwner: line 154, column 33:     returning Boolean from method private Boolean isQueue(String) in 0 ms
20080929214915.307:Class.LeadAutoConversion.process: line 71, column 27:     returning Id from method private Id getNewOwner(Id) in 1 ms
20080929214915.307:Class.LeadAutoConversion.process: line 90, column 9: leadsToConvert: (Database.LeadConvert[getAccountId=null;getContactId=null;getConvertedStatus=Closed - Converted;getLeadId=00Q3000000LS5eXEAT;getOpportunityName=null;getOwnerId=00530000001UByQAAW;isDoNotCreateOpportunity=false;isOverwriteLeadSource=false;isSendNotificationEmail=true;])
20080929214915.307:Class.LeadAutoConversion.process: line 91, column 45: Database.convertLead(LIST:Database.LeadConvert, Boolean)
*** Beginning LeadAutoConversion on Lead trigger event AfterUpdate for 00Q3000000LS5eX

20080929214915.998:Trigger.LeadAutoConversion: line 4, column 18:     returning Config from method public static Config getInstance() in 0 ms
20080929214915.998:Trigger.LeadAutoConversion: line 5, column 19:     returning String from method public String getAutoConversionQueue() in 0 ms
20080929214915.998:Trigger.LeadAutoConversion: line 6, column 43:     returning String from method public String getAutoConversionQueue() in 0 ms
20080929214915.998:Trigger.LeadAutoConversion: line 6, column 5: AutoConversionQueue:00G30000001H1R2EAK
20080929214915.998:Trigger.LeadAutoConversion: line 12, column 9: SelectLoop:LIST:SOBJECT:Lead
20080929214915.998:Trigger.LeadAutoConversion: line 13, column 13: l.ownerId: 00530000001UByQAAW

Cumulative resource usage:

Resource usage for namespace: (default)
Number of SOQL queries: 5 out of 20
Number of query rows: 3 out of 1000
Number of SOSL queries: 0 out of 0
Number of DML statements: 1 out of 20
Number of DML rows: 1 out of 100
Number of script statements: 338 out of 10200
Maximum heap size: 0 out of 100000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 10
Number of record type describes: 0 out of 10
Number of child relationships describes: 0 out of 10
Number of picklist describes: 0 out of 10
Number of future calls: 0 out of 10

Total email recipients queued to be sent : 0
Static variables and sizes:
Config:ASSGN_MODE_CAM:4
Config:ASSGN_MODE_CAM_ST:4
Config:ASSGN_MODE_LEAD:4
Config:DEFAULT_ACCESS:4
Config:DEFAULT_MODE:4
Config:DEFAULT_ROLE:9
Config:MODE_ALL:4
Config:MODE_NON_PARTNER:4
Config:MODE_PARTNER:4
Config:m_instance:1133
LeadAutoConversion:cfg:0
LeadAutoConversion:inQueue:18
LeadAutoConversion:leads:4
LeadAutoConversion:m_Config:0
LeadAutoConversion:m_Leads:26
LeadAutoConversion:m_Shares:4
LeadAutoConversion:m_executionCount:4
LeadAutoConversion:m_instance:4
LeadAutoConversion:m_leadMap:26
LeadAutoConversion:m_oldOwners:44
LeadAutoConversion:m_oppMembers:4
LeadAutoConversion:m_opps:4
LeadAutoConversion:m_partnerUsers:4
PartnerUsers:m_CAMs:4
PartnerUsers:m_isTest:4
PartnerUsers:m_partnerUsers:4


*** Ending LeadAutoConversion on Lead trigger event AfterUpdate for 00Q3000000LS5eX

20080929214915.307:Class.LeadAutoConversion.process: line 91, column 45:     DML Operation executed in 629 ms
20080929214915.307:Class.LeadAutoConversion.process: line 92, column 9: lcrs(Database.LeadConvertResult[getAccountId=0013000000M8wYuAAJ;getContactId=0033000000URFYbAAP;getErrors=();getLeadId=00Q3000000LS5eXEAT;getOpportunityId=0063000000MpsKOAAZ;isSuccess=true;])
20080929214915.307:Class.LeadAutoConversion.process: line 94, column 9: SelectLoop:LIST:Database.LeadConvertResult
20080929214915.307:Class.LeadAutoConversion.process: line 99, column 23: SOQL query with 1 row finished in 5 ms
20080929214915.307:Class.LeadAutoConversion.process: line 101, column 17: l2.ConvertedOpportunityId: 0063000000MpsKOAAZ
20080929214915.307:Class.LeadAutoConversion.process: line 103, column 13: m_oldOwners: {00Q3000000LS5eXEAT=00530000001UByQAAW}
20080929214915.307:Class.LeadAutoConversion.getNewOwner: line 145, column 35:     returning Integer from method public Integer getAssignmentMode() in 0 ms
20080929214915.307:Class.LeadAutoConversion.getNewOwner: line 149, column 24:     returning MAP:Id,Id from method public MAP:Id,Id getCAMs() in 0 ms
20080929214915.307:Class.LeadAutoConversion.getNewOwner: line 154, column 33:     returning Boolean from method private Boolean isQueue(String) in 0 ms
20080929214915.307:Class.LeadAutoConversion.process: line 105, column 27:     returning Id from method private Id getNewOwner(Id) in 1 ms
20080929214915.307:Class.LeadAutoConversion.process: line 108, column 17:     returning SET:Id from method public SET:Id getPartners() in 0 ms
20080929214915.307:Trigger.LeadAutoConversion: line 28, column 13:     returning from end of method public void process() in 657 ms
20080929214915.307:Class.LeadAutoConversion.flush: line 187, column 5: m_executionCount 0
20080929214915.307:Class.LeadAutoConversion.flush: line 188, column 5: m_oppMembers ()
20080929214915.307:Class.LeadAutoConversion.flush: line 189, column 5: m_Shares ()
20080929214915.307:Trigger.LeadAutoConversion: line 29, column 13:     returning from end of method public void flush() in 1 ms

Cumulative resource usage:

Resource usage for namespace: (default)
Number of SOQL queries: 6 out of 20
Number of query rows: 4 out of 1000
Number of SOSL queries: 0 out of 0
Number of DML statements: 1 out of 20
Number of DML rows: 1 out of 100
Number of script statements: 368 out of 10200
Maximum heap size: 0 out of 100000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 10
Number of record type describes: 0 out of 10
Number of child relationships describes: 0 out of 10
Number of picklist describes: 0 out of 10
Number of future calls: 0 out of 10

Total email recipients queued to be sent : 0
Static variables and sizes:
Config:ASSGN_MODE_CAM:4
Config:ASSGN_MODE_CAM_ST:4
Config:ASSGN_MODE_LEAD:4
Config:DEFAULT_ACCESS:4
Config:DEFAULT_MODE:4
Config:DEFAULT_ROLE:9
Config:MODE_ALL:4
Config:MODE_NON_PARTNER:4
Config:MODE_PARTNER:4
Config:m_instance:1133
LeadAutoConversion:cfg:0
LeadAutoConversion:inQueue:18
LeadAutoConversion:leads:26
LeadAutoConversion:m_Config:0
LeadAutoConversion:m_Leads:26
LeadAutoConversion:m_Shares:4
LeadAutoConversion:m_executionCount:4
LeadAutoConversion:m_instance:4
LeadAutoConversion:m_leadMap:0
LeadAutoConversion:m_oldOwners:44
LeadAutoConversion:m_oppMembers:4
LeadAutoConversion:m_opps:4
LeadAutoConversion:m_partnerUsers:4
PartnerUsers:m_CAMs:4
PartnerUsers:m_isTest:4
PartnerUsers:m_partnerUsers:4


*** Ending LeadAutoConversion on Lead trigger event AfterUpdate for 00Q3000000LS5eX


Spooling All Immediate Actions
Ending All Rules Evaluation
Bulk Execute all Immediate Actions
*** Beginning Workflow Evaluation
User: Admin User
Start Time: 20080929214916.048
Starting All Rules Evaluation
Starting evaluation of rule type Assignment
Starting evaluation of rule type Response
Starting evaluation of rule type Workflow
Starting evaluation of rule type Escalation
End Time: 20080929214916.049
*** Ending Workflow Evaluation 
Hi,
    We have a client that need to embed sections of the Customer Portal in their own portal. Is this possible? I was thinking that an iFrame would work but can see issues with that unless Salesforce specifically support it.
 
Thanks,
Mike
 
Hi,
    I thought I saw a post recently that it would be possible to store custom settings in Salesforce and access them through APEX. I don't see anything in Summer '08. Is this on the way?
 
Thanks,
Mike

Hi,

We are having difficulty avoiding governor limits in a lead trigger. The problem is how Saleforce invokes the trigger when assignment rules are executed. I have a case where 36 leads have their owner changed by the assignment rules. The trigger is then invoked *separately* on each lead rather than invoked in bulk. This results in the trigger being called more than 36 times. After the trigger is invoked on the leads individually, it appears that the trigger is then invoked one more time in batch mode on all the leads. There must be some kind of mechanism to detect and ignore the individual invocations and then to detect when the final bulk trigger invocation is occuring so the trigger can execute then. I can't see any way to do this however. Could somebody please advise?

Thanks,

Mike

Hi,
     Is there anyway to instantiate sObject lists? i.e.

List <sobject> updates = new List <sobject>();

I can see lots of situations where it would be usefull to pass concrete sobjects cast as sObject typed arguments and work with them in lists / collections. Might bend the boundery between a strongly and weakly typed language but handy all the same.



Message Edited by mikeegar on 03-12-2008 08:30 PM
Hi,
   I am implementing a solution where we need to provide an enhancement to the standard 'change owner' functionality on Leads and Opportunities. It is similar to the standard behavior except that instead of having users, queues and partner users, it will have users, queues, partner users and *partner queues*.
 
To do this, the lookup dialog for normal queues should omit partner queues (which follow a naming convention of 'PQ_*'). Is there any way to do this other than re-implementing the queue lookup dialog? I can imagine that would be very complicated.
 
Thanks,
 
Mike
Hi,
    Is there any way to stop Assignment Rule execution from inside a Trigger? I am writing a Lead Trigger that needs to do the following:
 
perform a calculation to determine the ownership of the lead object
If an owner is found
     Assign the Lead
Else
     Assign through the regular Assignment Rules.
 
The Assignment Rules could be prevented from executing by setting a checkbox or some field that could be added to the criteria of all Assignment Rules. This solution is not ideal however and can be problematic when an org has a large number of rules.
 
Is there a better way to do this?
 
Thanks,
Mike
 
 

Hi Folks,

It should be possible to default the related object and recipient fields using email URL parameters e.g. open up the standard email page with an email template using merge fields from a custom object and a lead as a recipient. This does not appear to work. It does work for contacts however.

With a custom object and a lead recipient, this does not work:
https://na15.salesforce.com/_ui/core/email/author/EmailAuthor?p3_lkid=<Custom ObjectId>&p2_lkid=<Lead Id>&rtype=00Q

Using the same syntax and a contact recipient, this does work:
https://na15.salesforce.com/_ui/core/email/author/EmailAuthor?p3_lkid=<Custom ObjectId>&p2_lkid=<Contact Id>&rtype=003

Is this a known bug?

 

I know there are a million posts about email URL hacking out there. I've read most of them at this point.

Thanks,
Mike

 

Hi,
    I thought I saw a post recently that it would be possible to store custom settings in Salesforce and access them through APEX. I don't see anything in Summer '08. Is this on the way?
 
Thanks,
Mike
Hi Guys,

I have a problem that has me a little stumped. I have a few triggers in my sandbox some written by me some written by another developer. On their own they work fine but they are dependant on each other in that one creates records that the other triggers off of so when they are made active I start to get some funny results and anusual errors popping every now and then.

Here's just one of the errors I'm receiving.

(1)
paymentAA: execution of AfterUpdate

caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE
_ENTITY, invoiceAction: execution of AfterInsert

caused by: System.ListException: Duplicate id in list: a0aT00000009RIzIAM

Class.InvoiceAction.updateInvo
iceAmount: line 54, column 9
Trigger.invoiceAction: line 4, column 9

Class.PaymentAA.CreateInvoice: line 65, column 12
Class.PaymentAA.CreatePayment: line 29, column 13
Trigger.paymentAA: line 2, column 4

And below are the lines of code referenced by this error well the main 'perpetraitors' as I see it

One important note to mention is that this code gives seems to only give me errors when I have more than 1 Invoice_Item__c in the list to insert. When there is just one it works fine but when there is 2 or more it seems as though it crashes I'm guessing because it calles the trigger on invoice_item__c twice too quickly? Before both records are committed? I'm not sure but any help would be great. Thanks in advance.

Code:
FROM PaymentAA

...
// define a new invoice 
           Emp_Invoice__c newinvoice = new Emp_Invoice__c();
           
           // update the value of the account it relates to to the same as the sales prospect
           newinvoice.Account__c = spAcc;
           
           // relate to sales prospect
           newinvoice.Sales_Prospect__c = spID;
           
           // sets the date on the invoice
           newinvoice.Invoice_Date__c = date.today();
                      
           // commits the new invoice to database
           insert newinvoice;

           // returns a list of all the order items associated with sales prospect
           List<Order_Item__c> orderitems = [select Name, Order_Line_Total__c from Order_Item__c where Sales_Prospect__c = :spID];
           List<Invoice_Item__c> ii = new List<Invoice_Item__c>();
           // iterate over all the line items in the order
           for (Order_Item__c oi : orderitems) {
               // create a new invoice item corresponding to each order item with the same values
               ii.add(new Invoice_Item__c(Invoice__c = newinvoice.Id, Order_Item__c = oi.Id, Line_Total_ex_GST__c = oi.Order_Line_Total__c));
           }
           insert ii;
...



AND THE WHOLE Class.InvoiceAction This Triggers from "Invoice_Item__c" after insert / after update 

public class InvoiceAction { public static void updateInvoiceAmount(Invoice_Item__c[] newInvItems) { //array of invoices that have a new amount paid List<Emp_Invoice__c> myInvoices = new List<Emp_Invoice__c>(); //iterate over all the new invoice items in this batch for (Invoice_Item__c thisInvItem:newInvItems ) { //ingnore invoice items with out an invoice if (thisInvItem.Invoice__c != null){ //get all invoice items for this invoice List<Invoice_Item__c> allInvItems = [SELECT Id, Line_Total_ex_GST__c, GST_Amount__c, Amount_Paid__c FROM Invoice_Item__c WHERE Invoice__c = :thisInvItem.Invoice__c limit 1000]; // get the invoice for this invoice item and lock it Emp_Invoice__c thisInvoice = [SELECT Id, Amount_ex_GST__c, GST_Amount__c, Amount_Paid__c FROM Emp_Invoice__c WHERE Id = :thisInvItem.Invoice__c limit 1 for update]; decimal sumApPaid = 0.0; decimal sumLtPaid = 0.0; decimal sumGstPaid = 0.0; // sum up all the invoice items for this invoice for (Invoice_Item__c cInvItem:allInvItems ) { if(cInvItem.Amount_Paid__c != null){ sumApPaid += cInvItem.Amount_Paid__c; } if(cInvItem.Line_Total_ex_GST__c != null){ sumLtPaid += cInvItem.Line_Total_ex_GST__c; } if(cInvItem.GST_Amount__c != null){ sumGstPaid += cInvItem.GST_Amount__c; } } // update the amuount paid for this invoice thisInvoice.Amount_Paid__c = sumApPaid; thisInvoice.Amount_ex_GST__c = sumLtPaid; thisInvoice.GST_Amount__c = sumGstPaid; // add this invoice to the array of invoices that have a new amount paid System.debug('[InvoiceAction -> executeTriggerAfter] adding amount paid=' + thisInvoice.Amount_Paid__c + ' to invoice id=' +thisInvoice.id); myInvoices.add(thisInvoice); } } //update all invoices that have a new amount paid update myInvoices; } }

 




Message Edited by patske on 06-19-2008 03:40 PM

Message Edited by patske on 06-19-2008 03:44 PM
Hey,
 
There may be similar threads on this topic, but here goes anyway:
 
>>>>
YES:  SEE RECENT POST
WHICH IS THE EXACT SAME THING, OR NEARLY SO
<<<<
 
We have an org from which we're sourcing a managed package, and I'm trying to connect to it using the new Force.com Eclipse plug-in (v. 11.1.1).  The SOAP Endpoint is v. 11.1 as well.  What I get when connecting, and also when trying to 'refresh from server', or 'synchronize with server', is a msg box with the following error:
 
Unable to perform synchronization.
 
Reason:
TeamException: null: Duplicate retrieve names specified for package '<pkg name>'
 
I see a stack trace in my workspace log; if anybody wants to see it, I'd be happy to add it to this thread.
 
Does anybody have some insight into this, and what I can do about it, or how I can work around it?  Let's say for the sake of discussion that I do NOT want to re-create my org from scratch.  :^}
 
Thanks!
 
-phil m.


Message Edited by philbo on 01-14-2008 10:19 AM
  • January 14, 2008
  • Like
  • 0
I am trying to copy an attachment from one account to the other in Apex Code and receive the following compilation error: "Data type not supported".

I highlighted the line of code that generated the error. It lookslike Apex Code does not support the .Body datatype. Is there anyway to insert an Attachment in Apex?

Here is the snippet of my code:

Code:
for (Attachment attachmentSource : [Select Body, ContentType, IsPrivate, Name from Attachment where ParentId = :a.Clone_From_ID__c])
{
Attachment attachmentTarget = new Attachment();


attachmentTarget.ParentId = a.Id;
attachmentTarget.OwnerId = a.OwnerId; //assign same owner as parent account

attachmentTarget.Body = attachmentSource.Body;
attachmentTarget.ContentType = attachmentSource.ContentType;
attachmentTarget.IsPrivate = attachmentSource.IsPrivate;
attachmentTarget.Name = attachmentSource.Name;

insert(attachmentTarget);
}

 




  • July 19, 2007
  • Like
  • 0