-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
2Replies
I want a Wrapper class to display all the records and should save the selected records using save button
Hi Guys,
i have a vf page where 2 record types records are displaying with checkbox i should save those selected records .. can you please help me with this
here is my code i not wrote a wrapper class i am not understanding how to do it
public class custInterNeeds {
public PegasysKAM__Account_Plan__c accplan {set;get;}
public list <PegasysKAM__Customer_Need__c> cus {get;set;}
public list <PegasysKAM__Customer_Need__c> cus1 {get;set;}
public PegasysKAM__Customer_Need__c CusNeed {get;set;}
public string pid {get;set;}
public String currentRecordId {get;set;}
public PageReference saveandnew() {
return null;
}
public PageReference save() {
return null ;
}
public PageReference Cancel(){
PageReference pageRef = new PageReference('/'+'string pid');
pageRef.setRedirect(true);
return pageRef;
}
public custInterNeeds(ApexPages.StandardController controller) {
string pid = ApexPages.currentPage().getParameters().get('pid');
cus = [SELECT ID,Name, PegasysKAM__Account__c,PegasysKAM__Need__c,PegasysKAM__Status__c,PegasysKAM__Year__c,PegasysKAM__Details__c FROM PegasysKAM__Customer_Need__c
where PegasysKAM__Account__c = :ApexPages.CurrentPage().getparameters().get('pid') AND RecordType.name='Customer' ];
cus1 = [SELECT ID,Name, PegasysKAM__Account__c,PegasysKAM__Need__c,PegasysKAM__Status__c,PegasysKAM__Year__c,PegasysKAM__Details__c FROM PegasysKAM__Customer_Need__c
where PegasysKAM__Account__c = :ApexPages.CurrentPage().getparameters().get('pid') AND RecordType.name='Internal' ];
}
}
<apex:page standardController="Account_Plan__c" Extensions="custInterNeeds" >
<script type="text/avascript">
function chkselected(obj,recid)
{
var inputcheckbox = document.getelementsbytagname("input");
for(var i=0; i<inputcheckbox.length; i++){
if(inputcheckbox[i].id.indexOf(recid)!=-1){
inputcheckbox[i].checked = obj.checked;
}
}
}
</script>
<apex:form >
<apex:pageblock title="Account Plan Edit" id="block" mode="edit" >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Cancel" action="{!cancel}"/>
<apex:commandButton value="Save&New" action="{!saveandnew}"/>
</apex:pageBlockButtons>
<apex:pageblocksection title="Information">
<apex:outputField value="{!Account_Plan__c.Account__c}"/>
<apex:inputField value="{!accplan.Key_Account_Manager__c}"/>
<apex:inputField value="{!accplan.Start_Date__c}"/>
<apex:inputField value="{!accplan.Status__c}"/>
<apex:inputField value="{!accplan.End_Date__c}"/>
<apex:inputField value="{!accplan.customer_approval__c}"/>
<apex:inputField value="{!accplan.Customer_Stakeholder__c}"/>
</apex:pageblocksection>
<apex:pageBlockSection title="Details">
<apex:inputField value="{!accplan.Overall_Objective__c}" style="width:120%;"/><br/>
<apex:inputField value="{!accplan.Description__c}" style="width:150%;" />
</apex:pageBlockSection>
</apex:pageblock>
<apex:pageBlock >
<apex:pageblockSection title="Customer Needs" >
<!--<apex:outputPanel rendered="{!IF(<strong>PegasysKAM__Customer_Need__c</strong>.RecordType.Name == 'Customer')}">-->
<!-- <apex:outputPanel rendered="{!Account_Plan__c.PegasysKAM__Customer_Need__c.RecordTypeId== '01I2v000003PVvj'}" > -->
<apex:pageBlockSectionItem dataStyle="width:100%" labelStyle="width:100%" >
<apex:pageblockTable value="{!cus}" var="c" styleclass="pageblock">
<apex:column headerValue="Account" >
<apex:outputField value="{!c.Account__c}" />
</apex:column>
<apex:column headerValue="Details">
<apex:outputField value="{!c.Details__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:outputField value="{!c.Status__c}"/>
</apex:column>
<apex:column headerValue="Need">
<apex:outputField value="{!c.Need__c}"/>
</apex:column>
<apex:column headerValue="Year">
<apex:outputField value="{!c.Year__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="chkselected(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!cus}" id="inputId"/>
</apex:column>
</apex:pageblockTable>
</apex:pageBlockSectionItem>
<!-- </apex:outputpanel> -->
</apex:pageblockSection>
<!-- section for internal needs-->
<apex:pageblockSection title="Internal Needs" >
<apex:pageBlockSectionItem dataStyle="width:100%" labelStyle="width:100%" >
<apex:pageblockTable value="{!cus1}" var="c" styleclass="pageblock">
<apex:column headerValue="Account" >
<apex:outputField value="{!c.Account__c}" />
</apex:column>
<apex:column headerValue="Details">
<apex:outputField value="{!c.Details__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:outputField value="{!c.Status__c}"/>
</apex:column>
<apex:column headerValue="Need">
<apex:outputField value="{!c.Need__c}"/>
</apex:column>
<apex:column headerValue="Year">
<apex:outputField value="{!c.Year__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="chkselected(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!cus}" id="inputId"/>
</apex:column>
</apex:pageblockTable>
</apex:pageBlockSectionItem>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
i have a vf page where 2 record types records are displaying with checkbox i should save those selected records .. can you please help me with this
here is my code i not wrote a wrapper class i am not understanding how to do it
public class custInterNeeds {
public PegasysKAM__Account_Plan__c accplan {set;get;}
public list <PegasysKAM__Customer_Need__c> cus {get;set;}
public list <PegasysKAM__Customer_Need__c> cus1 {get;set;}
public PegasysKAM__Customer_Need__c CusNeed {get;set;}
public string pid {get;set;}
public String currentRecordId {get;set;}
public PageReference saveandnew() {
return null;
}
public PageReference save() {
return null ;
}
public PageReference Cancel(){
PageReference pageRef = new PageReference('/'+'string pid');
pageRef.setRedirect(true);
return pageRef;
}
public custInterNeeds(ApexPages.StandardController controller) {
string pid = ApexPages.currentPage().getParameters().get('pid');
cus = [SELECT ID,Name, PegasysKAM__Account__c,PegasysKAM__Need__c,PegasysKAM__Status__c,PegasysKAM__Year__c,PegasysKAM__Details__c FROM PegasysKAM__Customer_Need__c
where PegasysKAM__Account__c = :ApexPages.CurrentPage().getparameters().get('pid') AND RecordType.name='Customer' ];
cus1 = [SELECT ID,Name, PegasysKAM__Account__c,PegasysKAM__Need__c,PegasysKAM__Status__c,PegasysKAM__Year__c,PegasysKAM__Details__c FROM PegasysKAM__Customer_Need__c
where PegasysKAM__Account__c = :ApexPages.CurrentPage().getparameters().get('pid') AND RecordType.name='Internal' ];
}
}
<apex:page standardController="Account_Plan__c" Extensions="custInterNeeds" >
<script type="text/avascript">
function chkselected(obj,recid)
{
var inputcheckbox = document.getelementsbytagname("input");
for(var i=0; i<inputcheckbox.length; i++){
if(inputcheckbox[i].id.indexOf(recid)!=-1){
inputcheckbox[i].checked = obj.checked;
}
}
}
</script>
<apex:form >
<apex:pageblock title="Account Plan Edit" id="block" mode="edit" >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Cancel" action="{!cancel}"/>
<apex:commandButton value="Save&New" action="{!saveandnew}"/>
</apex:pageBlockButtons>
<apex:pageblocksection title="Information">
<apex:outputField value="{!Account_Plan__c.Account__c}"/>
<apex:inputField value="{!accplan.Key_Account_Manager__c}"/>
<apex:inputField value="{!accplan.Start_Date__c}"/>
<apex:inputField value="{!accplan.Status__c}"/>
<apex:inputField value="{!accplan.End_Date__c}"/>
<apex:inputField value="{!accplan.customer_approval__c}"/>
<apex:inputField value="{!accplan.Customer_Stakeholder__c}"/>
</apex:pageblocksection>
<apex:pageBlockSection title="Details">
<apex:inputField value="{!accplan.Overall_Objective__c}" style="width:120%;"/><br/>
<apex:inputField value="{!accplan.Description__c}" style="width:150%;" />
</apex:pageBlockSection>
</apex:pageblock>
<apex:pageBlock >
<apex:pageblockSection title="Customer Needs" >
<!--<apex:outputPanel rendered="{!IF(<strong>PegasysKAM__Customer_Need__c</strong>.RecordType.Name == 'Customer')}">-->
<!-- <apex:outputPanel rendered="{!Account_Plan__c.PegasysKAM__Customer_Need__c.RecordTypeId== '01I2v000003PVvj'}" > -->
<apex:pageBlockSectionItem dataStyle="width:100%" labelStyle="width:100%" >
<apex:pageblockTable value="{!cus}" var="c" styleclass="pageblock">
<apex:column headerValue="Account" >
<apex:outputField value="{!c.Account__c}" />
</apex:column>
<apex:column headerValue="Details">
<apex:outputField value="{!c.Details__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:outputField value="{!c.Status__c}"/>
</apex:column>
<apex:column headerValue="Need">
<apex:outputField value="{!c.Need__c}"/>
</apex:column>
<apex:column headerValue="Year">
<apex:outputField value="{!c.Year__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="chkselected(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!cus}" id="inputId"/>
</apex:column>
</apex:pageblockTable>
</apex:pageBlockSectionItem>
<!-- </apex:outputpanel> -->
</apex:pageblockSection>
<!-- section for internal needs-->
<apex:pageblockSection title="Internal Needs" >
<apex:pageBlockSectionItem dataStyle="width:100%" labelStyle="width:100%" >
<apex:pageblockTable value="{!cus1}" var="c" styleclass="pageblock">
<apex:column headerValue="Account" >
<apex:outputField value="{!c.Account__c}" />
</apex:column>
<apex:column headerValue="Details">
<apex:outputField value="{!c.Details__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:outputField value="{!c.Status__c}"/>
</apex:column>
<apex:column headerValue="Need">
<apex:outputField value="{!c.Need__c}"/>
</apex:column>
<apex:column headerValue="Year">
<apex:outputField value="{!c.Year__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="chkselected(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!cus}" id="inputId"/>
</apex:column>
</apex:pageblockTable>
</apex:pageBlockSectionItem>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
- veena vani
- November 27, 2019
- Like
- 0
segregarting records depending on 2 record types in VF page.
i have 2 custom objects Account_Plan__c parent and PegasysKAM__Customer_Need__c child so the child object should display all the records but it
has 2 record type which is customer and internal in a vf page the records should be displayed by segregrating with customer and internal record type where.
i am getting all the records from child object but i am not understanding how to seggregate depending on record type please help thanks in advance
has 2 record type which is customer and internal in a vf page the records should be displayed by segregrating with customer and internal record type where.
i am getting all the records from child object but i am not understanding how to seggregate depending on record type please help thanks in advance
- veena vani
- November 15, 2019
- Like
- 0
How to autopopulate the custom object fields?
Hi,
i am new to lightning as i am trying to autopopulate custom object fields... i have 2 custom objects those are LEAD and OPPORTUNITY i created an convert to opportunity quick action button in lead object. while coverting to opportunity the related lead fields should autopopulate in the lightning component.
here is my code:
component:
<aura:component controller="createOpp" implements="force:lightningQuickAction,force:hasRecordId" access="global">
<aura:attribute name="opp" type="Opportunity__c[]" default="{ 'sobjectType': 'Opportunity__c'}"/>
<aura:attribute name="lelist" type="Lead__c[]" default="{ 'sobjectType': 'Lead__c'}"/>
<aura:attribute name="er" type="boolean" default="false"/>
<aura:attribute name="op" type="Opportunity__c" default="{ 'sobjectType': 'Opportunity__c',
'Name': '',
'Agent__c': '',
'Account__c': '',
'Agreements__c': '',
'Agent_Commission__c': '',
'Delivery_Terms__c': '',
'Description__c': '',
'End_Customer__c': '',
'End_Market__c': '',
'Expected_Launch__c': '',
'Potential_Price__c': '',
'Potential_Quantity__c': '',
'ProductName__c': '',
'Project_Type__c': '',
'Product_Specifications__c': '',
'UOM__c': '',}"/>
<aura:attribute name="lea" type="Lead__c" />
<aura:attribute name="recordId" type="Id" default="{ 'sobjectType': 'Lead__c' }"/>
<aura:attribute name="dateValidationError" type="boolean" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:handler name="init" value="{!this}" action="{!c.mapOpp}"/>
<div class="slds-box">
<div class="slds-col slds-has-flexi-truncate" align="left">
<table>
<lightning:layout class="slds-page-header slds-page-header--object-home">
<lightning:layoutItem >
<lightning:icon iconName="action:new_opportunity" size="small" alternativeText="Indicates approval"/>
</lightning:layoutItem>
<lightning:layoutItem padding="horizontal-Large">
<h1 class="slds-page-header__title slds-m-right--Large slds-align-middle slds-truncate" title="Create Opportunity"><b>Create Opportunity</b></h1>
<h2 class="slds-text-heading-medium">New Opportunity</h2>
</lightning:layoutItem>
</lightning:layout>
</table>
</div>
<form class="slds-form--inline"> <br/><br/>
<center> <lightning:button variant="brand"
disabled="{!v.dateValidationError}"
label="Save" onclick="{!c.Save}"/>
<lightning:button label="cancel"
iconName="cancel"
iconPosition="centera"
variant="brand" onclick="{!c.cancel}"/></center><br/><br/>
<body>
<p class="slds-text-title--caps slds-line-height--reset" style="color:Blue"><b>Opportunity Information</b></p><br/><br/>
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout"><br/>
<div class="slds-p-around_medium">
<!-- <label class="slds-form-element__label" >Opportunity Name</label>-->
<div class="slds-form-element__control">
<ui:inputText value="{!v.opp.Name}" label="Opportunity Name"/>
</div>
</div>
<div class="slds-p-around_medium">
<label class="slds-form-element__label" >Stage</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Stage__c}" />
</div>
</div>
<div class="slds-p-around_medium">
<br/> <label class="slds-form-element__label" for="inputNameSample1">Account:</label>
<div class="slds-form-element__control" style="width:30%;height:20px;">
<force:inputField value="{!v.opp.Account__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Project Type:</label>
<div class="slds-form-element__control" >
<force:inputField value="{!v.opp.Project_Type__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Agreements:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Agreements__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">End Customer:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.End_Customer__c}" />
</div>
</div><br/><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">End Market:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.End_Market__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Sample Required</label>
<div class="slds-form-element__control" >
<force:inputField value="{!v.opp.Sample_Required__c}" />
</div>
</div><br/><br/>
</table><br/><br/>
<p class="slds-text-title--caps slds-line-height--reset" style="color:Blue"><b>Business Potential Information</b></p><br/><br/>
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout"><br/>
<div class="slds-p-around_medium">
<label class="slds-form-element__label" for="inputNameSample1">Product Name:</label>
<div class="slds-form-element__control" style="width:30%;">
<force:inputField value="{!v.opp.ProductName__c}" />
</div>
</div><br/><br/>
<div class="slds-p-around_medium">
<label class="slds-form-element__label" for="inputNameSample1">Product Specification:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Product_Specifications__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Potential Quantity:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Potential_Quantity__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Potential Price:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Potential_Price__c}" />
</div>
</div><br/><br/>
<div class="slds-p-around_medium">
<div class="slds-form-element__control">
<lightning:input class="{! v.dateValidationError ? 'slds-has-error' : ''}"
type="date"
label="Expected Launch:"
value="{!v.opp.Expected_Launch__c}"
name="date"
variant="brand"
onchange="{!c.dateUpdate}"/>
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">UOM:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.UOM__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<div class="slds-form-element__control" >
<lightning:input class="{! v.dateValidationError ? 'slds-has-error' : ''}"
type="date"
label="Sample Required Date:"
value="{!v.opp.Sample_Required_Date__c}"
name="date"
variant="brand"
onchange="{!c.dateUpdate}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Documents Required:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Documents_Required__c}" />
</div>
</div><br/><br/>
<aura:if isTrue="{!v.dateValidationError}">
<div class="slds-text-color_error slds-p-left_x-small">
Date must be in present or in future..
</div>
</aura:if>
</table><br/><br/>
<center> <lightning:button label="save"
iconName="submit"
iconPosition="centera"
variant="brand"
disabled="{!v.dateValidationError}" onclick="{!c.Save}"/>
<lightning:button label="cancel"
iconName="cancel"
iconPosition="centera"
variant="brand" onclick="{!c.cancel}"/></center><br/><br/>
</body>
</form>
</div><br/>
</aura:component>
================
controller:
({
doInit : function(component, event, helper) {
helper.fetchOppRecords(component, event, helper);
},
mapOpp : function(component, event, helper) {
var Leadid = component.get("v.recordId");
var le = component.get("v.lea");
var action= component.get("c.getMapLeadFields")
action.setParams({"op":"v.opp", "leid":"v.recordId"});
action.setCallback(this, function(response){
var state=response.getState();
if(state=="SUCCESS"){
var opps = response.getReturnValue();
var op = component.get("v.op");
var lea=component.get("v.lea.Account__C");
component.set("v.op.Account__c",lea);
component.set("v.opp",opps);
alert('Fields automapped');
console.log("opps"+opps);
}
else{
alert("Failed to fetch records from server");
}
});
$A.enqueueAction(action);
}, dateUpdate : function(component, event, helper) {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
// if date is less then 10, then append 0 before date
if(dd < 10){
dd = '0' + dd;
}
// if month is less then 10, then append 0 before date
if(mm < 10){
mm = '0' + mm;
}
var todayFormattedDate = yyyy+'-'+mm+'-'+dd;
if(component.get("v.opp.Expected_Launch__c") != '' && component.get("v.opp.Expected_Launch__c") < todayFormattedDate){
component.set("v.dateValidationError" , true);
}else if(component.get("v.opp.Sample_Required_Date__c") != '' && component.get("v.opp.Sample_Required_Date__c") < todayFormattedDate){
component.set("v.dateValidationError" , true);
}
else{
component.set("v.dateValidationError" , false);
}
},
cancel : function(component, event, helper) {
// Close the action panel
var dismissActionPanel = $A.get("e.force:closeQuickAction");
dismissActionPanel.fire();
},
Save : function(component, event, helper) {
// Validate form fields
// Pass form data to a helper function
var opsrecs = component.get("v.op");
helper.saveOpp (component,opsrecs);
}
})
===========================
Helper:
({
fetchOppRecords : function(component, event, helper) {
var action= component.get("c.getFetchOpp")
action.setCallback(this, function(response){
var state=response.getState();
if(state==="SUCCESS"){
var Opplist = response.getReturnValue();
component.set("v.opp", Opplist);
console.log("opplist"+Opplist);
}else{
alert("Failed to fetch records from server");
}
});
$A.enqueueAction(action);
},
saveOpp: function(component, ops) {
//Save the expense and update the view
this.upsertOpp(component, ops, function(a) {
var urlEvent = $A.get("e.force:navigateToURL");
var state = a.getState();
if (component.isValid() && state === "SUCCESS") {
var Opp = component.get("v.opp");
Opp.push(a.getReturnValue());
component.set("v.opp", Opp);
alert('Lead Converted Successfully');
}
urlEvent.setParams({
"url": "/one/one.app#/sObject/Opportunity__c/list?filterName=00B7F00000AyAh9UAF"
});
urlEvent.fire();
});
},
upsertOpp : function(component, ops, callback) {
var action = component.get("c.getSaveOppRecs");
action.setParams({
"ops": ops
});
if (callback) {
action.setCallback(this, callback);
}
$A.enqueueAction(action);
}
})
=============================
apxc:
public class createOpp {
@AuraEnabled
public Static List<Opportunity__c> getFetchOpp(){
Return [Select id,Name,Account__c,Project_Type__c,Agreements__c,End_Customer__c,
Sample_Required__c,ProductName__c,Product_Specifications__c,Potential_Quantity__c,Potential_Price__c,
Expected_Launch__c,UOM__c,Sample_Required_Date__c,Documents_Required__c from Opportunity__c ];
}
@AuraEnabled
public Static List<Lead__c> getMapLeadFields(List<Lead__c> le){
system.debug('hello');
Return [Select id,Name,Agent__c,Account__c,Agreements__c,AgentCommission__c,
DeliveryTerms__c,Description__c,EndCustomer__c,EndMarket__c,ExpectedLaunch__c,
PotentialPrice__c,PotentialQuantity__c,Product_Name__c,Project_Type__c,Product_Specifications__c,
UOM__c from Lead__c];
}
@AuraEnabled
public static Opportunity__c getSaveOppRecs(Opportunity__c ops){
insert ops;
return ops;
}
}
===========================================
can anybody help me out with autopopulating the fields..
Thanks & Regards,
Veena.
i am new to lightning as i am trying to autopopulate custom object fields... i have 2 custom objects those are LEAD and OPPORTUNITY i created an convert to opportunity quick action button in lead object. while coverting to opportunity the related lead fields should autopopulate in the lightning component.
here is my code:
component:
<aura:component controller="createOpp" implements="force:lightningQuickAction,force:hasRecordId" access="global">
<aura:attribute name="opp" type="Opportunity__c[]" default="{ 'sobjectType': 'Opportunity__c'}"/>
<aura:attribute name="lelist" type="Lead__c[]" default="{ 'sobjectType': 'Lead__c'}"/>
<aura:attribute name="er" type="boolean" default="false"/>
<aura:attribute name="op" type="Opportunity__c" default="{ 'sobjectType': 'Opportunity__c',
'Name': '',
'Agent__c': '',
'Account__c': '',
'Agreements__c': '',
'Agent_Commission__c': '',
'Delivery_Terms__c': '',
'Description__c': '',
'End_Customer__c': '',
'End_Market__c': '',
'Expected_Launch__c': '',
'Potential_Price__c': '',
'Potential_Quantity__c': '',
'ProductName__c': '',
'Project_Type__c': '',
'Product_Specifications__c': '',
'UOM__c': '',}"/>
<aura:attribute name="lea" type="Lead__c" />
<aura:attribute name="recordId" type="Id" default="{ 'sobjectType': 'Lead__c' }"/>
<aura:attribute name="dateValidationError" type="boolean" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:handler name="init" value="{!this}" action="{!c.mapOpp}"/>
<div class="slds-box">
<div class="slds-col slds-has-flexi-truncate" align="left">
<table>
<lightning:layout class="slds-page-header slds-page-header--object-home">
<lightning:layoutItem >
<lightning:icon iconName="action:new_opportunity" size="small" alternativeText="Indicates approval"/>
</lightning:layoutItem>
<lightning:layoutItem padding="horizontal-Large">
<h1 class="slds-page-header__title slds-m-right--Large slds-align-middle slds-truncate" title="Create Opportunity"><b>Create Opportunity</b></h1>
<h2 class="slds-text-heading-medium">New Opportunity</h2>
</lightning:layoutItem>
</lightning:layout>
</table>
</div>
<form class="slds-form--inline"> <br/><br/>
<center> <lightning:button variant="brand"
disabled="{!v.dateValidationError}"
label="Save" onclick="{!c.Save}"/>
<lightning:button label="cancel"
iconName="cancel"
iconPosition="centera"
variant="brand" onclick="{!c.cancel}"/></center><br/><br/>
<body>
<p class="slds-text-title--caps slds-line-height--reset" style="color:Blue"><b>Opportunity Information</b></p><br/><br/>
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout"><br/>
<div class="slds-p-around_medium">
<!-- <label class="slds-form-element__label" >Opportunity Name</label>-->
<div class="slds-form-element__control">
<ui:inputText value="{!v.opp.Name}" label="Opportunity Name"/>
</div>
</div>
<div class="slds-p-around_medium">
<label class="slds-form-element__label" >Stage</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Stage__c}" />
</div>
</div>
<div class="slds-p-around_medium">
<br/> <label class="slds-form-element__label" for="inputNameSample1">Account:</label>
<div class="slds-form-element__control" style="width:30%;height:20px;">
<force:inputField value="{!v.opp.Account__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Project Type:</label>
<div class="slds-form-element__control" >
<force:inputField value="{!v.opp.Project_Type__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Agreements:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Agreements__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">End Customer:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.End_Customer__c}" />
</div>
</div><br/><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">End Market:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.End_Market__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Sample Required</label>
<div class="slds-form-element__control" >
<force:inputField value="{!v.opp.Sample_Required__c}" />
</div>
</div><br/><br/>
</table><br/><br/>
<p class="slds-text-title--caps slds-line-height--reset" style="color:Blue"><b>Business Potential Information</b></p><br/><br/>
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout"><br/>
<div class="slds-p-around_medium">
<label class="slds-form-element__label" for="inputNameSample1">Product Name:</label>
<div class="slds-form-element__control" style="width:30%;">
<force:inputField value="{!v.opp.ProductName__c}" />
</div>
</div><br/><br/>
<div class="slds-p-around_medium">
<label class="slds-form-element__label" for="inputNameSample1">Product Specification:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Product_Specifications__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Potential Quantity:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Potential_Quantity__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Potential Price:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Potential_Price__c}" />
</div>
</div><br/><br/>
<div class="slds-p-around_medium">
<div class="slds-form-element__control">
<lightning:input class="{! v.dateValidationError ? 'slds-has-error' : ''}"
type="date"
label="Expected Launch:"
value="{!v.opp.Expected_Launch__c}"
name="date"
variant="brand"
onchange="{!c.dateUpdate}"/>
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">UOM:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.UOM__c}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<div class="slds-form-element__control" >
<lightning:input class="{! v.dateValidationError ? 'slds-has-error' : ''}"
type="date"
label="Sample Required Date:"
value="{!v.opp.Sample_Required_Date__c}"
name="date"
variant="brand"
onchange="{!c.dateUpdate}" />
</div>
</div><br/>
<div class="slds-p-around_medium">
<br/><label class="slds-form-element__label" for="inputNameSample1">Documents Required:</label>
<div class="slds-form-element__control">
<force:inputField value="{!v.opp.Documents_Required__c}" />
</div>
</div><br/><br/>
<aura:if isTrue="{!v.dateValidationError}">
<div class="slds-text-color_error slds-p-left_x-small">
Date must be in present or in future..
</div>
</aura:if>
</table><br/><br/>
<center> <lightning:button label="save"
iconName="submit"
iconPosition="centera"
variant="brand"
disabled="{!v.dateValidationError}" onclick="{!c.Save}"/>
<lightning:button label="cancel"
iconName="cancel"
iconPosition="centera"
variant="brand" onclick="{!c.cancel}"/></center><br/><br/>
</body>
</form>
</div><br/>
</aura:component>
================
controller:
({
doInit : function(component, event, helper) {
helper.fetchOppRecords(component, event, helper);
},
mapOpp : function(component, event, helper) {
var Leadid = component.get("v.recordId");
var le = component.get("v.lea");
var action= component.get("c.getMapLeadFields")
action.setParams({"op":"v.opp", "leid":"v.recordId"});
action.setCallback(this, function(response){
var state=response.getState();
if(state=="SUCCESS"){
var opps = response.getReturnValue();
var op = component.get("v.op");
var lea=component.get("v.lea.Account__C");
component.set("v.op.Account__c",lea);
component.set("v.opp",opps);
alert('Fields automapped');
console.log("opps"+opps);
}
else{
alert("Failed to fetch records from server");
}
});
$A.enqueueAction(action);
}, dateUpdate : function(component, event, helper) {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
// if date is less then 10, then append 0 before date
if(dd < 10){
dd = '0' + dd;
}
// if month is less then 10, then append 0 before date
if(mm < 10){
mm = '0' + mm;
}
var todayFormattedDate = yyyy+'-'+mm+'-'+dd;
if(component.get("v.opp.Expected_Launch__c") != '' && component.get("v.opp.Expected_Launch__c") < todayFormattedDate){
component.set("v.dateValidationError" , true);
}else if(component.get("v.opp.Sample_Required_Date__c") != '' && component.get("v.opp.Sample_Required_Date__c") < todayFormattedDate){
component.set("v.dateValidationError" , true);
}
else{
component.set("v.dateValidationError" , false);
}
},
cancel : function(component, event, helper) {
// Close the action panel
var dismissActionPanel = $A.get("e.force:closeQuickAction");
dismissActionPanel.fire();
},
Save : function(component, event, helper) {
// Validate form fields
// Pass form data to a helper function
var opsrecs = component.get("v.op");
helper.saveOpp (component,opsrecs);
}
})
===========================
Helper:
({
fetchOppRecords : function(component, event, helper) {
var action= component.get("c.getFetchOpp")
action.setCallback(this, function(response){
var state=response.getState();
if(state==="SUCCESS"){
var Opplist = response.getReturnValue();
component.set("v.opp", Opplist);
console.log("opplist"+Opplist);
}else{
alert("Failed to fetch records from server");
}
});
$A.enqueueAction(action);
},
saveOpp: function(component, ops) {
//Save the expense and update the view
this.upsertOpp(component, ops, function(a) {
var urlEvent = $A.get("e.force:navigateToURL");
var state = a.getState();
if (component.isValid() && state === "SUCCESS") {
var Opp = component.get("v.opp");
Opp.push(a.getReturnValue());
component.set("v.opp", Opp);
alert('Lead Converted Successfully');
}
urlEvent.setParams({
"url": "/one/one.app#/sObject/Opportunity__c/list?filterName=00B7F00000AyAh9UAF"
});
urlEvent.fire();
});
},
upsertOpp : function(component, ops, callback) {
var action = component.get("c.getSaveOppRecs");
action.setParams({
"ops": ops
});
if (callback) {
action.setCallback(this, callback);
}
$A.enqueueAction(action);
}
})
=============================
apxc:
public class createOpp {
@AuraEnabled
public Static List<Opportunity__c> getFetchOpp(){
Return [Select id,Name,Account__c,Project_Type__c,Agreements__c,End_Customer__c,
Sample_Required__c,ProductName__c,Product_Specifications__c,Potential_Quantity__c,Potential_Price__c,
Expected_Launch__c,UOM__c,Sample_Required_Date__c,Documents_Required__c from Opportunity__c ];
}
@AuraEnabled
public Static List<Lead__c> getMapLeadFields(List<Lead__c> le){
system.debug('hello');
Return [Select id,Name,Agent__c,Account__c,Agreements__c,AgentCommission__c,
DeliveryTerms__c,Description__c,EndCustomer__c,EndMarket__c,ExpectedLaunch__c,
PotentialPrice__c,PotentialQuantity__c,Product_Name__c,Project_Type__c,Product_Specifications__c,
UOM__c from Lead__c];
}
@AuraEnabled
public static Opportunity__c getSaveOppRecs(Opportunity__c ops){
insert ops;
return ops;
}
}
===========================================
can anybody help me out with autopopulating the fields..
Thanks & Regards,
Veena.
- veena vani
- April 10, 2018
- Like
- 0
I want a Wrapper class to display all the records and should save the selected records using save button
Hi Guys,
i have a vf page where 2 record types records are displaying with checkbox i should save those selected records .. can you please help me with this
here is my code i not wrote a wrapper class i am not understanding how to do it
public class custInterNeeds {
public PegasysKAM__Account_Plan__c accplan {set;get;}
public list <PegasysKAM__Customer_Need__c> cus {get;set;}
public list <PegasysKAM__Customer_Need__c> cus1 {get;set;}
public PegasysKAM__Customer_Need__c CusNeed {get;set;}
public string pid {get;set;}
public String currentRecordId {get;set;}
public PageReference saveandnew() {
return null;
}
public PageReference save() {
return null ;
}
public PageReference Cancel(){
PageReference pageRef = new PageReference('/'+'string pid');
pageRef.setRedirect(true);
return pageRef;
}
public custInterNeeds(ApexPages.StandardController controller) {
string pid = ApexPages.currentPage().getParameters().get('pid');
cus = [SELECT ID,Name, PegasysKAM__Account__c,PegasysKAM__Need__c,PegasysKAM__Status__c,PegasysKAM__Year__c,PegasysKAM__Details__c FROM PegasysKAM__Customer_Need__c
where PegasysKAM__Account__c = :ApexPages.CurrentPage().getparameters().get('pid') AND RecordType.name='Customer' ];
cus1 = [SELECT ID,Name, PegasysKAM__Account__c,PegasysKAM__Need__c,PegasysKAM__Status__c,PegasysKAM__Year__c,PegasysKAM__Details__c FROM PegasysKAM__Customer_Need__c
where PegasysKAM__Account__c = :ApexPages.CurrentPage().getparameters().get('pid') AND RecordType.name='Internal' ];
}
}
<apex:page standardController="Account_Plan__c" Extensions="custInterNeeds" >
<script type="text/avascript">
function chkselected(obj,recid)
{
var inputcheckbox = document.getelementsbytagname("input");
for(var i=0; i<inputcheckbox.length; i++){
if(inputcheckbox[i].id.indexOf(recid)!=-1){
inputcheckbox[i].checked = obj.checked;
}
}
}
</script>
<apex:form >
<apex:pageblock title="Account Plan Edit" id="block" mode="edit" >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Cancel" action="{!cancel}"/>
<apex:commandButton value="Save&New" action="{!saveandnew}"/>
</apex:pageBlockButtons>
<apex:pageblocksection title="Information">
<apex:outputField value="{!Account_Plan__c.Account__c}"/>
<apex:inputField value="{!accplan.Key_Account_Manager__c}"/>
<apex:inputField value="{!accplan.Start_Date__c}"/>
<apex:inputField value="{!accplan.Status__c}"/>
<apex:inputField value="{!accplan.End_Date__c}"/>
<apex:inputField value="{!accplan.customer_approval__c}"/>
<apex:inputField value="{!accplan.Customer_Stakeholder__c}"/>
</apex:pageblocksection>
<apex:pageBlockSection title="Details">
<apex:inputField value="{!accplan.Overall_Objective__c}" style="width:120%;"/><br/>
<apex:inputField value="{!accplan.Description__c}" style="width:150%;" />
</apex:pageBlockSection>
</apex:pageblock>
<apex:pageBlock >
<apex:pageblockSection title="Customer Needs" >
<!--<apex:outputPanel rendered="{!IF(<strong>PegasysKAM__Customer_Need__c</strong>.RecordType.Name == 'Customer')}">-->
<!-- <apex:outputPanel rendered="{!Account_Plan__c.PegasysKAM__Customer_Need__c.RecordTypeId== '01I2v000003PVvj'}" > -->
<apex:pageBlockSectionItem dataStyle="width:100%" labelStyle="width:100%" >
<apex:pageblockTable value="{!cus}" var="c" styleclass="pageblock">
<apex:column headerValue="Account" >
<apex:outputField value="{!c.Account__c}" />
</apex:column>
<apex:column headerValue="Details">
<apex:outputField value="{!c.Details__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:outputField value="{!c.Status__c}"/>
</apex:column>
<apex:column headerValue="Need">
<apex:outputField value="{!c.Need__c}"/>
</apex:column>
<apex:column headerValue="Year">
<apex:outputField value="{!c.Year__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="chkselected(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!cus}" id="inputId"/>
</apex:column>
</apex:pageblockTable>
</apex:pageBlockSectionItem>
<!-- </apex:outputpanel> -->
</apex:pageblockSection>
<!-- section for internal needs-->
<apex:pageblockSection title="Internal Needs" >
<apex:pageBlockSectionItem dataStyle="width:100%" labelStyle="width:100%" >
<apex:pageblockTable value="{!cus1}" var="c" styleclass="pageblock">
<apex:column headerValue="Account" >
<apex:outputField value="{!c.Account__c}" />
</apex:column>
<apex:column headerValue="Details">
<apex:outputField value="{!c.Details__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:outputField value="{!c.Status__c}"/>
</apex:column>
<apex:column headerValue="Need">
<apex:outputField value="{!c.Need__c}"/>
</apex:column>
<apex:column headerValue="Year">
<apex:outputField value="{!c.Year__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="chkselected(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!cus}" id="inputId"/>
</apex:column>
</apex:pageblockTable>
</apex:pageBlockSectionItem>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
i have a vf page where 2 record types records are displaying with checkbox i should save those selected records .. can you please help me with this
here is my code i not wrote a wrapper class i am not understanding how to do it
public class custInterNeeds {
public PegasysKAM__Account_Plan__c accplan {set;get;}
public list <PegasysKAM__Customer_Need__c> cus {get;set;}
public list <PegasysKAM__Customer_Need__c> cus1 {get;set;}
public PegasysKAM__Customer_Need__c CusNeed {get;set;}
public string pid {get;set;}
public String currentRecordId {get;set;}
public PageReference saveandnew() {
return null;
}
public PageReference save() {
return null ;
}
public PageReference Cancel(){
PageReference pageRef = new PageReference('/'+'string pid');
pageRef.setRedirect(true);
return pageRef;
}
public custInterNeeds(ApexPages.StandardController controller) {
string pid = ApexPages.currentPage().getParameters().get('pid');
cus = [SELECT ID,Name, PegasysKAM__Account__c,PegasysKAM__Need__c,PegasysKAM__Status__c,PegasysKAM__Year__c,PegasysKAM__Details__c FROM PegasysKAM__Customer_Need__c
where PegasysKAM__Account__c = :ApexPages.CurrentPage().getparameters().get('pid') AND RecordType.name='Customer' ];
cus1 = [SELECT ID,Name, PegasysKAM__Account__c,PegasysKAM__Need__c,PegasysKAM__Status__c,PegasysKAM__Year__c,PegasysKAM__Details__c FROM PegasysKAM__Customer_Need__c
where PegasysKAM__Account__c = :ApexPages.CurrentPage().getparameters().get('pid') AND RecordType.name='Internal' ];
}
}
<apex:page standardController="Account_Plan__c" Extensions="custInterNeeds" >
<script type="text/avascript">
function chkselected(obj,recid)
{
var inputcheckbox = document.getelementsbytagname("input");
for(var i=0; i<inputcheckbox.length; i++){
if(inputcheckbox[i].id.indexOf(recid)!=-1){
inputcheckbox[i].checked = obj.checked;
}
}
}
</script>
<apex:form >
<apex:pageblock title="Account Plan Edit" id="block" mode="edit" >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />
<apex:commandButton value="Cancel" action="{!cancel}"/>
<apex:commandButton value="Save&New" action="{!saveandnew}"/>
</apex:pageBlockButtons>
<apex:pageblocksection title="Information">
<apex:outputField value="{!Account_Plan__c.Account__c}"/>
<apex:inputField value="{!accplan.Key_Account_Manager__c}"/>
<apex:inputField value="{!accplan.Start_Date__c}"/>
<apex:inputField value="{!accplan.Status__c}"/>
<apex:inputField value="{!accplan.End_Date__c}"/>
<apex:inputField value="{!accplan.customer_approval__c}"/>
<apex:inputField value="{!accplan.Customer_Stakeholder__c}"/>
</apex:pageblocksection>
<apex:pageBlockSection title="Details">
<apex:inputField value="{!accplan.Overall_Objective__c}" style="width:120%;"/><br/>
<apex:inputField value="{!accplan.Description__c}" style="width:150%;" />
</apex:pageBlockSection>
</apex:pageblock>
<apex:pageBlock >
<apex:pageblockSection title="Customer Needs" >
<!--<apex:outputPanel rendered="{!IF(<strong>PegasysKAM__Customer_Need__c</strong>.RecordType.Name == 'Customer')}">-->
<!-- <apex:outputPanel rendered="{!Account_Plan__c.PegasysKAM__Customer_Need__c.RecordTypeId== '01I2v000003PVvj'}" > -->
<apex:pageBlockSectionItem dataStyle="width:100%" labelStyle="width:100%" >
<apex:pageblockTable value="{!cus}" var="c" styleclass="pageblock">
<apex:column headerValue="Account" >
<apex:outputField value="{!c.Account__c}" />
</apex:column>
<apex:column headerValue="Details">
<apex:outputField value="{!c.Details__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:outputField value="{!c.Status__c}"/>
</apex:column>
<apex:column headerValue="Need">
<apex:outputField value="{!c.Need__c}"/>
</apex:column>
<apex:column headerValue="Year">
<apex:outputField value="{!c.Year__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="chkselected(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!cus}" id="inputId"/>
</apex:column>
</apex:pageblockTable>
</apex:pageBlockSectionItem>
<!-- </apex:outputpanel> -->
</apex:pageblockSection>
<!-- section for internal needs-->
<apex:pageblockSection title="Internal Needs" >
<apex:pageBlockSectionItem dataStyle="width:100%" labelStyle="width:100%" >
<apex:pageblockTable value="{!cus1}" var="c" styleclass="pageblock">
<apex:column headerValue="Account" >
<apex:outputField value="{!c.Account__c}" />
</apex:column>
<apex:column headerValue="Details">
<apex:outputField value="{!c.Details__c}"/>
</apex:column>
<apex:column headerValue="Status">
<apex:outputField value="{!c.Status__c}"/>
</apex:column>
<apex:column headerValue="Need">
<apex:outputField value="{!c.Need__c}"/>
</apex:column>
<apex:column headerValue="Year">
<apex:outputField value="{!c.Year__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="chkselected(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!cus}" id="inputId"/>
</apex:column>
</apex:pageblockTable>
</apex:pageBlockSectionItem>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
- veena vani
- November 27, 2019
- Like
- 0
How to implement pagination in vf?
I'm new to salesforce, can you please tell me rough idea that how can I implement pagination?
- ashish jadhav 9
- April 15, 2016
- Like
- 0