You need to sign in to do that
Don't have an account?
Generate PDF Invoice & Create Invoice Tracking Record & Attach Generated PDF to New Record??
I have tried so many different things to try to get this accomplished and I just can't figure it out! It's driving me crazy, I've spent so many hours getting error after error.
So, any help would be greatly appreciated!!
I have a custom button on the parent record that 1. Creates a .pdf through a visualforce page using data within the parent record (Invoice) and 2. Creates a child record "Partnership Invoice Tracking".
I would like a third action to fire as well - attach the created .pdf to the newly created Partnership Invoice Tracking record. I've been so close so many times, but kept getting " Expected ';' " errors.
Here is the code I have that performs the two above referenced actions:
________________________________________________________________________________
{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")} var newRecords = []; var PA = new sforce.SObject("Partnership_Account__c "); var PAStatus__c = "{!Partnership_Account__c.Status__c }" if(PAStatus__c == "Active") { window.open("{!URLFOR('apex/partnershipAccountpdf?id=' + Partnership_Account__c.Id )}"); } else { alert('Only active Partnership Accounts will generate the Invoice. Please change the Status field value to Active in the Partnership Account record to generate the invoice.'); } {!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} // purpose: onClick() event handler // author: Amanda Silber // dated: November 2, 2012 var createList = []; var copyPartnershipInvoiceTracking = new sforce.SObject("Partnership_Invoice_Tracking__c"); copyPartnershipInvoiceTracking.Partnership_Account__c = "{!Partnership_Account__c.Id}"; var tDate = sforce.internal.dateTimeToString(new Date()); //set name on record copyPartnershipInvoiceTracking.Name = "{!Partnership_Account__c.Invoice_Number__c}"; copyPartnershipInvoiceTracking.Contract_Addendum_Type__c = "SRA"; createList.push(copyPartnershipInvoiceTracking); sforce.connection.create(createList); window.alert("Partnership Invoice Tracking Record Created"); parent.window.location.reload();
___________________________________________________________________________
Thank you in advance!!
Was thinking what if we insert the generated Pdf as an attachment and related the attachment with the Custom object where you want may resolve the problem than using ajax
Let me just say that in no way do I consider myself a developer. I dabble in it and I try really hard to learn it by writing and testing and reading blogs and developer guides. I would love to understand it better, but I don't have much time to take classes.
That being said, I'm not sure of any other way to do it other than how I am currently. Here is what I had for the 'attachment' code: