• wendy chan 3
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies
I`m have build below visualforce page which allows our portal users to send emails. Page works fine, however now I want to add a functionality to allow users to upload the attachment and send with email. I have went through lot of resources online but cant find the solution. Can someone please help?

 
public class sendEmailStdCon {

    private final Case c;

    //Case fields
     public String Caseno { get; set; }
     public String CaseRecType { get; set; }
     public String CaseStatus { get; set; }
     public String CaseSubject { get; set; }
    public string threadID { get; set; }
    public string refNumber   { get; set; }

    public String subject { get; set; }
    public String body { get; set; }
    public String addresses { get; set; }
    public String BodyofEmail { get; set; }
    public String BccAddress { get; set; }
    public String ccAddress { get; set; }
    public String ToAddress { get; set; }


    public   String orgEmails {get;set;}



    datetime currenttime =  System.now();

    public sendEmailStdCon(ApexPages.StandardController controller) {

        Case c = [SELECT id, CaseNumber,Status ,Subject, Email_Case_Ref__c , RecordType.Name from Case where id = :ApexPages.currentPage().getParameters().get('id')];

            Caseno = c.CaseNumber;
         CaseRecType = c.RecordType.Name;
            CaseStatus = c.Status;
            CaseSubject = C.Subject;
           refNumber = c.Email_Case_Ref__c;     

        EmailMessage e = [ SELECT id, FromName,CcAddress, BccAddress,ToAddress , Subject, TextBody, FromAddress from EmailMessage WHERE 
                          ParentId = :ApexPages.currentPage().getParameters().get('id')  ORDER BY MessageDate DESC Limit 1  ];



        BodyofEmail = e.TextBody;
        Subject = e.Subject;
        BccAddress =  Userinfo.getUserEmail();
        ccAddress = e.CcAddress;
        addresses = e.FromAddress; 
        ToAddress = e.ToAddress;
    }







    public Case getCase() {
        return c;
    }

    public PageReference send() {

                  system.debug('orgEmails: ' + orgEmails);


      OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = :orgEmails];


        // Define the email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 



        String[] toAddresses = ToAddress.split(';', 0);

        // Sets the paramaters of the email
        email.setSubject( subject + ' ' + refNumber);
        email.setToAddresses( toAddresses );

        if (ccAddress != null && ccAddress.trim() != '' ) {
        String[] cccAddresses =ccAddress.split(';', 0);
        email.setCcAddresses( cccAddresses );
            }

        email.setPlainTextBody( BodyofEmail );



                if (BccAddress != null && BccAddress.trim() != '' ) {
        String[] BccAddresses =BccAddress.split(';', 0);
        email.setCcAddresses( BccAddresses );
            }


        if ( owea.size() > 0 ) {
        email.setOrgWideEmailAddressId(owea.get(0).Id);
        }



        // Sends the email
        Messaging.SendEmailResult [] r = 
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});   


             //   EmailMessage E = New EmailMessage () ;
            //  e.


        return null;
    }
}

VF:
<apex:page standardcontroller="Case" extensions="sendEmailStdCon">


    <apex:messages />
    <apex:pageBlock title="Send an Email to Your Representatives">
        <p>Fill out information below and click on "Send" button send an email.</p>
        <br />
        <apex:pageBlockSection columns="2"> 
            <apex:outputText label="Case Number" value="{!Caseno}"> </apex:outputText>
            <apex:outputText label="Case Record Type" value="{!CaseRecType}"> </apex:outputText>
            <apex:outputText label="Status" value="{!CaseStatus}"> </apex:outputText>
            <apex:outputText label="Subject" value="{!CaseSubject}"> </apex:outputText>

        </apex:pageBlockSection>

        <apex:form >


            <br /><br />

            <apex:outputLabel value="To" for="To"/>:<br />     
            <apex:inputText value="{!ToAddress}" id="to" maxlength="500" style="width: 500px;" />
            <br /><br />

            <apex:outputLabel value="CC" for="CC"/>:<br />     
            <apex:inputText value="{!ccAddress}" id="cc" maxlength="500" style="width: 500px;" />
            <br /><br />

            <apex:outputLabel value="Bcc" for="Bcc"/>:<br />     
            <apex:inputText value="{!Bccaddress}" id="Bcc" maxlength="500" style="width: 500px;"  />
            <br /><br />


            <apex:outputLabel value="Subject" for="Subject"/>:<br />     
            <apex:inputText value="{!subject}" id="Subject" maxlength="500" style="width: 500px;" />
            <br /><br />


            <apex:outputLabel value="Body" for="Body"/>:<br />     
            <apex:inputTextarea value="{!BodyofEmail}" id="Body"  rows="10" cols="80" style="width:550px;height:500px"   />           
            <br /><br /><br />
            <apex:commandButton value="Send Email" action="{!send}" /> 
        </apex:form>
    </apex:pageBlock>
</apex:page>

I`m using below Outputtext to show negative values in brackets. For example, -1,000.00 to reflect as (1,000.00)
 
