function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Priya AakankshaPriya Aakanksha 

how to do two action with one button one should send mail and another get attached in note and attachements

how to do two action with one button one should send mail and another get attached in note and attachements
Best Answer chosen by Priya Aakanksha
Priya AakankshaPriya Aakanksha
problem solved.
===============
// this code is attachment of pdf=====

public void saveAttachment(){
  String encodedContentsString = System.currentPageReference().getParameters().get('fileContents');
  Id accountId = System.currentPageReference().getParameters().get('accountId');
  
  Attachment attachment = new Attachment();
  attachment.Body = Blob.valueOf(encodedContentsString);
  attachment.Name = String.valueOf('test.txt');
  attachment.ParentId = accountId; 
  insert attachment;
}
==========================//
 

All Answers

Priya AakankshaPriya Aakanksha
if i click that button one action should send mail and another action should saved in notes and attachements
Team NubesEliteTeam NubesElite
Hi Priya,
Call One method from another method within the class, or you could use javascript and use the oncomplete function (maybe).

Thank You
www.nubeselite.com

Developement | Training | Consulting

Please Mark this assolution if your problem resolved.
Priya AakankshaPriya Aakanksha
// how to use in this code- oncomplete function
=======================================
public pagereference sendmailandsavepdf(){
        for(mywrapperclass w:wraplist){
            if(w.flag == true){
                 if(w.dmrec.DeNoSent__c__c == false){
                w.dmrec.DeNoSent__c=true;
               
                w.dmrec.DeNoSent__c=system.today();
                     update w.dmrec;
                 }
       
            }
        }
==========
plz reply
Team NubesEliteTeam NubesElite
Please refer this you will get an idea
Controller:-
public class Apex{
    public boolean test{get;set;}
    
    public Apex(){
        test = false;
    }
    public void method1(){
        test = true;
    }
}
Page:-
<apex:page showHeader="false" sidebar="false" controller="Apex">
<apex:outputPanel id="tst">
<script>
    function complete1() {
        var check1= '{!test}';
        alert(check1);
        }
</script>
<apex:form>
<apex:commandButton value="Next" action="{!method1}" rerender="tst" oncomplete="complete1();"/>
</apex:form>
</apex:outputPanel>
</apex:page>

Thank You
www.nubeselite.com

Developement | Training | Consulting

Please Mark this assolution if your problem resolved.
Priya AakankshaPriya Aakanksha
problem solved.
===============
// this code is attachment of pdf=====

public void saveAttachment(){
  String encodedContentsString = System.currentPageReference().getParameters().get('fileContents');
  Id accountId = System.currentPageReference().getParameters().get('accountId');
  
  Attachment attachment = new Attachment();
  attachment.Body = Blob.valueOf(encodedContentsString);
  attachment.Name = String.valueOf('test.txt');
  attachment.ParentId = accountId; 
  insert attachment;
}
==========================//
 
This was selected as the best answer