• Rohan Suresh
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hello,

I have this strange issue where the actionSupport is failing to execute Controller action. It works properly for couple of clicks/selections but after that it doesnt do anything.

Below is the code snippet:
!-- Visualforce page code --!
<apex:page controller="sampleCon">
    <apex:form >
        
    
    <apex:selectList id="ddlVCs" label="Vertical Unit / Accounts" value="{!SelectedVCs}" >
          <apex:selectOptions value="{!ValueCorridors}"></apex:selectOptions>
          <apex:actionSupport event="ondblclick" action="{!FetchAccountsForVC}" rerender="out1" status="myStatus1" />
          <apex:actionStatus id="myStatus1" startText="Please Wait..."  />
      </apex:selectList>
    
    <apex:outputPanel id="out1"   >
        <apex:selectList id="ddlAccounts" label="Accounts" value="{!SelectedAccounts}">
            <apex:selectOptions value="{!AccountsList}"></apex:selectOptions>
        </apex:selectList>
    </apex:outputPanel>
    
</apex:page>

!-- Controller Class Code --!
public class sampleCon {
    String selVCs;
    String[] selectedAccounts = new String[]{};
    List<SelectOption> lstAccountsForVC = new List<SelectOption>();
    String TempVar;
            
    public PageReference test() {
        return null;
    }

    public List<SelectOption> GetValueCorridors()
    {
        List<Account> lstVC = [SELECT Value_Corridor__c FROM Account where Business_Unit__c = 'Business Unit UK (BU-UK)'];
        
        List<SelectOption> options = new List<SelectOption>();
        
        If(lstVC.size() > 0)
        {
            for(Account Acc : lstVC)
            {
                options.add(new SelectOption(Acc.Value_Corridor__c, Acc.Value_Corridor__c));
            }
        }
        
        return options;
    }
    
    public String getSelectedVCs()
    {
        return selVCs;
    }
    
    public void setSelectedVCs(String SelectedVCs)
    {
        this.selVCs = SelectedVCs;
    }
    
    public PageReference FetchAccountsForVC()
    {
        TempVar = selVCs;
        List<Account> lstAccounts = [SELECT Id, Name FROM Account where Value_Corridor__c = :selVCs];
        
        List<SelectOption> options = new List<SelectOption>();
        
        If(lstAccounts.size() > 0)
        {
            for(Account Acc : lstAccounts)
            {
                options.add(new SelectOption(Acc.Id, Acc.Name));
            }
        }
        
        lstAccountsForVC = options;
        
        return null;
    }
    
    public List<SelectOption> getAccountsList()
    {
        return lstAccountsForVC;
    }
    
    public String[] getSelectedAccounts()
    {
        return selectedAccounts;
    }
    
    public void setSelectedAccounts(String[] SelectedAccounts)
    {
        this.selectedAccounts = SelectedAccounts;
    }    
    
}
Thanks,
Vikesh Gajula

Hi,
I have created a visualforce email template. The body of this template contains some text and few merge fields linked to custom object. I am able read the data using merge fields successfully.


But this custom object also allows users to attach files. So I need to send those attached files (if any) with the same email.


I have tried different options but none of them worked for me. Now for time being what i did is that i added a custom component in my mail body and that custom component has a apex:repeat control that gives the link and content type of attachments in a tabular format. Below is my custom component:


<table cellpadding="1" cellspacing="0" width="100%" border="1">

    <tr><td colspan="2"><b>Attachments</b></td></tr>

    <tr><td><b>File Name</b></td>         <td><b>Content Type</b></td></tr>

    <apex:repeat value="{!attachments}" var="attachment">

     <tr>

         <td><apex:outputLink value="https://c.cs17.content.force.com/servlet/servlet.FileDownload?file={!attachment.Id}">          {!attachment.name}</apex:outputLink></td>

         <td>{!attachment.contentType}</td>

     </tr>

    </apex:repeat>

</table>


But the above solution requires the user to be connected to the internet and login to salesforce to access the attachments since the files are not physically attached to mail.


Do we have any way through which we can read attachments from attachment table and send as attachments using visualforce email templates. Also there may be 1 or more than one attachment.

 

Thanks,

