-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
10Questions
-
14Replies
how to get email template id in select option
here its my code:-
// Apex controller
public class Filtered_Contacts {
public List<opportunity> oppList{get;set;}
//public string stagename{get;set;}
public Boolean show{set;get;}
public Boolean showbtn{set;get;}
public opportunity opp{get;set;}
public List<WrapperClass> wrapList {get; set;}
public String selectedTemplateName { public get; public set; }
// counstructor
public Filtered_Contacts(){
oppList = new List<opportunity>();
opp = new opportunity();
show =false;
showbtn=false;
wrapList = new List<WrapperClass>();
}
public pageReference fetchopp(){
show =true;
showbtn=true;
system.debug('====='+show);
oppList = New List<opportunity>();
system.debug('====='+show);
for(Opportunity op : [select id, Name , StageName from opportunity where AccountId=:opp.AccountId and StageName=:opp.StageName]) {
wrapList.add(new WrapperClass(op));
system.debug('wrapList'+wrapList);
}
return null;
}
public PageReference sendEmail() {
List<Opportunity> selectedopportunity = new List<Opportunity>();
for(WrapperClass oppt : wrapList) {
if(oppt.selected == true) {
selectedopportunity.add(oppt.opps);
}
}
System.debug('These are the selected opportunities…'+selectedopportunity);
String body = '';
body = '<table border="1" style="border-collapse: collapse"><tr><th>id</th><th>Name</th></tr>';
for(Opportunity oppp : selectedopportunity) {
String url='<a href="'+system.Url.Getsalesforcebaseurl().toexternalform()+'/'+oppp.Id+'"> '+oppp.Name+'</a>';
String name = oppp.Name;
body += '<tr><td>' + url + '</td><td>' + name + '</td></tr>' ;
}
body += '</table>';
system.debug('body '+body);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'rishabhrathor05@gmail.com'};
system.debug(toAddresses);
mail.setToAddresses(toAddresses);
mail.setReplyTo('rishabhrathor05@gmail.com');
mail.setSenderDisplayName('Salesforce');
mail.setSubject( 'See Link');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Hello');
// mail.setTemplateId(t.id);
mail.HtmlBody = body;
system.debug('======='+body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
List<Messaging.SendEmailResult> results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
if(results[0].success){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.CONFIRM, 'Success!'));
}
return null;
}
public List<SelectOption> getMyPersonalTemplateOptions() {
showbtn=true;
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('','-None-'));
for (EmailTemplate t : [select Id,Name,Body from EmailTemplate ])
{
options.add(new SelectOption(t.Id,t.Name));
}
system.debug('========'+options);
return options;
}
public class WrapperClass {
public Opportunity opps {get; set;}
public Boolean selected {get; set;}
public WrapperClass(Opportunity op) {
opps = op;
selected = false;
}
}
}
<!--- vf page--->
<apex:page Controller="Filtered_Contacts" lightningStylesheets="true" sidebar="false">
<script>
function checkAll(cb,cbid)
{
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf(cbid)!=-1){
inputElem[i].checked = cb.checked;
}
}
}
</script>
<article class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__figure">
<span class="slds-icon_container slds-icon-standard-account" title="Opportunity">
<svg class="slds-icon slds-icon_small" aria-hidden="true">
<!-- <use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#account"></use>-->
</svg>
<span class="slds-assistive-text">Opportunity</span>
</span>
</div>
<div class="slds-media__body">
<h2 class="slds-card__header-title">
<a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Opportunity">
<span>Opportunities</span>
</a>
</h2>
</div>
</header>
</div>
</article>
<apex:slds />
<apex:form id="theform">
<div class="demo-only demo-only--sizing slds-grid slds-wrap slds-m-top_large">
<label ><strong> Account Name </strong></label>
<div class="slds-size_1-of-4">
<!-- <apex:outputLabel value="{!$ObjectType.Account.fields['Name'].label}" /> -->
<apex:inputField value="{!opp.AccountId}" />
</div>
<label ><strong> Stage Name </strong></label>
<div class="slds-size_1-of-4">
<apex:inputfield value="{!opp.StageName}" />
</div>
<label><strong> Template Name </strong></label>
<div class="slds-size_1-of-4">
<apex:selectList value="{!selectedTemplateName}" multiselect="false" size="1">
<apex:selectOptions value="{!myPersonalTemplateOptions}"/>
</apex:selectList>
</div>
</div><br/>
<div class="slds-grid">
<div class="slds-size_1-of-12">
<apex:commandButton action="{!fetchopp}" value="Search" styleClass="slds-button slds-button_brand"/>
</div>
<div class="slds-size_1-of-12">
<apex:outputPanel rendered="{!showbtn}" >
<apex:commandButton action="{!sendEmail}" value="Send Email" styleClass="slds-button slds-button_brand"/>
</apex:outputPanel>
</div>
</div>
<div class="slds-p-top_small">
<apex:outputPanel rendered="{!show}">
<table class="slds-table slds-table_cell-buffer slds-table_bordered slds-p-top_small" >
<thead>
<tr>
<th class="" scope="col">
<div class="slds-truncate" >
<input type="checkbox" value="" onclick="checkAll(this,'checkedone')"/>
</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" >Id</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Last Name">Opportunity Name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Email">Stage </div>
</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!wrapList}" var="con">
<tr class="slds-hint-parent">
<td><apex:inputCheckbox value="{!con.selected}" id="checkedone"/></td>
<td data-label="Id" >
<div class="slds-truncate" title="Id"><apex:outputField value="{!con.opps.Id}"/> </div>
</td>
<td data-label="Opportunity Name" >
<div class="slds-truncate" title=" Opportunity Name"> <Apex:outputfield value="{!con.opps.Name}"/></div>
</td>
<td data-label="Stage Name">
<div class="slds-truncate" title="Stage Name"> <apex:outputfield value="{!con.opps.StageName}"/></div>
</td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:outputPanel>
</div>
</apex:form>
</apex:page>
// Apex controller
public class Filtered_Contacts {
public List<opportunity> oppList{get;set;}
//public string stagename{get;set;}
public Boolean show{set;get;}
public Boolean showbtn{set;get;}
public opportunity opp{get;set;}
public List<WrapperClass> wrapList {get; set;}
public String selectedTemplateName { public get; public set; }
// counstructor
public Filtered_Contacts(){
oppList = new List<opportunity>();
opp = new opportunity();
show =false;
showbtn=false;
wrapList = new List<WrapperClass>();
}
public pageReference fetchopp(){
show =true;
showbtn=true;
system.debug('====='+show);
oppList = New List<opportunity>();
system.debug('====='+show);
for(Opportunity op : [select id, Name , StageName from opportunity where AccountId=:opp.AccountId and StageName=:opp.StageName]) {
wrapList.add(new WrapperClass(op));
system.debug('wrapList'+wrapList);
}
return null;
}
public PageReference sendEmail() {
List<Opportunity> selectedopportunity = new List<Opportunity>();
for(WrapperClass oppt : wrapList) {
if(oppt.selected == true) {
selectedopportunity.add(oppt.opps);
}
}
System.debug('These are the selected opportunities…'+selectedopportunity);
String body = '';
body = '<table border="1" style="border-collapse: collapse"><tr><th>id</th><th>Name</th></tr>';
for(Opportunity oppp : selectedopportunity) {
String url='<a href="'+system.Url.Getsalesforcebaseurl().toexternalform()+'/'+oppp.Id+'"> '+oppp.Name+'</a>';
String name = oppp.Name;
body += '<tr><td>' + url + '</td><td>' + name + '</td></tr>' ;
}
body += '</table>';
system.debug('body '+body);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'rishabhrathor05@gmail.com'};
system.debug(toAddresses);
mail.setToAddresses(toAddresses);
mail.setReplyTo('rishabhrathor05@gmail.com');
mail.setSenderDisplayName('Salesforce');
mail.setSubject( 'See Link');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Hello');
// mail.setTemplateId(t.id);
mail.HtmlBody = body;
system.debug('======='+body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
List<Messaging.SendEmailResult> results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
if(results[0].success){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.CONFIRM, 'Success!'));
}
return null;
}
public List<SelectOption> getMyPersonalTemplateOptions() {
showbtn=true;
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('','-None-'));
for (EmailTemplate t : [select Id,Name,Body from EmailTemplate ])
{
options.add(new SelectOption(t.Id,t.Name));
}
system.debug('========'+options);
return options;
}
public class WrapperClass {
public Opportunity opps {get; set;}
public Boolean selected {get; set;}
public WrapperClass(Opportunity op) {
opps = op;
selected = false;
}
}
}
<!--- vf page--->
<apex:page Controller="Filtered_Contacts" lightningStylesheets="true" sidebar="false">
<script>
function checkAll(cb,cbid)
{
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf(cbid)!=-1){
inputElem[i].checked = cb.checked;
}
}
}
</script>
<article class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__figure">
<span class="slds-icon_container slds-icon-standard-account" title="Opportunity">
<svg class="slds-icon slds-icon_small" aria-hidden="true">
<!-- <use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#account"></use>-->
</svg>
<span class="slds-assistive-text">Opportunity</span>
</span>
</div>
<div class="slds-media__body">
<h2 class="slds-card__header-title">
<a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Opportunity">
<span>Opportunities</span>
</a>
</h2>
</div>
</header>
</div>
</article>
<apex:slds />
<apex:form id="theform">
<div class="demo-only demo-only--sizing slds-grid slds-wrap slds-m-top_large">
<label ><strong> Account Name </strong></label>
<div class="slds-size_1-of-4">
<!-- <apex:outputLabel value="{!$ObjectType.Account.fields['Name'].label}" /> -->
<apex:inputField value="{!opp.AccountId}" />
</div>
<label ><strong> Stage Name </strong></label>
<div class="slds-size_1-of-4">
<apex:inputfield value="{!opp.StageName}" />
</div>
<label><strong> Template Name </strong></label>
<div class="slds-size_1-of-4">
<apex:selectList value="{!selectedTemplateName}" multiselect="false" size="1">
<apex:selectOptions value="{!myPersonalTemplateOptions}"/>
</apex:selectList>
</div>
</div><br/>
<div class="slds-grid">
<div class="slds-size_1-of-12">
<apex:commandButton action="{!fetchopp}" value="Search" styleClass="slds-button slds-button_brand"/>
</div>
<div class="slds-size_1-of-12">
<apex:outputPanel rendered="{!showbtn}" >
<apex:commandButton action="{!sendEmail}" value="Send Email" styleClass="slds-button slds-button_brand"/>
</apex:outputPanel>
</div>
</div>
<div class="slds-p-top_small">
<apex:outputPanel rendered="{!show}">
<table class="slds-table slds-table_cell-buffer slds-table_bordered slds-p-top_small" >
<thead>
<tr>
<th class="" scope="col">
<div class="slds-truncate" >
<input type="checkbox" value="" onclick="checkAll(this,'checkedone')"/>
</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" >Id</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Last Name">Opportunity Name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Email">Stage </div>
</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!wrapList}" var="con">
<tr class="slds-hint-parent">
<td><apex:inputCheckbox value="{!con.selected}" id="checkedone"/></td>
<td data-label="Id" >
<div class="slds-truncate" title="Id"><apex:outputField value="{!con.opps.Id}"/> </div>
</td>
<td data-label="Opportunity Name" >
<div class="slds-truncate" title=" Opportunity Name"> <Apex:outputfield value="{!con.opps.Name}"/></div>
</td>
<td data-label="Stage Name">
<div class="slds-truncate" title="Stage Name"> <apex:outputfield value="{!con.opps.StageName}"/></div>
</td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:outputPanel>
</div>
</apex:form>
</apex:page>
- rishabh rathor 18
- September 16, 2020
- Like
- 0
i want to show 5 accounts as in tabs and when i select on any account (in tab) then account's email should displayusing lightning component
====Component===========
<aura:component controller="AccountTabsCntrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doinit}" />
<aura:attribute name="Accounts" type="List" />
<lightning:tabset>
<aura:iteration items="{!v.Accounts}" var="acc">
<lightning:tab label="{!acc.Name}">
{acc.Phone}
</lightning:tab>
</aura:iteration>
</lightning:tabset>
</aura:component>
=========js controller=========
({
doinit : function(component, event, helper) {
console.log('load');
var action = component.get('c.getAccounts');
action.setCallback(this, function(response){
var result =response.getReturnValue();
console.log(result);
component.set("v.Accounts",result);
console.log(result);
});
$A.enqueueAction(action);
},
})
===========Apex controller==============
public class AccountTabsCntrl {
@AuraEnabled
public static list<Account> getAccounts(id accountIds){
List<Account> accLIst = new List<Account>();
accLIst = [Select id, Name,Phone from account where Id=:accountIds Limit 5];
return accLIst;
}
}
<aura:component controller="AccountTabsCntrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doinit}" />
<aura:attribute name="Accounts" type="List" />
<lightning:tabset>
<aura:iteration items="{!v.Accounts}" var="acc">
<lightning:tab label="{!acc.Name}">
{acc.Phone}
</lightning:tab>
</aura:iteration>
</lightning:tabset>
</aura:component>
=========js controller=========
({
doinit : function(component, event, helper) {
console.log('load');
var action = component.get('c.getAccounts');
action.setCallback(this, function(response){
var result =response.getReturnValue();
console.log(result);
component.set("v.Accounts",result);
console.log(result);
});
$A.enqueueAction(action);
},
})
===========Apex controller==============
public class AccountTabsCntrl {
@AuraEnabled
public static list<Account> getAccounts(id accountIds){
List<Account> accLIst = new List<Account>();
accLIst = [Select id, Name,Phone from account where Id=:accountIds Limit 5];
return accLIst;
}
}
- rishabh rathor 18
- December 21, 2019
- Like
- 0
failed to complete tarailhead challenge
for:-
https://trailhead.salesforce.com/content/learn/modules/lightning-web-components-basics/add-styles-and-data-to-a-lightning-web-component
https://trailhead.salesforce.com/content/learn/modules/lightning-web-components-basics/add-styles-and-data-to-a-lightning-web-component
- rishabh rathor 18
- December 19, 2019
- Like
- 0
My requirement is to display Account and its related contacts using accordion Using VF page.
Here Its my Code:-
========Apex Controller=============
public class AccordianCntrl {
public String selectedaccountId { get; set; }
public List<Contact> Contacts{get;set;}
public AccordianCntrl(){
Contacts = new List<Contact>();
}
public List<Account> getListOfAccounts()
{
List<Account> AccountList = [select id,Name,Phone,AccountNumber,Industry from Account Limit 10] ;
return AccountList;
}
// Return Accounts
public pagereference contactNames()
{
system.debug('id '+selectedaccountId);
Contacts = [Select FirstName, LastName, Email , Phone From Contact where Accountid=:selectedaccountId];
//List<Contact> results1 = [Select FirstName, LastName, Email , Phone From Contact ];
System.debug(Contacts);
return null;
}
}
========VF Page===================
<apex:page controller="AccordianCntrl" docType="html-5.0" standardStylesheets="true" showHeader="false">
<apex:slds />
<style>
.slds-scope .slds-section { position: relative; margin: 0px;}
.slds-scope .slds-section:after { content: ""; width: 8px; height: 8px; border-bottom: 2px solid #000; border-left: 2px solid #000; position: absolute; transform: rotate(-135deg) skew(0deg); top: 13px; left: 12px; cursor: pointer;}
.slds-scope .slds-section.slds-is-open:after { content: ""; width: 8px; height: 8px; border-bottom: 2px solid #000; border-left: 2px solid #000; position: absolute; transform: rotate(-45deg) skew(0deg); top: 12px; right: 10px; cursor: pointer;}
.slds-scope .slds-section__title-action{ background: transparent; border-top: 1px solid #dddbda !important;}
.slds-scope .slds-section:first-child .slds-section__title-action{ border-top:0px !important;}
.slds-scope .slds-section.slds-is-open .slds-section__content{ padding:15px 30px;}
</style>
<!--jQuery CDN-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!--Salesforce Lightning Design System Static Resource-->
<apex:stylesheet value="{!URLFOR($Resource.SLDS, 'assets/styles/salesforce-lightning-design-system-vf.min.css')}" />
<script>
var j$ = jQuery.noConflict();
</script>
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<!--The Salesforce Lightning Design System Wrapping Div with Scoping Class -->
<div class="minerva18">
<fieldset class="slds-box slds-theme--default slds-container">
<!-- Single Section Wrapper With Three SLDS Sections, The Wrapper Div Class must be 'Minerva18SectionGroupSingle' -->
<div class="Minerva18SectionGroupSingle" >
<div class="slds-section">
<h3 class="slds-section__title">
<button class="slds-button slds-section__title-action">
<svg aria-hidden="true" class="slds-section__title-action-icon slds-button__icon slds-button__icon--left">
<use xlink:href="{!$Resource.SLDS}/assets/icons/utility-sprite/svg/symbols.svg#switch"></use>
</svg>Accounts</button>
</h3>
<div class="slds-section__content">
<apex:outputPanel id="table">
<table class="slds-table slds-table_cell-buffer slds-table_bordered" >
<thead>
<tr >
<th class="" scope="col">
<div class="slds-truncate" title="Name">Name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Account Number">Account Number</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Phone">Phone</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Industry">Industry</div>
</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!ListOfAccounts}" var="con">
<tr class="slds-hint-parent">
<td data-label="Account Number" >
<div class="slds-truncate" title="Account Number"> <Apex:outputfield value="{!con.AccountNumber}"/></div>
</td>
<td data-label="Phone">
<div class="slds-truncate" title="Phone"> <apex:outputfield value="{!con.Phone}"/></div>
</td>
<td data-label="Industry">
<div class="slds-truncate" title="Industry"> <apex:outputfield value="{!con.Industry}"/></div>
</td>
</tr>
</apex:repeat>
</tbody>
</table>
<apex:actionSupport event="onchange" action="{!contactNames}" reRender="table"/>
</apex:outputPanel>
</div>
</div>
</div>
<!-- Single Section Wrapper End-->
</fieldset>
<fieldset class="slds-box slds-theme--default slds-container">
<div class="Minerva18SectionGroupSingle" >
<div class="slds-section">
<h3 class="slds-section__title">
<button class="slds-button slds-section__title-action">
<svg aria-hidden="true" class="slds-section__title-action-icon slds-button__icon slds-button__icon--left">
<use xlink:href="{!$Resource.SLDS}/assets/icons/utility-sprite/svg/symbols.svg#switch"></use>
</svg>
Related contacts
</button>
</h3>
<div class="slds-section__content">
<p>
Hello...
</p>
</div>
</div>
</div>
</fieldset>
</div>
<script>
/*SLDS Sections*/
j$('.slds-section__content').hide();
j$('.slds-section__title').find('button').find('svg').css('transition', '0.3s');
j$('.slds-section__title').click(function(){
if(j$(this).parent().parent().hasClass('Minerva18SectionGroupSingle')){
if(j$(this).parent().hasClass('slds-is-open')){
j$(this).parent().removeClass('slds-is-open');
j$(this).parent().find('.slds-section__content').hide();
}
else{
j$(this).parent().parent().find('.slds-section').removeClass('slds-is-open');
j$(this).parent().parent().find('.slds-section__content').hide();
j$(this).parent().toggleClass('slds-is-open');
j$(this).parent().find('.slds-section__content').show();
}
}
else{
j$(this).parent().toggleClass('slds-is-open');
if(j$(this).parent().hasClass('slds-is-open')){
j$(this).parent().find('.slds-section__content').show();
}else{
j$(this).parent().find('.slds-section__content').hide();
}
}
});
/*SLDS Sections*/
</script>
</html>
</apex:page>
Thanks & Regards!!
Rishabh Rathor
Plz Help me ASAP.
========Apex Controller=============
public class AccordianCntrl {
public String selectedaccountId { get; set; }
public List<Contact> Contacts{get;set;}
public AccordianCntrl(){
Contacts = new List<Contact>();
}
public List<Account> getListOfAccounts()
{
List<Account> AccountList = [select id,Name,Phone,AccountNumber,Industry from Account Limit 10] ;
return AccountList;
}
// Return Accounts
public pagereference contactNames()
{
system.debug('id '+selectedaccountId);
Contacts = [Select FirstName, LastName, Email , Phone From Contact where Accountid=:selectedaccountId];
//List<Contact> results1 = [Select FirstName, LastName, Email , Phone From Contact ];
System.debug(Contacts);
return null;
}
}
========VF Page===================
<apex:page controller="AccordianCntrl" docType="html-5.0" standardStylesheets="true" showHeader="false">
<apex:slds />
<style>
.slds-scope .slds-section { position: relative; margin: 0px;}
.slds-scope .slds-section:after { content: ""; width: 8px; height: 8px; border-bottom: 2px solid #000; border-left: 2px solid #000; position: absolute; transform: rotate(-135deg) skew(0deg); top: 13px; left: 12px; cursor: pointer;}
.slds-scope .slds-section.slds-is-open:after { content: ""; width: 8px; height: 8px; border-bottom: 2px solid #000; border-left: 2px solid #000; position: absolute; transform: rotate(-45deg) skew(0deg); top: 12px; right: 10px; cursor: pointer;}
.slds-scope .slds-section__title-action{ background: transparent; border-top: 1px solid #dddbda !important;}
.slds-scope .slds-section:first-child .slds-section__title-action{ border-top:0px !important;}
.slds-scope .slds-section.slds-is-open .slds-section__content{ padding:15px 30px;}
</style>
<!--jQuery CDN-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!--Salesforce Lightning Design System Static Resource-->
<apex:stylesheet value="{!URLFOR($Resource.SLDS, 'assets/styles/salesforce-lightning-design-system-vf.min.css')}" />
<script>
var j$ = jQuery.noConflict();
</script>
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<!--The Salesforce Lightning Design System Wrapping Div with Scoping Class -->
<div class="minerva18">
<fieldset class="slds-box slds-theme--default slds-container">
<!-- Single Section Wrapper With Three SLDS Sections, The Wrapper Div Class must be 'Minerva18SectionGroupSingle' -->
<div class="Minerva18SectionGroupSingle" >
<div class="slds-section">
<h3 class="slds-section__title">
<button class="slds-button slds-section__title-action">
<svg aria-hidden="true" class="slds-section__title-action-icon slds-button__icon slds-button__icon--left">
<use xlink:href="{!$Resource.SLDS}/assets/icons/utility-sprite/svg/symbols.svg#switch"></use>
</svg>Accounts</button>
</h3>
<div class="slds-section__content">
<apex:outputPanel id="table">
<table class="slds-table slds-table_cell-buffer slds-table_bordered" >
<thead>
<tr >
<th class="" scope="col">
<div class="slds-truncate" title="Name">Name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Account Number">Account Number</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Phone">Phone</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Industry">Industry</div>
</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!ListOfAccounts}" var="con">
<tr class="slds-hint-parent">
<td data-label="Account Number" >
<div class="slds-truncate" title="Account Number"> <Apex:outputfield value="{!con.AccountNumber}"/></div>
</td>
<td data-label="Phone">
<div class="slds-truncate" title="Phone"> <apex:outputfield value="{!con.Phone}"/></div>
</td>
<td data-label="Industry">
<div class="slds-truncate" title="Industry"> <apex:outputfield value="{!con.Industry}"/></div>
</td>
</tr>
</apex:repeat>
</tbody>
</table>
<apex:actionSupport event="onchange" action="{!contactNames}" reRender="table"/>
</apex:outputPanel>
</div>
</div>
</div>
<!-- Single Section Wrapper End-->
</fieldset>
<fieldset class="slds-box slds-theme--default slds-container">
<div class="Minerva18SectionGroupSingle" >
<div class="slds-section">
<h3 class="slds-section__title">
<button class="slds-button slds-section__title-action">
<svg aria-hidden="true" class="slds-section__title-action-icon slds-button__icon slds-button__icon--left">
<use xlink:href="{!$Resource.SLDS}/assets/icons/utility-sprite/svg/symbols.svg#switch"></use>
</svg>
Related contacts
</button>
</h3>
<div class="slds-section__content">
<p>
Hello...
</p>
</div>
</div>
</div>
</fieldset>
</div>
<script>
/*SLDS Sections*/
j$('.slds-section__content').hide();
j$('.slds-section__title').find('button').find('svg').css('transition', '0.3s');
j$('.slds-section__title').click(function(){
if(j$(this).parent().parent().hasClass('Minerva18SectionGroupSingle')){
if(j$(this).parent().hasClass('slds-is-open')){
j$(this).parent().removeClass('slds-is-open');
j$(this).parent().find('.slds-section__content').hide();
}
else{
j$(this).parent().parent().find('.slds-section').removeClass('slds-is-open');
j$(this).parent().parent().find('.slds-section__content').hide();
j$(this).parent().toggleClass('slds-is-open');
j$(this).parent().find('.slds-section__content').show();
}
}
else{
j$(this).parent().toggleClass('slds-is-open');
if(j$(this).parent().hasClass('slds-is-open')){
j$(this).parent().find('.slds-section__content').show();
}else{
j$(this).parent().find('.slds-section__content').hide();
}
}
});
/*SLDS Sections*/
</script>
</html>
</apex:page>
Thanks & Regards!!
Rishabh Rathor
Plz Help me ASAP.
- rishabh rathor 18
- November 30, 2019
- Like
- 0
How to show list of related contacts on the selection of an account record From Drop Down picklist of accounts
Here It is my code:-
==========Apex Controller===================
public class DropdownContrl {
@AuraEnabled
Public static String accountId{get;set;}
@Auraenabled
public static List<Account> getAccounts()
{
List<Account> accList = new List<Account>();
accList = [SELECT Id, Name FROM Account];
system.debug('Accounts '+accList);
return accList;
}
@Auraenabled
public static List<Contact> getContact(List<Id> accountIds)
{
System.debug('Acclount Id '+accountIds);
List<Contact> conlst = new List<Contact>();
conlst = [SELECT FirstName, LastName,Email,Phone from Contact WHERE
accountId in : accountIds];
system.debug('contacts '+conlst);
return conlst;
}
}
=========Component=========
<aura:component controller="DropdownContrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
<aura:attribute name="Accounts" type="List" />
<aura:attribute name="Contacts" type="List" />
<aura:handler name="init" value="{!this}" action="{!c.doinit}" />
<h2 class="slds-page-header__title">Display Account List</h2>
<lightning:layout>
<article class="slds-card slds-m-bottom_medium">
<div class="slds-media__body">
<div>
<lightning:layoutitem>
<lightning:select aura:id="act" name="selectAccount" >
<option value="" label="--None--">
</option>
<aura:iteration items="{!v.Accounts}" var="item" >
<option value="{!item.Id}" label="{!item.Name}" >
{!item.Name}
</option>
</aura:iteration>
</lightning:select>
</lightning:layoutitem>
</div>
</div>
</article>
</lightning:layout>
<div>
<lightning:button label="Get Contacts" title="Neutral action" onclick="{! c.getcontacts }"/>
<!-- <button class="slds-button slds-button_brand" style="height:30px;width: 50px;" label ="Get Contacts" onclick="{!c.getcontacts}" ></button>-->
</div>
<h2 class="slds-page-header__title">Related Contacts</h2>
<div aura:id="ContactRecordViewController" class="slds">
<table class="slds-table slds-table--bordered slds-table--striped">
<thead>
<tr>
<th scope="col"><span class="slds-truncate">First Name</span></th>
<th scope="col"><span class="slds-truncate">Last Name</span></th>
<th scope="col"><span class="slds-truncate">Email</span></th>
<th scope="col"><span class="slds-truncate">Phone</span></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.Contacts}" var="con" indexVar="index">
<tr>
<td data-index="{!index}">{!con.FirstName}</td>
<td data-index="{!index}">{!con.LastName}</td>
<td data-index="{!index}">{!con.Email}</td>
<td data-index="{!index}">{!con.Phone}</td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</aura:component>
=============Helper==============
({
fetchContacts : function(component, event, helper) {
var action = component.get("c.getContact");
console.log(action);
var accountId = component.get("v.recordId");
console.log(accountId);
action.setParams({
accountIds: accountId
});
action.setCallback(this, function(response) {
var state = response.getState();
if(state === 'SUCCESS') {
var contactList = response.getReturnValue();
component.set("v.Contacts",contactList);
console.log(contactList);
}
else {
alert('Error in getting data');
}
});
$A.enqueueAction(action);
},
})
=====================Js controller============
({
doinit : function(component, event, helper) {
console.log('load');
var action = component.get('c.getAccounts');
action.setCallback(this, function(response){
var result =response.getReturnValue();
console.log(result);
component.set("v.Accounts",result);
console.log(result);
});
$A.enqueueAction(action);
},
getcontacts : function(component, event, helper)
{
helper.fetchContacts(component, event, helper);
} ,
})
==========Apex Controller===================
public class DropdownContrl {
@AuraEnabled
Public static String accountId{get;set;}
@Auraenabled
public static List<Account> getAccounts()
{
List<Account> accList = new List<Account>();
accList = [SELECT Id, Name FROM Account];
system.debug('Accounts '+accList);
return accList;
}
@Auraenabled
public static List<Contact> getContact(List<Id> accountIds)
{
System.debug('Acclount Id '+accountIds);
List<Contact> conlst = new List<Contact>();
conlst = [SELECT FirstName, LastName,Email,Phone from Contact WHERE
accountId in : accountIds];
system.debug('contacts '+conlst);
return conlst;
}
}
=========Component=========
<aura:component controller="DropdownContrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
<aura:attribute name="Accounts" type="List" />
<aura:attribute name="Contacts" type="List" />
<aura:handler name="init" value="{!this}" action="{!c.doinit}" />
<h2 class="slds-page-header__title">Display Account List</h2>
<lightning:layout>
<article class="slds-card slds-m-bottom_medium">
<div class="slds-media__body">
<div>
<lightning:layoutitem>
<lightning:select aura:id="act" name="selectAccount" >
<option value="" label="--None--">
</option>
<aura:iteration items="{!v.Accounts}" var="item" >
<option value="{!item.Id}" label="{!item.Name}" >
{!item.Name}
</option>
</aura:iteration>
</lightning:select>
</lightning:layoutitem>
</div>
</div>
</article>
</lightning:layout>
<div>
<lightning:button label="Get Contacts" title="Neutral action" onclick="{! c.getcontacts }"/>
<!-- <button class="slds-button slds-button_brand" style="height:30px;width: 50px;" label ="Get Contacts" onclick="{!c.getcontacts}" ></button>-->
</div>
<h2 class="slds-page-header__title">Related Contacts</h2>
<div aura:id="ContactRecordViewController" class="slds">
<table class="slds-table slds-table--bordered slds-table--striped">
<thead>
<tr>
<th scope="col"><span class="slds-truncate">First Name</span></th>
<th scope="col"><span class="slds-truncate">Last Name</span></th>
<th scope="col"><span class="slds-truncate">Email</span></th>
<th scope="col"><span class="slds-truncate">Phone</span></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.Contacts}" var="con" indexVar="index">
<tr>
<td data-index="{!index}">{!con.FirstName}</td>
<td data-index="{!index}">{!con.LastName}</td>
<td data-index="{!index}">{!con.Email}</td>
<td data-index="{!index}">{!con.Phone}</td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</aura:component>
=============Helper==============
({
fetchContacts : function(component, event, helper) {
var action = component.get("c.getContact");
console.log(action);
var accountId = component.get("v.recordId");
console.log(accountId);
action.setParams({
accountIds: accountId
});
action.setCallback(this, function(response) {
var state = response.getState();
if(state === 'SUCCESS') {
var contactList = response.getReturnValue();
component.set("v.Contacts",contactList);
console.log(contactList);
}
else {
alert('Error in getting data');
}
});
$A.enqueueAction(action);
},
})
=====================Js controller============
({
doinit : function(component, event, helper) {
console.log('load');
var action = component.get('c.getAccounts');
action.setCallback(this, function(response){
var result =response.getReturnValue();
console.log(result);
component.set("v.Accounts",result);
console.log(result);
});
$A.enqueueAction(action);
},
getcontacts : function(component, event, helper)
{
helper.fetchContacts(component, event, helper);
} ,
})
- rishabh rathor 18
- November 26, 2019
- Like
- 0
Display list of Account in picklist and when account gets selected its related contacts should be displayed in table
Here It is my code:-
======Apex Controller========
public with sharing class AccountController1_picklistrendering { public String account { get; set; } public String selectedAccId{get;set;} public String selectedConId{get;set;} public List<SelectOption> getAccountNames() { List<SelectOption> accOptions= new List<SelectOption>(); accOptions.add( new SelectOption('','--Select--')); for( Account acc : [select Id,name from Account ] ) { accOptions.add( new SelectOption(acc.Id,acc.name)); } return accOptions; } public List<SelectContact> getContactNames() { System.debug('Entered ContactNames account id...........'+selectedAccId ); if(selectContact != null) contact con = [select name from contact where accountid=:selectedAccId ]; return con; } }
=============VF Page==================
<apex:page controller="AccountController1_picklistrendering"> <apex:form > <apex:pageBlock title="Account Name"> Account Names <apex:selectList value="{!selectedAccId}" size="1"> <apex:selectOptions value="{!AccountNames}"/> <apex:actionSupport event="onchange" reRender="a"/> </apex:selectList> <br/><br/> Related Contact Names <apex:pageBlockTable value="{!ContactNames}" var="items"> <apex:column value="{!items.name}"/> </apex:pageBlockTable> <apex:selectList value="{!selectedConId}" size="1" id="a"> <apex:selectOptions value="{!ContactNames}" /> </apex:selectList> </apex:pageBlock> </apex:form> </apex:page>
======Apex Controller========
public with sharing class AccountController1_picklistrendering { public String account { get; set; } public String selectedAccId{get;set;} public String selectedConId{get;set;} public List<SelectOption> getAccountNames() { List<SelectOption> accOptions= new List<SelectOption>(); accOptions.add( new SelectOption('','--Select--')); for( Account acc : [select Id,name from Account ] ) { accOptions.add( new SelectOption(acc.Id,acc.name)); } return accOptions; } public List<SelectContact> getContactNames() { System.debug('Entered ContactNames account id...........'+selectedAccId ); if(selectContact != null) contact con = [select name from contact where accountid=:selectedAccId ]; return con; } }
=============VF Page==================
<apex:page controller="AccountController1_picklistrendering"> <apex:form > <apex:pageBlock title="Account Name"> Account Names <apex:selectList value="{!selectedAccId}" size="1"> <apex:selectOptions value="{!AccountNames}"/> <apex:actionSupport event="onchange" reRender="a"/> </apex:selectList> <br/><br/> Related Contact Names <apex:pageBlockTable value="{!ContactNames}" var="items"> <apex:column value="{!items.name}"/> </apex:pageBlockTable> <apex:selectList value="{!selectedConId}" size="1" id="a"> <apex:selectOptions value="{!ContactNames}" /> </apex:selectList> </apex:pageBlock> </apex:form> </apex:page>
- rishabh rathor 18
- November 23, 2019
- Like
- 0
I am stucking on confuguration setup for google adwords and analytics to Salesforce..I got a link but that was too getting me confused..I have passed GCILD field and GA visitor Id in the web to lead custom firm with javascript support..but how to get that
I am stucking on confuguration setup for google adwords and analytics to Salesforce..I got a link but that was too getting me confused..I have passed GCILD field and GA visitor Id in the web to lead custom firm with javascript support..but how to get that work so that I can receive conversions.
- rishabh rathor 18
- November 20, 2019
- Like
- 0
The pardot is commevted to google adwords and google analytics but the I am not getting importing of salesforce conversions in GA and vice versa.I have setup GCLID hidden field to the pardot forms but unable to capture this id If anyone is having idea to
The pardot is commevted to google adwords and google analytics but the I am not getting importing of salesforce conversions in GA and vice versa..I have setup GCLID hidden field to the pardot forms but unable to capture this id..If anyone is having idea to setup onversions amd handling GCLID in web to lead form then pls tell me..
- rishabh rathor 18
- November 20, 2019
- Like
- 0
Hi , How to import selected records using lightning component
How to import selected records using lightning component.
- rishabh rathor 18
- September 17, 2019
- Like
- 0
I want to show dynamic picklist of Objects and its field which is done but i m facing issue that is How to use add row and delete row functionality in vf page.
Here it is my code:-
==========controller===========
public class Dynamic_Table {
public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public String selectedObject {get; set;}
public String selectedField {get; set;}
Public Dynamic_Table()
{
selectedObject = 'account';
}
public List<SelectOption> getObjectNames()
{
List<SelectOption> objNames = new List<SelectOption>();
List<String> entities = new List<String>(schemaMap.keySet());
entities.sort();
for(String name : entities)
{
objNames.add(new SelectOption(name,name));
}
return objNames;
}
public List<SelectOption> getObjectFields()
{
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
Map<String, Schema.SObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
List<SelectOption> fieldNames = new List<SelectOption>();
for (String fieldName: fieldMap.keySet())
{
fieldNames.add(new SelectOption(fieldName,fieldName));
//fieldMap.get(fieldName).getDescribe().getLabel();//It provides to get the object fields label.
}
return fieldNames;
}
}
===========vf page==============
<apex:page controller="Dynamic_Table" lightningStylesheets="true">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<apex:pageBlockSectionItem >
<apex:outputlabel value="Object Names :"/>
<apex:actionRegion >
<apex:selectList value="{!selectedObject}" size="1">
<apex:selectOptions value="{!ObjectNames}"/>
<apex:actionSupport event="onchange" rerender="myFields"/>
</apex:selectList>
</apex:actionRegion>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputlabel value="Field Names :"/>
<apex:outputPanel id="myFields">
<apex:actionRegion >
<apex:selectList value="{!selectedField}" size="1">
<apex:selectOptions value="{!ObjectFields}"/>
</apex:selectList>
</apex:actionRegion>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
==========controller===========
public class Dynamic_Table {
public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public String selectedObject {get; set;}
public String selectedField {get; set;}
Public Dynamic_Table()
{
selectedObject = 'account';
}
public List<SelectOption> getObjectNames()
{
List<SelectOption> objNames = new List<SelectOption>();
List<String> entities = new List<String>(schemaMap.keySet());
entities.sort();
for(String name : entities)
{
objNames.add(new SelectOption(name,name));
}
return objNames;
}
public List<SelectOption> getObjectFields()
{
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
Map<String, Schema.SObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
List<SelectOption> fieldNames = new List<SelectOption>();
for (String fieldName: fieldMap.keySet())
{
fieldNames.add(new SelectOption(fieldName,fieldName));
//fieldMap.get(fieldName).getDescribe().getLabel();//It provides to get the object fields label.
}
return fieldNames;
}
}
===========vf page==============
<apex:page controller="Dynamic_Table" lightningStylesheets="true">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<apex:pageBlockSectionItem >
<apex:outputlabel value="Object Names :"/>
<apex:actionRegion >
<apex:selectList value="{!selectedObject}" size="1">
<apex:selectOptions value="{!ObjectNames}"/>
<apex:actionSupport event="onchange" rerender="myFields"/>
</apex:selectList>
</apex:actionRegion>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputlabel value="Field Names :"/>
<apex:outputPanel id="myFields">
<apex:actionRegion >
<apex:selectList value="{!selectedField}" size="1">
<apex:selectOptions value="{!ObjectFields}"/>
</apex:selectList>
</apex:actionRegion>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
- rishabh rathor 18
- August 26, 2019
- Like
- 0
how to get email template id in select option
here its my code:-
// Apex controller
public class Filtered_Contacts {
public List<opportunity> oppList{get;set;}
//public string stagename{get;set;}
public Boolean show{set;get;}
public Boolean showbtn{set;get;}
public opportunity opp{get;set;}
public List<WrapperClass> wrapList {get; set;}
public String selectedTemplateName { public get; public set; }
// counstructor
public Filtered_Contacts(){
oppList = new List<opportunity>();
opp = new opportunity();
show =false;
showbtn=false;
wrapList = new List<WrapperClass>();
}
public pageReference fetchopp(){
show =true;
showbtn=true;
system.debug('====='+show);
oppList = New List<opportunity>();
system.debug('====='+show);
for(Opportunity op : [select id, Name , StageName from opportunity where AccountId=:opp.AccountId and StageName=:opp.StageName]) {
wrapList.add(new WrapperClass(op));
system.debug('wrapList'+wrapList);
}
return null;
}
public PageReference sendEmail() {
List<Opportunity> selectedopportunity = new List<Opportunity>();
for(WrapperClass oppt : wrapList) {
if(oppt.selected == true) {
selectedopportunity.add(oppt.opps);
}
}
System.debug('These are the selected opportunities…'+selectedopportunity);
String body = '';
body = '<table border="1" style="border-collapse: collapse"><tr><th>id</th><th>Name</th></tr>';
for(Opportunity oppp : selectedopportunity) {
String url='<a href="'+system.Url.Getsalesforcebaseurl().toexternalform()+'/'+oppp.Id+'"> '+oppp.Name+'</a>';
String name = oppp.Name;
body += '<tr><td>' + url + '</td><td>' + name + '</td></tr>' ;
}
body += '</table>';
system.debug('body '+body);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'rishabhrathor05@gmail.com'};
system.debug(toAddresses);
mail.setToAddresses(toAddresses);
mail.setReplyTo('rishabhrathor05@gmail.com');
mail.setSenderDisplayName('Salesforce');
mail.setSubject( 'See Link');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Hello');
// mail.setTemplateId(t.id);
mail.HtmlBody = body;
system.debug('======='+body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
List<Messaging.SendEmailResult> results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
if(results[0].success){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.CONFIRM, 'Success!'));
}
return null;
}
public List<SelectOption> getMyPersonalTemplateOptions() {
showbtn=true;
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('','-None-'));
for (EmailTemplate t : [select Id,Name,Body from EmailTemplate ])
{
options.add(new SelectOption(t.Id,t.Name));
}
system.debug('========'+options);
return options;
}
public class WrapperClass {
public Opportunity opps {get; set;}
public Boolean selected {get; set;}
public WrapperClass(Opportunity op) {
opps = op;
selected = false;
}
}
}
<!--- vf page--->
<apex:page Controller="Filtered_Contacts" lightningStylesheets="true" sidebar="false">
<script>
function checkAll(cb,cbid)
{
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf(cbid)!=-1){
inputElem[i].checked = cb.checked;
}
}
}
</script>
<article class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__figure">
<span class="slds-icon_container slds-icon-standard-account" title="Opportunity">
<svg class="slds-icon slds-icon_small" aria-hidden="true">
<!-- <use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#account"></use>-->
</svg>
<span class="slds-assistive-text">Opportunity</span>
</span>
</div>
<div class="slds-media__body">
<h2 class="slds-card__header-title">
<a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Opportunity">
<span>Opportunities</span>
</a>
</h2>
</div>
</header>
</div>
</article>
<apex:slds />
<apex:form id="theform">
<div class="demo-only demo-only--sizing slds-grid slds-wrap slds-m-top_large">
<label ><strong> Account Name </strong></label>
<div class="slds-size_1-of-4">
<!-- <apex:outputLabel value="{!$ObjectType.Account.fields['Name'].label}" /> -->
<apex:inputField value="{!opp.AccountId}" />
</div>
<label ><strong> Stage Name </strong></label>
<div class="slds-size_1-of-4">
<apex:inputfield value="{!opp.StageName}" />
</div>
<label><strong> Template Name </strong></label>
<div class="slds-size_1-of-4">
<apex:selectList value="{!selectedTemplateName}" multiselect="false" size="1">
<apex:selectOptions value="{!myPersonalTemplateOptions}"/>
</apex:selectList>
</div>
</div><br/>
<div class="slds-grid">
<div class="slds-size_1-of-12">
<apex:commandButton action="{!fetchopp}" value="Search" styleClass="slds-button slds-button_brand"/>
</div>
<div class="slds-size_1-of-12">
<apex:outputPanel rendered="{!showbtn}" >
<apex:commandButton action="{!sendEmail}" value="Send Email" styleClass="slds-button slds-button_brand"/>
</apex:outputPanel>
</div>
</div>
<div class="slds-p-top_small">
<apex:outputPanel rendered="{!show}">
<table class="slds-table slds-table_cell-buffer slds-table_bordered slds-p-top_small" >
<thead>
<tr>
<th class="" scope="col">
<div class="slds-truncate" >
<input type="checkbox" value="" onclick="checkAll(this,'checkedone')"/>
</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" >Id</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Last Name">Opportunity Name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Email">Stage </div>
</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!wrapList}" var="con">
<tr class="slds-hint-parent">
<td><apex:inputCheckbox value="{!con.selected}" id="checkedone"/></td>
<td data-label="Id" >
<div class="slds-truncate" title="Id"><apex:outputField value="{!con.opps.Id}"/> </div>
</td>
<td data-label="Opportunity Name" >
<div class="slds-truncate" title=" Opportunity Name"> <Apex:outputfield value="{!con.opps.Name}"/></div>
</td>
<td data-label="Stage Name">
<div class="slds-truncate" title="Stage Name"> <apex:outputfield value="{!con.opps.StageName}"/></div>
</td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:outputPanel>
</div>
</apex:form>
</apex:page>
// Apex controller
public class Filtered_Contacts {
public List<opportunity> oppList{get;set;}
//public string stagename{get;set;}
public Boolean show{set;get;}
public Boolean showbtn{set;get;}
public opportunity opp{get;set;}
public List<WrapperClass> wrapList {get; set;}
public String selectedTemplateName { public get; public set; }
// counstructor
public Filtered_Contacts(){
oppList = new List<opportunity>();
opp = new opportunity();
show =false;
showbtn=false;
wrapList = new List<WrapperClass>();
}
public pageReference fetchopp(){
show =true;
showbtn=true;
system.debug('====='+show);
oppList = New List<opportunity>();
system.debug('====='+show);
for(Opportunity op : [select id, Name , StageName from opportunity where AccountId=:opp.AccountId and StageName=:opp.StageName]) {
wrapList.add(new WrapperClass(op));
system.debug('wrapList'+wrapList);
}
return null;
}
public PageReference sendEmail() {
List<Opportunity> selectedopportunity = new List<Opportunity>();
for(WrapperClass oppt : wrapList) {
if(oppt.selected == true) {
selectedopportunity.add(oppt.opps);
}
}
System.debug('These are the selected opportunities…'+selectedopportunity);
String body = '';
body = '<table border="1" style="border-collapse: collapse"><tr><th>id</th><th>Name</th></tr>';
for(Opportunity oppp : selectedopportunity) {
String url='<a href="'+system.Url.Getsalesforcebaseurl().toexternalform()+'/'+oppp.Id+'"> '+oppp.Name+'</a>';
String name = oppp.Name;
body += '<tr><td>' + url + '</td><td>' + name + '</td></tr>' ;
}
body += '</table>';
system.debug('body '+body);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'rishabhrathor05@gmail.com'};
system.debug(toAddresses);
mail.setToAddresses(toAddresses);
mail.setReplyTo('rishabhrathor05@gmail.com');
mail.setSenderDisplayName('Salesforce');
mail.setSubject( 'See Link');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Hello');
// mail.setTemplateId(t.id);
mail.HtmlBody = body;
system.debug('======='+body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
List<Messaging.SendEmailResult> results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
if(results[0].success){
ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.CONFIRM, 'Success!'));
}
return null;
}
public List<SelectOption> getMyPersonalTemplateOptions() {
showbtn=true;
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('','-None-'));
for (EmailTemplate t : [select Id,Name,Body from EmailTemplate ])
{
options.add(new SelectOption(t.Id,t.Name));
}
system.debug('========'+options);
return options;
}
public class WrapperClass {
public Opportunity opps {get; set;}
public Boolean selected {get; set;}
public WrapperClass(Opportunity op) {
opps = op;
selected = false;
}
}
}
<!--- vf page--->
<apex:page Controller="Filtered_Contacts" lightningStylesheets="true" sidebar="false">
<script>
function checkAll(cb,cbid)
{
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++)
{
if(inputElem[i].id.indexOf(cbid)!=-1){
inputElem[i].checked = cb.checked;
}
}
}
</script>
<article class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__figure">
<span class="slds-icon_container slds-icon-standard-account" title="Opportunity">
<svg class="slds-icon slds-icon_small" aria-hidden="true">
<!-- <use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#account"></use>-->
</svg>
<span class="slds-assistive-text">Opportunity</span>
</span>
</div>
<div class="slds-media__body">
<h2 class="slds-card__header-title">
<a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Opportunity">
<span>Opportunities</span>
</a>
</h2>
</div>
</header>
</div>
</article>
<apex:slds />
<apex:form id="theform">
<div class="demo-only demo-only--sizing slds-grid slds-wrap slds-m-top_large">
<label ><strong> Account Name </strong></label>
<div class="slds-size_1-of-4">
<!-- <apex:outputLabel value="{!$ObjectType.Account.fields['Name'].label}" /> -->
<apex:inputField value="{!opp.AccountId}" />
</div>
<label ><strong> Stage Name </strong></label>
<div class="slds-size_1-of-4">
<apex:inputfield value="{!opp.StageName}" />
</div>
<label><strong> Template Name </strong></label>
<div class="slds-size_1-of-4">
<apex:selectList value="{!selectedTemplateName}" multiselect="false" size="1">
<apex:selectOptions value="{!myPersonalTemplateOptions}"/>
</apex:selectList>
</div>
</div><br/>
<div class="slds-grid">
<div class="slds-size_1-of-12">
<apex:commandButton action="{!fetchopp}" value="Search" styleClass="slds-button slds-button_brand"/>
</div>
<div class="slds-size_1-of-12">
<apex:outputPanel rendered="{!showbtn}" >
<apex:commandButton action="{!sendEmail}" value="Send Email" styleClass="slds-button slds-button_brand"/>
</apex:outputPanel>
</div>
</div>
<div class="slds-p-top_small">
<apex:outputPanel rendered="{!show}">
<table class="slds-table slds-table_cell-buffer slds-table_bordered slds-p-top_small" >
<thead>
<tr>
<th class="" scope="col">
<div class="slds-truncate" >
<input type="checkbox" value="" onclick="checkAll(this,'checkedone')"/>
</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" >Id</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Last Name">Opportunity Name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Email">Stage </div>
</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!wrapList}" var="con">
<tr class="slds-hint-parent">
<td><apex:inputCheckbox value="{!con.selected}" id="checkedone"/></td>
<td data-label="Id" >
<div class="slds-truncate" title="Id"><apex:outputField value="{!con.opps.Id}"/> </div>
</td>
<td data-label="Opportunity Name" >
<div class="slds-truncate" title=" Opportunity Name"> <Apex:outputfield value="{!con.opps.Name}"/></div>
</td>
<td data-label="Stage Name">
<div class="slds-truncate" title="Stage Name"> <apex:outputfield value="{!con.opps.StageName}"/></div>
</td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:outputPanel>
</div>
</apex:form>
</apex:page>
- rishabh rathor 18
- September 16, 2020
- Like
- 0
How to show list of related contacts on the selection of an account record From Drop Down picklist of accounts
Here It is my code:-
==========Apex Controller===================
public class DropdownContrl {
@AuraEnabled
Public static String accountId{get;set;}
@Auraenabled
public static List<Account> getAccounts()
{
List<Account> accList = new List<Account>();
accList = [SELECT Id, Name FROM Account];
system.debug('Accounts '+accList);
return accList;
}
@Auraenabled
public static List<Contact> getContact(List<Id> accountIds)
{
System.debug('Acclount Id '+accountIds);
List<Contact> conlst = new List<Contact>();
conlst = [SELECT FirstName, LastName,Email,Phone from Contact WHERE
accountId in : accountIds];
system.debug('contacts '+conlst);
return conlst;
}
}
=========Component=========
<aura:component controller="DropdownContrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
<aura:attribute name="Accounts" type="List" />
<aura:attribute name="Contacts" type="List" />
<aura:handler name="init" value="{!this}" action="{!c.doinit}" />
<h2 class="slds-page-header__title">Display Account List</h2>
<lightning:layout>
<article class="slds-card slds-m-bottom_medium">
<div class="slds-media__body">
<div>
<lightning:layoutitem>
<lightning:select aura:id="act" name="selectAccount" >
<option value="" label="--None--">
</option>
<aura:iteration items="{!v.Accounts}" var="item" >
<option value="{!item.Id}" label="{!item.Name}" >
{!item.Name}
</option>
</aura:iteration>
</lightning:select>
</lightning:layoutitem>
</div>
</div>
</article>
</lightning:layout>
<div>
<lightning:button label="Get Contacts" title="Neutral action" onclick="{! c.getcontacts }"/>
<!-- <button class="slds-button slds-button_brand" style="height:30px;width: 50px;" label ="Get Contacts" onclick="{!c.getcontacts}" ></button>-->
</div>
<h2 class="slds-page-header__title">Related Contacts</h2>
<div aura:id="ContactRecordViewController" class="slds">
<table class="slds-table slds-table--bordered slds-table--striped">
<thead>
<tr>
<th scope="col"><span class="slds-truncate">First Name</span></th>
<th scope="col"><span class="slds-truncate">Last Name</span></th>
<th scope="col"><span class="slds-truncate">Email</span></th>
<th scope="col"><span class="slds-truncate">Phone</span></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.Contacts}" var="con" indexVar="index">
<tr>
<td data-index="{!index}">{!con.FirstName}</td>
<td data-index="{!index}">{!con.LastName}</td>
<td data-index="{!index}">{!con.Email}</td>
<td data-index="{!index}">{!con.Phone}</td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</aura:component>
=============Helper==============
({
fetchContacts : function(component, event, helper) {
var action = component.get("c.getContact");
console.log(action);
var accountId = component.get("v.recordId");
console.log(accountId);
action.setParams({
accountIds: accountId
});
action.setCallback(this, function(response) {
var state = response.getState();
if(state === 'SUCCESS') {
var contactList = response.getReturnValue();
component.set("v.Contacts",contactList);
console.log(contactList);
}
else {
alert('Error in getting data');
}
});
$A.enqueueAction(action);
},
})
=====================Js controller============
({
doinit : function(component, event, helper) {
console.log('load');
var action = component.get('c.getAccounts');
action.setCallback(this, function(response){
var result =response.getReturnValue();
console.log(result);
component.set("v.Accounts",result);
console.log(result);
});
$A.enqueueAction(action);
},
getcontacts : function(component, event, helper)
{
helper.fetchContacts(component, event, helper);
} ,
})
==========Apex Controller===================
public class DropdownContrl {
@AuraEnabled
Public static String accountId{get;set;}
@Auraenabled
public static List<Account> getAccounts()
{
List<Account> accList = new List<Account>();
accList = [SELECT Id, Name FROM Account];
system.debug('Accounts '+accList);
return accList;
}
@Auraenabled
public static List<Contact> getContact(List<Id> accountIds)
{
System.debug('Acclount Id '+accountIds);
List<Contact> conlst = new List<Contact>();
conlst = [SELECT FirstName, LastName,Email,Phone from Contact WHERE
accountId in : accountIds];
system.debug('contacts '+conlst);
return conlst;
}
}
=========Component=========
<aura:component controller="DropdownContrl" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
<aura:attribute name="Accounts" type="List" />
<aura:attribute name="Contacts" type="List" />
<aura:handler name="init" value="{!this}" action="{!c.doinit}" />
<h2 class="slds-page-header__title">Display Account List</h2>
<lightning:layout>
<article class="slds-card slds-m-bottom_medium">
<div class="slds-media__body">
<div>
<lightning:layoutitem>
<lightning:select aura:id="act" name="selectAccount" >
<option value="" label="--None--">
</option>
<aura:iteration items="{!v.Accounts}" var="item" >
<option value="{!item.Id}" label="{!item.Name}" >
{!item.Name}
</option>
</aura:iteration>
</lightning:select>
</lightning:layoutitem>
</div>
</div>
</article>
</lightning:layout>
<div>
<lightning:button label="Get Contacts" title="Neutral action" onclick="{! c.getcontacts }"/>
<!-- <button class="slds-button slds-button_brand" style="height:30px;width: 50px;" label ="Get Contacts" onclick="{!c.getcontacts}" ></button>-->
</div>
<h2 class="slds-page-header__title">Related Contacts</h2>
<div aura:id="ContactRecordViewController" class="slds">
<table class="slds-table slds-table--bordered slds-table--striped">
<thead>
<tr>
<th scope="col"><span class="slds-truncate">First Name</span></th>
<th scope="col"><span class="slds-truncate">Last Name</span></th>
<th scope="col"><span class="slds-truncate">Email</span></th>
<th scope="col"><span class="slds-truncate">Phone</span></th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.Contacts}" var="con" indexVar="index">
<tr>
<td data-index="{!index}">{!con.FirstName}</td>
<td data-index="{!index}">{!con.LastName}</td>
<td data-index="{!index}">{!con.Email}</td>
<td data-index="{!index}">{!con.Phone}</td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</aura:component>
=============Helper==============
({
fetchContacts : function(component, event, helper) {
var action = component.get("c.getContact");
console.log(action);
var accountId = component.get("v.recordId");
console.log(accountId);
action.setParams({
accountIds: accountId
});
action.setCallback(this, function(response) {
var state = response.getState();
if(state === 'SUCCESS') {
var contactList = response.getReturnValue();
component.set("v.Contacts",contactList);
console.log(contactList);
}
else {
alert('Error in getting data');
}
});
$A.enqueueAction(action);
},
})
=====================Js controller============
({
doinit : function(component, event, helper) {
console.log('load');
var action = component.get('c.getAccounts');
action.setCallback(this, function(response){
var result =response.getReturnValue();
console.log(result);
component.set("v.Accounts",result);
console.log(result);
});
$A.enqueueAction(action);
},
getcontacts : function(component, event, helper)
{
helper.fetchContacts(component, event, helper);
} ,
})
- rishabh rathor 18
- November 26, 2019
- Like
- 0
Display list of Account in picklist and when account gets selected its related contacts should be displayed in table
Here It is my code:-
======Apex Controller========
public with sharing class AccountController1_picklistrendering { public String account { get; set; } public String selectedAccId{get;set;} public String selectedConId{get;set;} public List<SelectOption> getAccountNames() { List<SelectOption> accOptions= new List<SelectOption>(); accOptions.add( new SelectOption('','--Select--')); for( Account acc : [select Id,name from Account ] ) { accOptions.add( new SelectOption(acc.Id,acc.name)); } return accOptions; } public List<SelectContact> getContactNames() { System.debug('Entered ContactNames account id...........'+selectedAccId ); if(selectContact != null) contact con = [select name from contact where accountid=:selectedAccId ]; return con; } }
=============VF Page==================
<apex:page controller="AccountController1_picklistrendering"> <apex:form > <apex:pageBlock title="Account Name"> Account Names <apex:selectList value="{!selectedAccId}" size="1"> <apex:selectOptions value="{!AccountNames}"/> <apex:actionSupport event="onchange" reRender="a"/> </apex:selectList> <br/><br/> Related Contact Names <apex:pageBlockTable value="{!ContactNames}" var="items"> <apex:column value="{!items.name}"/> </apex:pageBlockTable> <apex:selectList value="{!selectedConId}" size="1" id="a"> <apex:selectOptions value="{!ContactNames}" /> </apex:selectList> </apex:pageBlock> </apex:form> </apex:page>
======Apex Controller========
public with sharing class AccountController1_picklistrendering { public String account { get; set; } public String selectedAccId{get;set;} public String selectedConId{get;set;} public List<SelectOption> getAccountNames() { List<SelectOption> accOptions= new List<SelectOption>(); accOptions.add( new SelectOption('','--Select--')); for( Account acc : [select Id,name from Account ] ) { accOptions.add( new SelectOption(acc.Id,acc.name)); } return accOptions; } public List<SelectContact> getContactNames() { System.debug('Entered ContactNames account id...........'+selectedAccId ); if(selectContact != null) contact con = [select name from contact where accountid=:selectedAccId ]; return con; } }
=============VF Page==================
<apex:page controller="AccountController1_picklistrendering"> <apex:form > <apex:pageBlock title="Account Name"> Account Names <apex:selectList value="{!selectedAccId}" size="1"> <apex:selectOptions value="{!AccountNames}"/> <apex:actionSupport event="onchange" reRender="a"/> </apex:selectList> <br/><br/> Related Contact Names <apex:pageBlockTable value="{!ContactNames}" var="items"> <apex:column value="{!items.name}"/> </apex:pageBlockTable> <apex:selectList value="{!selectedConId}" size="1" id="a"> <apex:selectOptions value="{!ContactNames}" /> </apex:selectList> </apex:pageBlock> </apex:form> </apex:page>
- rishabh rathor 18
- November 23, 2019
- Like
- 0
I want to show dynamic picklist of Objects and its field which is done but i m facing issue that is How to use add row and delete row functionality in vf page.
Here it is my code:-
==========controller===========
public class Dynamic_Table {
public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public String selectedObject {get; set;}
public String selectedField {get; set;}
Public Dynamic_Table()
{
selectedObject = 'account';
}
public List<SelectOption> getObjectNames()
{
List<SelectOption> objNames = new List<SelectOption>();
List<String> entities = new List<String>(schemaMap.keySet());
entities.sort();
for(String name : entities)
{
objNames.add(new SelectOption(name,name));
}
return objNames;
}
public List<SelectOption> getObjectFields()
{
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
Map<String, Schema.SObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
List<SelectOption> fieldNames = new List<SelectOption>();
for (String fieldName: fieldMap.keySet())
{
fieldNames.add(new SelectOption(fieldName,fieldName));
//fieldMap.get(fieldName).getDescribe().getLabel();//It provides to get the object fields label.
}
return fieldNames;
}
}
===========vf page==============
<apex:page controller="Dynamic_Table" lightningStylesheets="true">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<apex:pageBlockSectionItem >
<apex:outputlabel value="Object Names :"/>
<apex:actionRegion >
<apex:selectList value="{!selectedObject}" size="1">
<apex:selectOptions value="{!ObjectNames}"/>
<apex:actionSupport event="onchange" rerender="myFields"/>
</apex:selectList>
</apex:actionRegion>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputlabel value="Field Names :"/>
<apex:outputPanel id="myFields">
<apex:actionRegion >
<apex:selectList value="{!selectedField}" size="1">
<apex:selectOptions value="{!ObjectFields}"/>
</apex:selectList>
</apex:actionRegion>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
==========controller===========
public class Dynamic_Table {
public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public String selectedObject {get; set;}
public String selectedField {get; set;}
Public Dynamic_Table()
{
selectedObject = 'account';
}
public List<SelectOption> getObjectNames()
{
List<SelectOption> objNames = new List<SelectOption>();
List<String> entities = new List<String>(schemaMap.keySet());
entities.sort();
for(String name : entities)
{
objNames.add(new SelectOption(name,name));
}
return objNames;
}
public List<SelectOption> getObjectFields()
{
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
Map<String, Schema.SObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
List<SelectOption> fieldNames = new List<SelectOption>();
for (String fieldName: fieldMap.keySet())
{
fieldNames.add(new SelectOption(fieldName,fieldName));
//fieldMap.get(fieldName).getDescribe().getLabel();//It provides to get the object fields label.
}
return fieldNames;
}
}
===========vf page==============
<apex:page controller="Dynamic_Table" lightningStylesheets="true">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<apex:pageBlockSectionItem >
<apex:outputlabel value="Object Names :"/>
<apex:actionRegion >
<apex:selectList value="{!selectedObject}" size="1">
<apex:selectOptions value="{!ObjectNames}"/>
<apex:actionSupport event="onchange" rerender="myFields"/>
</apex:selectList>
</apex:actionRegion>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputlabel value="Field Names :"/>
<apex:outputPanel id="myFields">
<apex:actionRegion >
<apex:selectList value="{!selectedField}" size="1">
<apex:selectOptions value="{!ObjectFields}"/>
</apex:selectList>
</apex:actionRegion>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
- rishabh rathor 18
- August 26, 2019
- Like
- 0
lightning csv uploader to create accounts
Hi Team,
trying to deisgn CSV uploder in lightning component and need to display in table after uploading CSV file and on click on save button need to save account reords in data base.
Using these contoroller to create account.. help me to design lightning component
trying to deisgn CSV uploder in lightning component and need to display in table after uploading CSV file and on click on save button need to save account reords in data base.
public class PMO_CsvUploaderController { public Blob csvFileBody{get;set;} public string csvAsString{get;set;} public String[] csvFileLines{get;set;} public List<Account> Acclist{get;set;} public PMO_CsvUploaderController(){ csvFileLines = new String[]{}; Acclist = New List<Account>(); } public void importCSVFile(){ try{ csvAsString = csvFileBody.toString(); csvFileLines = csvAsString.split('\n'); for(Integer i=1;i<csvFileLines.size();i++){ Account couObj = new Account(); string[] csvRecordData = csvFileLines[i].split(','); couObj.name = csvRecordData[1] ; couObj.AccountNumber = csvRecordData[2]; couObj.Phone = csvRecordData[3]; couObj.Rating = csvRecordData[4]; /* String temp_fees=csvRecordData[3]; couObj.Course_fees__c = Decimal.valueOf(temp_fees); String temp_date=csvRecordData[4]; couObj.Course_Date__c = Date.parse(temp_date); */ Acclist.add(couObj); } insert Acclist; } catch (Exception e){ System.debug(e.getCause()); ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importing data. Please make sure input csv file is correct'); ApexPages.addMessage(errorMessage); } } }
Using these contoroller to create account.. help me to design lightning component
- bhanu_prakash
- January 04, 2019
- Like
- 0
How to upload csv file using lightning component?
Hi All,
I have requirement to upload CSV file into Salesforce using lightning component then this record will insert in Sobject records.Please guide me on this scenario.
Thanks,
Santhanam
I have requirement to upload CSV file into Salesforce using lightning component then this record will insert in Sobject records.Please guide me on this scenario.
Thanks,
Santhanam
- santhanam Arunachalam
- September 19, 2018
- Like
- 0
I want to open pdf document in lightning component
I want to open the pdf in lightning component how it can be done please help me out for this
- Shruti Vish
- April 12, 2017
- Like
- 0
Lightning force:editRecord Event handle Save
I am working with the force:editRecord event to handle the edit of a list of objects in a lightning component. I am able to return and display the list of objects each list item has an edit button that calls a function like what is displayed in this article:
https://developer.salesforce.com/docs/atlas.en-us.200.0.lightning.meta/lightning/ref_force_editRecord.htm (https://developer.salesforce.com/docs/atlas.en-us.200.0.lightning.meta/lightning/ref_force_editRecord.htm" target="_blank)
I've only been able to get this to work in a developer org if I add the component to an object page.
The problem is I need to update the list with the newley updated values but haven't been able to find any reference to handling the save event on the editRecord Modal popup. Any assistance would be great.
https://developer.salesforce.com/docs/atlas.en-us.198.0.lightning.meta/lightning/ref_force_recordSaveSuccess.htm
Here is basic example of what I am trying to do. Adding the component to the account page I can click the button edit the record and hit save. The Account compact data in the top of the page updates but what's in the component does not.
Component Code:
Component Controller Code:
Apex Controller:
https://developer.salesforce.com/docs/atlas.en-us.200.0.lightning.meta/lightning/ref_force_editRecord.htm (https://developer.salesforce.com/docs/atlas.en-us.200.0.lightning.meta/lightning/ref_force_editRecord.htm" target="_blank)
I've only been able to get this to work in a developer org if I add the component to an object page.
The problem is I need to update the list with the newley updated values but haven't been able to find any reference to handling the save event on the editRecord Modal popup. Any assistance would be great.
https://developer.salesforce.com/docs/atlas.en-us.198.0.lightning.meta/lightning/ref_force_recordSaveSuccess.htm
Here is basic example of what I am trying to do. Adding the component to the account page I can click the button edit the record and hit save. The Account compact data in the top of the page updates but what's in the component does not.
Component Code:
<aura:component controller="editRecordSimulationController" implements="force:appHostable, flexipage:availableForAllPageTypes, force:hasRecordId"> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <aura:dependency resource="markup://force:editRecord" type="EVENT" /> <aura:handler name="handleEdit" event="force:editRecord" action="{!c.doInit}" /> <aura:handler name="handleSaveSuccess" event="force:recordSaveSuccess" action="{!c.doInit}" /> <aura:attribute name="recordId" type="string" /> <aura:attribute name="accType" type="String" /> <ui:inputText label="Record Id" value="{!v.recordId}" required="true"/> <ui:button class="btn" label="Submit" press="{!c.setOutput}"/> <br /> <br /> <br /> Account Type: <ui:outputText value="{!v.accType}" /> </aura:component>
Component Controller Code:
({ doInit : function(component, event, helper) { var recordId = component.get("v.recordId"); var action = component.get("c.getTypeFromAccount"); action.setParams({ recordId: recordId }); action.setCallback(this, function(response){ var state = response.getState(); if (state === "SUCCESS") { var accType = response.getReturnValue(); component.set("v.accType", accType); } }); $A.enqueueAction(action); }, setOutput : function(component, event, helper) { var editRecordEvent = $A.get("e.force:editRecord"); editRecordEvent.setParams({ "recordId": component.get("v.recordId") }); editRecordEvent.fire(); } })
Apex Controller:
public class editRecordSimulationController { @AuraEnabled public static string getTypeFromAccount(string recordId) { Account acc = [select Type from Account Where Id = :recordId limit 1]; return acc.Type; } }
- Dave The Ghost
- January 05, 2016
- Like
- 0
Send Email to the Selected Records from the Default View Page.
Hi All,
I require an urgent help.
The requirement is that i need to provide a custom button on the Default List View Page to send an Email to the selected record's Email Id field.
The records will be selected using the Action Checkbox provided i.e. i need to check the CheckBox provided under Action column to select the records, and after selecting the records click on the Custom button to send the Email to all.
Can it be done, if yes please let me know How....Its urgent Please..
- SMaster
- November 09, 2010
- Like
- 0