<td>$<apex:outputText value="{0, Number, Currency}">   <apex:param value="{!target}" /> </apex:outputText></td>



Above line works fine except that I want to get rid of decimals. Negative value should appear like this (1,000) without decimals. Can someone please suggest a better way to achieve this? Can I achieve this using LEFT or Right Funtion?
I have two object - Object A and Object B. Object A has a field "Total Amount" and Object B has a field "Amount". Both objects have NO relation with each other. What I want to do is bring in total SUM of "Amount" (from Object B) in "Total Amount" (of Object A) using trigger.

Below code only works if Total_Amount__c has some value in it. If I remove a value, I keep getting - [System.NullPointerException: Attempt to de-reference a null object: Trigger.RollupTrigger: line 14, column 1]

 
trigger RollupTrigger on Object_B__c (after insert,after update)
{
        Decimal decValue = 0;

   AggregateResult[] groupedResults = [SELECT  SUM(Amount__c)   FROM Object_B__c  GROUP BY ID];
    
for (AggregateResult ar : groupedResults)  {
    System.debug('Average amount' + ar.get('expr0'));

    
    For (Object_A__c A : [SELECT ID, Total_Amount__c from Object_A__c WHERE ID = 'a122800000154Mi'])
    {
         
        A.Total_Amount__c += (Decimal)ar.get('expr0');
        Update A;
        
       }
    }
}

 
I have two object - Object A and Object B. Object A has a field "Total Amount" and Object B has a field "Amount". Both objects have NO relation with each other. What I want to do is bring in total SUM of "Amount" (from Object B) in "Total Amount" (of Object A) using trigger. Can some one please help me with an example?
I was wondering if someone can help me with an issue I have with Single Sign On. I have implemented a Single Sign on with one of our Third Party app using "Connected Apps" in Salesforce. SSO works fine, but I want to pass some additional information such as Account Name, Type, Industry etc. So that a new account is created in Third Party app along with SSO. is there a way I can accomplish this ? I want to pass SAML as well as JSON attribute in the SAML request. This Third Party app allows creating account in SAML request.
I`m new to SAML/SSO configuration and I was wondering if someone can point me in right direction. I have a requirement where I need to configure a third party app as a service provider (Salesforce to act as IdP). I have already shared my org certificate with this Third Party App engineers and in return, they have shared their ACS and entity URL with me. However, SSO is not working.
Questions -
1) Is 'Connected App' the only way to establish SSO in Salesforce?
2) In a documentation shared by this Third Party app, they have given a standard SAML/XML response. Could we create a custom functionality (without using Connected App) to establish SSO?

Any help is much appreciated.
I`m using below Outputtext to show negative values in brackets. For example, -1,000.00 to reflect as (1,000.00)
 
<td>$<apex:outputText value="{0, Number, Currency}">   <apex:param value="{!target}" /> </apex:outputText></td>



Above line works fine except that I want to get rid of decimals. Negative value should appear like this (1,000) without decimals. Can someone please suggest a better way to achieve this? Can I achieve this using LEFT or Right Funtion?
I have two object - Object A and Object B. Object A has a field "Total Amount" and Object B has a field "Amount". Both objects have NO relation with each other. What I want to do is bring in total SUM of "Amount" (from Object B) in "Total Amount" (of Object A) using trigger. Can some one please help me with an example?