Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <apex:form id="frm">
- <font color="red"><apex:pageMessages ></apex:pageMessages></font>
- <apex:sectionHeader title="Attach File to Notes & Attachments"/>
- <apex:pageblock >
- <b> 1. Select the File</b><br/>
- Type the path of the file or click the Browse button to find the file.<br/>
- <br/><apex:inputfile value="{!myfile.body}" filename="{!myfile.Name}"/> <!-- SENDS THE ATTACHED FILE INFO TO TESTMETHOD() -->
- <p></p>
- <b> 2. Click the "Attach File" button.</b><br/>
- ( When the upload is complete the file information will appear in Next Page )<br/>
- <br/> <apex:actionRegion immediate="true" >
- <apex:commandbutton value="Attach File" action="{!showPopup}" id="saveButton" rerender="popup"/>
- </apex:actionRegion>
- <br/>
- <apex:outputPanel id="popup">
- <apex:outputPanel id="popInnerOutputPnl" styleClass="customPopup" layout="block" rendered="{!displayPopUp}">
- <apex:commandButton value="X" title="Close the popup" action="{!Cancel1}" styleClass="closeButton" >
- </apex:commandButton><br/>
- <table border="0">
- <tr><td> </td></tr>
- <tr>
- <td align="center">
- Additional Notification Recipients(Separate Email Addresses With A Comma)
- </td>
- <td>
- </td>
- </tr><tr><td> </td></tr>
- </table>
- <table align="center"><tr> <td> </td></tr>
- <tr>
- <td align="center">
- <apex:commandButton id="btnCenter" value="Save & Send" action="{!testingMethod}"> <!-- CALLING THE LOGIC TO CREATE AND ATTACH -->
- </apex:commandButton>
- </td>
- </tr>
- </table>
- </apex:outputPanel>
- </apex:outputPanel>
- <br/><apex:commandbutton value="Cancel" action="{!Cancel1}" onclick="return myFunction()"/>
- </apex:pageblock>
- </apex:form>
- public with sharing class CustomEmailAttachmentsForCampaigns {
- public CPQ_Notes_Attachments__c cpq1{get;set;}
- @AuraEnabled
- public static Boolean displayPopup {get;set;}
- public CustomEmailAttachmentsForCampaigns() {}
- public
- CustomEmailAttachmentsForCampaigns(ApexPages.StandardController controller) {
- }
- public static transient Attachment myfile;
- //public Attachment myfile;
- //Getfile Method
- public Attachment getmyfile()
- {
- myfile = new Attachment();
- return myfile;
- }
- public void showPopup(){
- displayPopup = true;
- }
- @AuraEnabled
- public static void testingMethod()
- {
- CPQ_Notes_Attachments__c cpqNotesandAttach;
- String idofSC;
- Sales_Campaign__c newRecord = new Sales_Campaign__c(Name = 'Test account', Account__c = 'Test');
- insert newRecord;
- idofSC = newRecord.id;
- System.debug('TESTING SC ID' + idofSC);
- cpqNotesandAttach.Sales_Campaign__c = idofSC;
- Attachment att = new Attachment(parentId = idofSC, name=myfile.name, body = myfile.body);
- insert att;
- System.debug('TESTING ATT ID' + att.id);
- }
- public PageReference Cancel1()
- {
- displayPopup = false;
- return null;
- }
- }
Add Comment
Please, Sign In to add comment