Vicky

Hello,

I have this strange issue where the actionSupport is failing to execute Controller action. It works properly for couple of clicks/selections but after that it doesnt do anything.

Below is the code snippet:
!-- Visualforce page code --!
<apex:page controller="sampleCon">
    <apex:form >
        
    
    <apex:selectList id="ddlVCs" label="Vertical Unit / Accounts" value="{!SelectedVCs}" >
          <apex:selectOptions value="{!ValueCorridors}"></apex:selectOptions>
          <apex:actionSupport event="ondblclick" action="{!FetchAccountsForVC}" rerender="out1" status="myStatus1" />
          <apex:actionStatus id="myStatus1" startText="Please Wait..."  />
      </apex:selectList>
    
    <apex:outputPanel id="out1"   >
        <apex:selectList id="ddlAccounts" label="Accounts" value="{!SelectedAccounts}">
            <apex:selectOptions value="{!AccountsList}"></apex:selectOptions>
        </apex:selectList>
    </apex:outputPanel>
    
</apex:page>

!-- Controller Class Code --!
public class sampleCon {
    String selVCs;
    String[] selectedAccounts = new String[]{};
    List<SelectOption> lstAccountsForVC = new List<SelectOption>();
    String TempVar;
            
    public PageReference test() {
        return null;
    }

    public List<SelectOption> GetValueCorridors()
    {
        List<Account> lstVC = [SELECT Value_Corridor__c FROM Account where Business_Unit__c = 'Business Unit UK (BU-UK)'];
        
        List<SelectOption> options = new List<SelectOption>();
        
        If(lstVC.size() > 0)
        {
            for(Account Acc : lstVC)
            {
                options.add(new SelectOption(Acc.Value_Corridor__c, Acc.Value_Corridor__c));
            }
        }
        
        return options;
    }
    
    public String getSelectedVCs()
    {
        return selVCs;
    }
    
    public void setSelectedVCs(String SelectedVCs)
    {
        this.selVCs = SelectedVCs;
    }
    
    public PageReference FetchAccountsForVC()
    {
        TempVar = selVCs;
        List<Account> lstAccounts = [SELECT Id, Name FROM Account where Value_Corridor__c = :selVCs];
        
        List<SelectOption> options = new List<SelectOption>();
        
        If(lstAccounts.size() > 0)
        {
            for(Account Acc : lstAccounts)
            {
                options.add(new SelectOption(Acc.Id, Acc.Name));
            }
        }
        
        lstAccountsForVC = options;
        
        return null;
    }
    
    public List<SelectOption> getAccountsList()
    {
        return lstAccountsForVC;
    }
    
    public String[] getSelectedAccounts()
    {
        return selectedAccounts;
    }
    
    public void setSelectedAccounts(String[] SelectedAccounts)
    {
        this.selectedAccounts = SelectedAccounts;
    }    
    
}
Thanks,
Vikesh Gajula

Hi,
I have created a visualforce email template. The body of this template contains some text and few merge fields linked to custom object. I am able read the data using merge fields successfully.


But this custom object also allows users to attach files. So I need to send those attached files (if any) with the same email.


I have tried different options but none of them worked for me. Now for time being what i did is that i added a custom component in my mail body and that custom component has a apex:repeat control that gives the link and content type of attachments in a tabular format. Below is my custom component:


<table cellpadding="1" cellspacing="0" width="100%" border="1">

    <tr><td colspan="2"><b>Attachments</b></td></tr>

    <tr><td><b>File Name</b></td>         <td><b>Content Type</b></td></tr>

    <apex:repeat value="{!attachments}" var="attachment">

     <tr>

         <td><apex:outputLink value="https://c.cs17.content.force.com/servlet/servlet.FileDownload?file={!attachment.Id}">          {!attachment.name}</apex:outputLink></td>

         <td>{!attachment.contentType}</td>

     </tr>

    </apex:repeat>

</table>


But the above solution requires the user to be connected to the internet and login to salesforce to access the attachments since the files are not physically attached to mail.


Do we have any way through which we can read attachments from attachment table and send as attachments using visualforce email templates. Also there may be 1 or more than one attachment.

 

Thanks,

Vicky