- Gopal Chat
- NEWBIE
- 40 Points
- Member since 2017
- Techmatrix
-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
28Questions
-
18Replies
I'm not able to write test class for my class
Class -----------
global class MitratechCustomerSupport implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope env) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
String threadIdentifire=email.FromAddress+'--'+email.subject+'--'+email.toAddresses;
String caseNum=email.subject.subString(email.subject.lastindexOf('-')+1,email.subject.Length());
String sourceIdStore='';
String s= '';
Case objCase = new Case();
EmailMessage objEmailMessage = new EmailMessage();
Messaging.InboundEmail.Header[] hd=email.headers;
if(!test.isRunningTest()){
for(Messaging.InboundEmail.Header hdValue: hd){
s = s+String.valueOf(hdValue);
}
}
Id caseId=[SELECT Id FROM Case WHERE CaseNumber=:caseNum.trim()][0].Id;
if( caseId!=NULL){
try{
//Verify OTP
if(s.contains('Forwarding Confirmation')){
objCase.Subject = email.subject;
objCase.Origin = 'Email';
objCase.Status = 'New';
Insert objCase;
}
else{
//Insert Inbound Email Message
objEmailMessage.ToAddress = String.join( email.toAddresses, ',');
objEmailMessage.FromAddress = email.FromAddress;
objEmailMessage.FromName = email.FromName;
objEmailMessage.Subject = email.subject;
objEmailMessage.HtmlBody = email.htmlBody;
objEmailMessage.Incoming= true;
objEmailMessage.TextBody = email.plainTextBody;
objEmailMessage.RelatedToId =caseId;
//objEmailMessage.ThreadIdentifier=threadIdentifire;
//objEmailMessage.MessageIdentifier=threadIdentifire;
insert objEmailMessage;
for(Case cs:[SELECT SourceId FROM Case WHERE id=:caseId]){
sourceIdStore=cs.SourceId;
}
If(String.isBlank(sourceIdStore)){
objCase.SourceId =objEmailMessage.Id;
}
objCase.Id=caseId;
update objCase;
}
}
Catch(Exception ex){
system.debug('Exception Message'+ex.getMessage());
}
}
result.success = true;
return result;
}
}
Test Class-----
@isTest
public class MitratechCustomerSupportTest {
@isTest
public static void runTest(){
Case c = new Case(subject = 'TEST',Status ='New', Priority = 'Medium', Origin = 'Email');
insert c;
c = [select id, casenumber from Case where id = :c.id];
Messaging.InboundEmail email = new Messaging.InboundEmail() ;
Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
email.subject = 'blah blah blah '+'-'+c.casenumber;
email.fromAddress = 'someaddress@email.com';
email.plainTextBody = 'email body\n2225256325\nTitle';
MitratechCustomerSupport testInbound=new MitratechCustomerSupport ();
testInbound.handleInboundEmail(email, env);
}
}
- Gopal Chat
- February 09, 2022
- Like
- 0
Locality__c & '/' & TEXT(DATEVALUE(CreatedDate)) & '/' & TEXT(TIMEVALUE(CreatedDate)) this is my formula giving output in this form
i want to add 2 and half hours in time bz time is in GMT
- Gopal Chat
- February 02, 2019
- Like
- 0
Auto Populate Date of birth by age In Lightning Component
For example -when i set 2 in years the age,date of birth will be 2 jan 2017
- Gopal Chat
- January 31, 2019
- Like
- 0
I want a trigger or batch which count week based on Start date
for example start date is 12/01/2018,after 7 days the count will be 1/0,after next 7 days the count will be 2/0, after one year the count will be 0/1 based on start date
- Gopal Chat
- December 01, 2018
- Like
- 0
In my code i want to show or hide None div based on input,if input is blank the div of none will show none,and email validation error
<aura:attribute name="enquiryName" type="String" default="" />
<aura:attribute name="mobileNumber" type="String" default="" />
<aura:attribute name="emailId" type="String" default="" />
<aura:attribute name="companyName" type="String" default="" />
<aura:attribute name="typeOfEnquiry" type="List" default="" />
<aura:attribute name="selectedEnquiry" type="String" default="" />
<aura:attribute name="typeOfProperty" type="List" default="" />
<aura:attribute name="selectedPropertyType" type="String" default="" />
<aura:attribute name="propertyArea" type="String" default="" />
<aura:attribute name="country" type="String" default="" />
<aura:attribute name="city" type="String" default="" />
<aura:attribute name="address" type="String" default="" />
<aura:handler name="init" value="{!this}" action="{!c.onLoad}" />
<!--<lightning:spinner aura:id="mySpinner" variant="brand" size="medium" class="slds-hide"/>-->
<lightning:spinner variant="brand" size="medium" aura:id="Id_spinner" class="slds-hide" />
<lightning:card>
<aura:set attribute="title">
<div class="slds-text-heading_large slds-text-align_center">
<b>Enquiry</b>
</div>
</aura:set>
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-12">
</div>
<div class="slds-col slds-size_10-of-12">
<lightning:input name="input1" label="Name" placeholder="Enter Name..." value="{!v.enquiryName}" required="true"/>
<div class="slds-text-color_error" style="background-color:#fff;" aura:id="containerCollapsable">
<p>None</p>
</div>
</div>
<div class="slds-col slds-size_1-of-12">
</div>
</div>
<br />
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-12">
</div>
<div class="slds-col slds-size_10-of-12">
<lightning:input aura:id="mobile" name="input2" label="Mobile Number" maxlength="10" minlength="10" placeholder="Enter Mobile Number..." value="{!v.mobileNumber}" required="true"/>
<div class="slds-text-color_error" style="background-color:#fff;">
<p>None</p>
</div>
</div>
<div class="slds-col slds-size_1-of-12">
</div>
</div>
<br />
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-12">
</div>
<div class="slds-col slds-size_10-of-12">
<lightning:input aura:id="email" name="input3" label="Email Id" placeholder="Enter Email Id..." value="{!v.emailId}" required="true"/>
<div class="slds-text-color_error" style="background-color:#fff;">
<p>None</p>
</div>
</div>
<div class="slds-col slds-size_1-of-12">
</div>
</div>
<br/>
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-12">
</div>
<div class="slds-col slds-size_10-of-12">
<lightning:input name="input4" label="Company Name" placeholder="Enter Company Name..." value="{!v.companyName}"/>
</div>
<div class="slds-col slds-size_1-of-12">
</div>
</div>
<br />
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-12">
</div>
<div class="slds-col slds-size_10-of-12">
<lightning:select name="typeId" label="Select Type" aura:id="typeId" value="{!v.selectedEnquiry}" required="true">
<option text="---Choose Type---" value="0" />
<aura:iteration items="{!v.typeOfEnquiry}" var="option">
<option text="{!option}" value="{!option}"/>
</aura:iteration>
</lightning:select>
<div class="slds-text-color_error" style="background-color:#fff;">
<p>None</p>
</div>
</div>
<div class="slds-col slds-size_1-of-12">
</div>
</div>
<br />
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-12">
</div>
<div class="slds-col slds-size_10-of-12">
<lightning:select name="propertyId" label="Select Property Type" aura:id="propertyId" value="{!v.selectedPropertyType}" required="true">
<option text="---Choose Property Type---" value="0" />
<aura:iteration items="{!v.typeOfProperty}" var="option">
<option text="{!option}" value="{!option}" />
</aura:iteration>
</lightning:select>
<div class="slds-text-color_error" style="background-color:#fff;">
<p>None</p>
</div>
</div>
<div class="slds-col slds-size_1-of-12">
</div>
</div>
<br/>
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-12">
</div>
<div class="slds-col slds-size_10-of-12">
<lightning:input name="input6" label="Property Area" placeholder="Enter Property Area..." value="{!v.propertyArea}" required="true"/>
<div class="slds-text-color_error" style="background-color:#fff;">
<p>None</p>
</div>
</div>
<div class="slds-col slds-size_1-of-12">
</div>
</div>
<br/>
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-12">
</div>
<div class="slds-col slds-size_10-of-12">
<lightning:input name="input7" label="Country" placeholder="Enter Country..." value="{!v.country}" required="true"/>
<div class="slds-text-color_error" style="background-color:#fff;">
<p>None</p>
</div>
</div>
<div class="slds-col slds-size_1-of-12">
</div>
</div>
<br />
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-12">
</div>
<div class="slds-col slds-size_10-of-12">
<lightning:input name="input8" label="City" placeholder="Enter City..." value="{!v.city}" required="true"/>
<div class="slds-text-color_error" style="background-color:#fff;">
<p>None</p>
</div>
</div>
<div class="slds-col slds-size_1-of-12">
</div>
</div>
<br />
<div class="slds-grid slds-wrap">
<div class="slds-col slds-size_1-of-12">
</div>
<div class="slds-col slds-size_10-of-12">
<lightning:input name="input9" label="Address" placeholder="Enter Address..." value="{!v.address}" />
</div>
<div class="slds-col slds-size_1-of-12">
</div>
</div>
<aura:set attribute="footer">
<div class="slds-text-align_center">
<lightning:button variant="brand" label="Save" title="Brand" onclick="{!c.handleClick}" />
</div>
</aura:set>
</lightning:card>
</aura:component>
({
handleClick : function(component, event, helper) {
// var spinner = component.find("mySpinner");
//component.find("Id_spinner").set("v.class" , 'slds-show');
//$A.util.removeClass(spinner,"slds-hide");
var action = component.get("c.handleClickApex");
if(!helper.checkvalidation(component, event)){
action.setParams({
"enquiryName" : component.get('v.enquiryName'),
"mobileNumber" : component.get('v.mobileNumber'),
"emailId" : component.get('v.emailId'),
"companyName" : component.get("v.companyName") ,
"selectedEnquiry" : component.get("v.selectedEnquiry"),
"selectedPropertyType" : component.get("v.selectedPropertyType"),
"propertyArea" : component.get("v.propertyArea"),
"country" : component.get("v.country"),
"city" : component.get("v.city"),
"address" : component.get("v.address")
});
action.setCallback(this,function(response){
// component.find("Id_spinner").set("v.class",'slds-hide');
if(response.getState() === "SUCCESS") {
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
"recordId": response.getReturnValue()
});
navEvt.fire();
// $A.util.addClass(spinner,"slds-hide");
}
});
$A.enqueueAction(action);
}
},
onLoad : function(component,event,helper) {
// var spinner = component.find("mySpinner");
// $A.util.removeClass(spinner,"slds-hide");
var enquiryType = $A.get("$Label.c.EnquiryType");
component.set("v.typeOfEnquiry",enquiryType.split(":"));
var propertyType = $A.get("$Label.c.PropertyType");
component.set("v.typeOfProperty",propertyType.split(":"));
// $A.util.addClass(spinner,"slds-hide");
}
})
({
checkvalidation : function(component, event) {
var notBlank = false;
if(!component.get('v.enquiryName')){
notBlank = true;
}
else if(!component.get('v.mobileNumber')){
var mobileValue=component.find("mobile").get("v.value");
if(!mobileValue.match(/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/)) {
}
notBlank = true;
}else if(!component.get('v.emailId')){
var emailValue=component.find("email").get("v.value");
if(!emailValue.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)){
}
notBlank = true;
}else if(!component.get("v.selectedEnquiry")){
notBlank = true;
}else if(!component.get("v.selectedPropertyType")){
notBlank = true;
}else if(!component.get("v.propertyArea")){
notBlank = true;
}else if(!component.get("v.country")){
notBlank = true;
}else if(!component.get("v.city")){
notBlank = false;
}
return notBlank;
}
})
- Gopal Chat
- September 28, 2018
- Like
- 0
- Gopal Chat
- September 25, 2018
- Like
- 0
Component not updating the record on save button
<aura:attribute name="searchKeyword" type="String" default=""/>
<aura:attribute name="lstOfAccount" type="Account[]"/>
<aura:attribute name="listcontact" type="Contact[]"/>
<aura:attribute name="columns" type="List"/>
<aura:attribute name="isBlank" type="boolean" default="false"/>
<aura:attribute name="recordId" type="String"/>
<aura:attribute name="updatedRecord" type="Object[]" />
<div class="slds-m-around_medium" style="background:#fff">
<lightning:layout>
<lightning:layoutItem padding="around-small">
<lightning:spinner variant="brand" size="medium" aura:id="Id_spinner" class="slds-hide" />
<h1 class="slds-page-header__title slds-truncate slds-align-middle"
title="Enter Account Name">Enter Account Name</h1>
<lightning:input value="{!v.searchKeyword}" required="true" aura:id="searchKeyword"/>
</lightning:layoutItem>
</lightning:layout>
<lightning:layout>
<lightning:layoutItem size="2" padding="around-small">
<lightning:button onclick="{!c.Search}" variant="brand" label="Search" iconName="utility:search"/>
</lightning:layoutItem>
</lightning:layout>
<aura:if isTrue="{!and(v.isBlank, v.lstOfAccount!=NULL)}">
<lightning:card title="Account Records" variant="brand">
<lightning:datatable columns="{! v.columns }" data="{!v.lstOfAccount}"
hideCheckboxColumn="true" keyField="Id" onsave ="{!c.Save}"/>
</lightning:card>
</aura:if>
</div>
</aura:component>
({
Search : function(component, event, helper) {
component.set('v.columns', [
{label: 'Name', fieldName: 'Name', editable:'true', type: 'text'},
{label: 'Phone', fieldName: 'Phone', editable:'true', type: 'Phone'},
{label: 'Industry', fieldName: 'Industry', editable:'true', type: 'text'}]);
var action = component.get("c.fetchAccount");
action.setParams({
"searchKeyWord" : component.get("v.searchKeyword")
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
component.set("v.lstOfAccount", response.getReturnValue());
component.set("v.isBlank",true);
if(response.getReturnValue()==null){
var toast = $A.get("e.force:showToast");
toast.setParams({
"type":"Error",
"title":"Error",
"message":"No Account Found",
"duration":1000
});
toast.fire();
}
}
});
$A.enqueueAction(action);
},
Save : function (component,event,helper){
var action=component.get("c.saveAccount");
action.setParams({
"AccListStr":JSON.stringify(component.get("v.lstOfAccount"))
});
action.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
component.set("v.lstOfAccount", response.getReturnValue());
alert(response.getReturnValue());
var toast = $A.get("e.force:showToast");
toast.setParams({
"type":"Success",
"title":"Success",
"message":"Account Saved Successfully",
"duration":1000
});
toast.fire();
}
});
$A.enqueueAction(action);
}
})
public class AccountSearchController{
@AuraEnabled
public static List <Account> fetchAccount(String searchKeyWord) {
String searchKey = searchKeyWord +'%';
List <Account> lstOfAccount = [SELECT Id, Name,Phone,Industry FROM Account
WHERE Name LIKE:searchKey];
system.debug('==>'+lstOfAccount);
if(lstOfAccount.size() > 0)
return lstOfAccount;
else return null;
}
@auraEnabled
public static List<Account> saveAccount(String AccListStr){
List<Account> accList = (List<Account>)json.deserialize(AccListStr, List<Account>.class);
update accList;
system.debug('===>accList'+accList);
return accList;
}
}
- Gopal Chat
- September 11, 2018
- Like
- 0
Trigger is not working in Update,Error(duplicate id in list which i am updating)
if(CheckRecursive.runOnce() && TriggerManager.getState(string.valueOf(this))){
Set<Id> doctorIdSet = new Set<Id>();
Set<Id> patientIdSet = new Set<Id>();
Set<Date> operationDateSet = new Set<Date>();
Set<Id> HealthcardSet = new Set<Id>();
Set<String> operationTimeSet = new Set<String>();
Map<string,List<Appointment__c>> docAppointmentMap = new Map<String,List<Appointment__c>>();
Map<string,List<Appointment__c>> patientAppointmentMap = new Map<string,List<Appointment__c>>();
for(Appointment__c apt : trigger.New)
if(ChiroConstants.operationStatusToSimulateDeleteSet.contains(apt.Status__c)
&& apt.Status__c != trigger.oldMap.get(apt.Id).Status__c){
system.debug('===>Raghav');
doctorIdSet.add(apt.Doctor_Name__c);
operationDateSet.add(apt.Appointment_Date__c);
operationTimeSet.add(apt.Appointment_Time__c);
patientIdSet.add(apt.Patient__c);
HealthcardSet.add(apt.Health_Card__c);
string key = apt.Doctor_Name__c+'@@'+apt.Appointment_Date__c+'@@'+apt.Appointment_Time__c;
system.debug('==>key'+key);
string patientKey = apt.Patient__c+'@@'+apt.Doctor_Name__c+'@@'+apt.Clinic_Name__c+'@@'+apt.Health_Card__c;
system.debug('==>patientKey'+patientKey);
patientAppointmentMap.put(patientKey,new List<Appointment__c>());
docAppointmentMap.put(key,new List<Appointment__c>());
system.debug('==>docAppointmentMap'+docAppointmentMap); }
for(Appointment__c apt : [SELECT Id,Doctor_Name__c,Appointment_Date__c,Appointment_Time__c,Priority_Sequence__c
FROM Appointment__c
WHERE Doctor_Name__c IN :doctorIdSet
AND status__c NOT IN :ChiroConstants.operationStatusToSimulateDeleteSet
AND Appointment_Date__c IN :operationDateSet
AND Appointment_time__c IN :operationTimeSet
ORDER BY Doctor_Name__c,Appointment_Date__c,Appointment_Time__c,Priority_Sequence__c]){
string key = apt.Doctor_Name__c+'@@'+apt.Appointment_Date__c+'@@'+apt.Appointment_Time__c;
If(docAppointmentMap.containsKey(key)){
system.debug('===>Dockey'+key);
List<Appointment__c> tempList = docAppointmentMap.get(key);
tempList.add(apt);
docAppointmentMap.put(key, tempList);
}
}
for(Appointment__c apt : [SELECT Id,Patient__c,Health_Card__c,Doctor_Name__c,Clinic_Name__c,Appointment_Date__c,Appointment_Time__c,Serial_No__c
FROM Appointment__c
WHERE Patient__c IN :patientIdSet
AND Doctor_Name__c IN :doctorIdSet
AND Health_Card__c IN :HealthcardSet
AND status__c NOT IN :ChiroConstants.operationStatusToSimulateDeleteSet
ORDER BY Patient__c,Serial_No__c]){
string key = apt.Patient__c+'@@'+apt.Doctor_Name__c+'@@'+apt.Clinic_Name__c+'@@'+apt.Health_Card__c;
system.debug('===>Patkey'+key);
If(patientAppointmentMap.containsKey(key)){
List<Appointment__c> tempList = patientAppointmentMap.get(key);
tempList.add(apt);
patientAppointmentMap.put(key, tempList);
}
}
List<Appointment__c> updateAppointmentList = new List<Appointment__c>();
for(List<Appointment__c> apptList : docAppointmentMap.values()){
integer sequence = 1;
for(Appointment__c appt : apptList){
appt.Priority_Sequence__c = sequence++;
updateAppointmentList.add(appt);
system.debug('===>updateAppointmentList1'+updateAppointmentList);
}
}
for(List<Appointment__c> apptList : patientAppointmentMap.values()){
integer sequence = 1;
for(Appointment__c appt : apptList){
appt.Serial_No__c = sequence++;
updateAppointmentList.add(appt);
system.debug('===>updateAppointmentList2'+updateAppointmentList);
}
}
system.debug('===>updateAppointmentListSize----->'+updateAppointmentList.size());
system.debug('===>updateAppointmentList--->'+updateAppointmentList);
if(updateAppointmentList.size()>0)
update updateAppointmentList;
system.debug('===>updateAppointmentList3'+updateAppointmentList);
}
}
- Gopal Chat
- August 24, 2018
- Like
- 0
In my trigger Account have two child (GF_Order_Summary__c,GF_Outlet__c),GF_Outlet__c have a child GF_Outlet_Monthly_Order_Summary__c ,on the basis of transction year,transction months i want to bulkify my trigger
thanks in advance.
Trigger UpdateOutletMOrderSummaryToAccmOrders on GF_Outlet_Monthly_Order_Summary__c (after insert,after Update,before delete){
Map<Id,String> AccIdMap=new Map<Id,String>();
Map<Id,GF_Order_Summary__c> AccToOrdSumMap=new Map<Id,GF_Order_Summary__c>();
List<GF_Order_Summary__c> updateOrdSumList = new List<GF_Order_Summary__c>();
List<GF_Order_Summary__c> listAccountMonOrder = new List<GF_Order_Summary__c>();
List<GF_Order_Summary__c> deleteOrdSumList = new List<GF_Order_Summary__c>();
if(trigger.isInsert || trigger.isUpdate){
List<GF_Outlet_Monthly_Order_Summary__c> OrdSumList = [Select Id,Name,GF_Total_No_of_Orders__c,CurrencyIsoCode,GF_Total_Revenue__c,
GF_Transaction_Month__c,GF_Transaction_Year__c,GF_Outlet__r.GFID_Account__c
from GF_Outlet_Monthly_Order_Summary__c
where GF_Outlet__r.GFID_Account__c!=NULL AND Id IN :Trigger.new];
system.debug('===>OrdSumList'+OrdSumList);
if(OrdSumList.size()>0){
for(GF_Outlet_Monthly_Order_Summary__c outMonSum : OrdSumList){
AccIdMap.put(outMonSum.GF_Outlet__r.GFID_Account__c,null);
AccToOrdSumMap.put(outMonSum.GF_Outlet__r.GFID_Account__c,null);
}
}
if(AccIdMap.keySet().size() > 0){
for(GF_Order_Summary__c ordSum : [SELECT Id,Name,GF_Total_No_of_Orders__c,GF_Total_Revenue__c,GF_Transaction_Year__c,GF_Transaction_Month__c,GF_Account__c FROM GF_Order_Summary__c WHERE GF_Account__c IN :AccIdMap.keySet()]){
AccIdMap.put(ordSum.GF_Account__c,String.valueOf(ordSum.GF_Transaction_Month__c +'@@'+ordSum.GF_Transaction_Year__c));
system.debug('===>ragh'+ordSum);
AccToOrdSumMap.put(ordSum.GF_Account__c,ordSum);
System.debug('AccIdMap>>>>>>'+AccIdMap);
System.debug('AccToOrdSumMap>>>>>>'+AccToOrdSumMap);
}
for(GF_Outlet_Monthly_Order_Summary__c outMontOrdSum : OrdSumList){
system.debug('-->'+AccIdMap.get(outMontOrdSum.GF_Outlet__r.GFID_Account__c));
system.debug('-->'+ String.valueOf(outMontOrdSum.GF_Transaction_Month__c+'@@'+outMontOrdSum.GF_Transaction_Year__c));
if(AccToOrdSumMap.containsKey(outMontOrdSum.GF_Outlet__r.GFID_Account__c) &&
AccIdMap.containsKey(outMontOrdSum.GF_Outlet__r.GFID_Account__c) &&
String.valueOf(outMontOrdSum.GF_Transaction_Month__c+'@@'+outMontOrdSum.GF_Transaction_Year__c) ==
AccIdMap.get(outMontOrdSum.GF_Outlet__r.GFID_Account__c)){
GF_Order_Summary__c orsu=new GF_Order_Summary__c();
orsu = AccToOrdSumMap.get(outMontOrdSum.GF_Outlet__r.GFID_Account__c);
orsu.GF_Total_Revenue__c +=outMontOrdSum.GF_Total_Revenue__c;
orsu.GF_Total_No_of_Orders__c += outMontOrdSum.GF_Total_No_of_Orders__c;
updateOrdSumList.add(orsu);
System.debug('>>>>>updateOrdSumList '+updateOrdSumList);
}
else{
GF_Order_Summary__c orsu=new GF_Order_Summary__c();
orsu.CurrencyIsoCode=outMontOrdSum.CurrencyIsoCode ;
orsu.GF_Total_Revenue__c=outMontOrdSum.GF_Total_Revenue__c!=null?outMontOrdSum.GF_Total_Revenue__c:0;
orsu.GF_Total_No_of_Orders__c = outMontOrdSum.GF_Total_No_of_Orders__c!=null?outMontOrdSum.GF_Total_No_of_Orders__c:0;
orsu.GF_Transaction_Month__c=outMontOrdSum.GF_Transaction_Month__c!=null?outMontOrdSum.GF_Transaction_Month__c:'';
orsu.GF_Transaction_Year__c=outMontOrdSum.GF_Transaction_Year__c!=null?outMontOrdSum.GF_Transaction_Year__c:'';
orsu.GF_Account__c=outMontOrdSum.GF_Outlet__r.GFID_Account__c;
listAccountMonOrder.add(orsu);
}
}
}
}
if(trigger.isDelete){
List<GF_Outlet_Monthly_Order_Summary__c> OrdSumList = [Select Id,Name,GF_Total_No_of_Orders__c,CurrencyIsoCode,GF_Total_Revenue__c,
GF_Outlet__r.GFID_Account__c,GF_Transaction_Month__c,GF_Transaction_Year__c
from GF_Outlet_Monthly_Order_Summary__c
where GF_Outlet__r.GFID_Account__c !=NULL AND Id IN :Trigger.old];
system.debug('===>'+OrdSumList);
if(OrdSumList.size()>0){
for(GF_Outlet_Monthly_Order_Summary__c outMonSum : OrdSumList) {
AccIdMap.put(outMonSum.GF_Outlet__r.GFID_Account__c,null);
AccToOrdSumMap.put(outMonSum.GF_Outlet__r.GFID_Account__c,null);
}
}
if(AccIdMap.keySet().size() > 0){
for(GF_Order_Summary__c ordSum : [SELECT Id,Name,GF_Total_No_of_Orders__c,GF_Total_Revenue__c,GF_Transaction_Year__c,
GF_Transaction_Month__c,GF_Account__c
FROM GF_Order_Summary__c
WHERE GF_Account__c IN :AccIdMap.keySet()]){
AccIdMap.put(ordSum.GF_Account__c,String.valueOf(ordSum.GF_Transaction_Month__c +'@@'+ordSum.GF_Transaction_Year__c));
AccToOrdSumMap.put(ordSum.GF_Account__c,ordSum);
System.debug('AccIdMap>>>>>>'+AccIdMap);
System.debug('AccToOrdSumMap>>>>>>'+AccToOrdSumMap);
system.debug('===>'+ordSum);
}
for(GF_Outlet_Monthly_Order_Summary__c outMontOrdSum : OrdSumList){
system.debug('-->'+AccIdMap.get(outMontOrdSum.GF_Outlet__r.GFID_Account__c));
system.debug('-->'+ String.valueOf(outMontOrdSum.GF_Transaction_Month__c+'@@'+outMontOrdSum.GF_Transaction_Year__c));
if(AccToOrdSumMap.containsKey(outMontOrdSum.GF_Outlet__r.GFID_Account__c) &&
AccIdMap.containsKey(outMontOrdSum.GF_Outlet__r.GFID_Account__c) &&
String.valueOf(outMontOrdSum.GF_Transaction_Month__c+'@@'+outMontOrdSum.GF_Transaction_Year__c) ==
AccIdMap.get(outMontOrdSum.GF_Outlet__r.GFID_Account__c)){
system.debug('--->Raghav');
GF_Order_Summary__c orsu=new GF_Order_Summary__c();
orsu = AccToOrdSumMap.get(outMontOrdSum.GF_Outlet__r.GFID_Account__c);
system.debug('===>orsu.GF_Total_Revenue__c'+orsu.GF_Total_Revenue__c);
system.debug('===>orsu.GF_Total_Revenue__c'+outMontOrdSum.GF_Total_Revenue__c);
system.debug('==fgndhfghg');
if(orsu.GF_Total_No_of_Orders__c == outMontOrdSum.GF_Total_No_of_Orders__c){
system.debug('===Raghav');
deleteOrdSumList.add(orsu);
break;
}
else{
orsu.GF_Total_Revenue__c -=outMontOrdSum.GF_Total_Revenue__c;
orsu.GF_Total_No_of_Orders__c-= outMontOrdSum.GF_Total_No_of_Orders__c;
updateOrdSumList.add(orsu);
break;
}
}
}
}
}
if(listAccountMonOrder.size() > 0)
insert listAccountMonOrder;
system.debug('==listAccountMonOrder'+listAccountMonOrder);
if(updateOrdSumList.size()> 0)
update updateOrdSumList;
system.debug('==updateOrdSumList'+updateOrdSumList);
if(deleteOrdSumList.size() > 0)
delete deleteOrdSumList;
system.debug('==deleteOrdSumList'+deleteOrdSumList);
}
- Gopal Chat
- July 30, 2018
- Like
- 0
In a page I have Comment section recordtype is textarea,In that i want to stp paste after its word length become 255
- Gopal Chat
- July 18, 2018
- Like
- 0
This is my code,and it's mot working can anyone help me
Set<Id> contentDocumentIdSet = new Set<Id>();
list<Contract> ConToUpdate = new list<Contract>();
set<id> LinkedEntityId1=new set<id>();
if(Trigger.isInsert || Trigger.isUpdate|| Trigger.isUndelete){
for(ContentVersion cv:trigger.new){
if(cv.ContentDocumentId != null){
contentDocumentIdSet.add(cv.ContentDocumentId);
}
}
}
if(Trigger.isDelete){
for(ContentVersion cv:trigger.old){
if(cv.ContentDocumentId != null){
contentDocumentIdSet.add(cv.ContentDocumentId);
}
}
}
system.debug('===contentDocumentIdSet'+contentDocumentIdSet);
List<ContentDocumentLink> cdlForEvent= [SELECT ContentDocumentID, LinkedEntityId FROM ContentDocumentLink
WHERE ContentDocumentID IN:contentDocumentIdSet];
if(cdlForEvent!=null && cdlForEvent.size()>0){
for(ContentDocumentLink contlink:cdlForEvent){
String qtId = String.valueOf(contlink.LinkedEntityId);
qtId = qtId.substring(0,3);
if(qtId=='800'){
LinkedEntityId1.add(contlink.LinkedEntityId);
}
}
system.debug('===LinkedEntityId1'+LinkedEntityId1);
if(LinkedEntityId1!=null && LinkedEntityId1.size()>0){
for(Contract con : [SELECT Id,No_of_Files__c FROM Contract WHERE ID in:LinkedEntityId1]){
con.No_of_Files__c+=LinkedEntityId1.size();
ConToUpdate.add(con);
}
}
}
if(ConToUpdate!=NULL && ConToUpdate.size()>0)
system.debug('===ConToUpdate'+ConToUpdate);
update ConToUpdate;
}
- Gopal Chat
- July 01, 2018
- Like
- 0
Page is not working
But In EmailDetail page selected contact is not showing.
Here is code
<apex:page controller="SearchRecords" showHeader="false" sidebar="false" >
<apex:form id="frm">
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
<apex:commandButton action="{!searchRecord}" value="Search" id="theSearch" reRender="frm"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Detail" id="pb">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" name="group1" reRender="{!display}" />
<apex:actionSupport event="onclick" action="{!newClick}" reRender="conSection" >
<apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
</apex:actionSupport>
</apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.Phone}"/>
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:outputPanel id="conSection">
<apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
<apex:outputPanel rendered="{!listWrapper.size != 0}">
<div align="center" >
<apex:commandButton value="Send Email" action="{!SendEmail}"/>
<apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
</div>
<apex:pageBlockTable value="{!listWrapper}" id="pbt1" var="wrap">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
</apex:column>
<apex:column value="{!wrap.con.Name}"/>
<apex:column value="{!wrap.con.Phone}"/>
<apex:column value="{!wrap.con.Email}"/>
<apex:column value="{!wrap.con.Account.Name}"/>
<apex:column value="{!wrap.con.AccountId}"/>
<apex:column value="{!wrap.con.Id}"/>
</apex:pageBlockTable>
<apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
<apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled="{!disable}"/>
</apex:outputPanel>
<apex:outputPanel rendered="{!listWrapper.size == 0}">
<b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageblock>
</apex:form>
</apex:page>
public class SearchRecords {
public boolean display{get;set;}
public boolean disable{get;set;}
public String AccId{get;set;}
public string getstring{get;set;}
public string selectedvalie{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> conList{get;set;}
public list<Attachment> AttachmentList{get;set;}
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize=3;
public contact con{get;set;}
public Attachment Att{get;set;}
public string Body{get;set;}
public string Subject{get;set;}
public string selectAttachment{get;set;}
public boolean Attc{get;set;}
public boolean Docu{get;set;}
public boolean SysFil{get;set;}
public List<WrapperClass> listWrapper {get;set;}
public List<WrapperClass> listWrapper1 {get;set;}
public void searchRecord(){
display=False;
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public void newClick(){
disable=false;
LimitSize=3;
OffsetSize=0;
showContact();
}
public void showContact(){
display=true;
listWrapper = new List<WrapperClass>();
List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize];
if(conlist!=NULL){
totalRecs = conlist.size();
for(contact con:conlist)
{
listWrapper.add(new WrapperClass(con));
}
}
}
public pageReference PrintDetail(){
listWrapper1=new list<WrapperClass>();
for(WrapperClass wr: listWrapper){
if(wr.checked==true)
listWrapper1.add(wr);
}
pageReference acctPage = new pageReference('/Apex/printContactDetail');
return acctPage;
}
public pageReference SendEmail(){
listWrapper1=new list<WrapperClass>();
String str='';
for(WrapperClass wr: listWrapper){
if(wr.checked==true){
listWrapper1.add(wr);
str+=wr.con.id+',';
}
system.debug('====>listWrapper1'+listWrapper1);
}
str=str.removeEnd(',');
pageReference EmailPage = new pageReference('/Apex/EmailDetail?id='+str);
emailPage.setRedirect(true);
return EmailPage;
}
public pageReference AddFile(){
String str=ApexPages.currentPage().getParameters().get('id');
PageReference acctPage = new pageReference('/Apex/AttachmentPage?id='+str);
return acctPage;
}
set<id> contactId=new set<Id>();
public void Attachment(){
String str1=ApexPages.currentPage().getParameters().get('id');
system.debug('---line81'+str1);
for(string st:str1.split(',')){
contactid.add(st);
}
AttachmentList=[select Id,Name,Body,BodyLength,ContentType,ParentId from Attachment where ParentId IN:contactId];
system.debug('AttachmentList'+AttachmentList);
}
public void HideShow(){
system.debug('selectAttachment'+selectAttachment);
if(selectAttachment=='Attachment'){
Attc=True;
Docu=False;
SysFil=False;
Attachment();
}
else if(selectAttachment=='Document'){
Attc=False;
Docu=True;
SysFil=False;
}
else if(selectAttachment=='System File'){
Attc=False;
Docu=False;
SysFil=True;
}
}
public pageReference Send(){
return null;
}
public pageReference Cancel(){
return null;
}
public void FirstPage(){
disable=false;
OffsetSize = 0;
showContact();
}
public void previous(){
disable=false;
OffsetSize = OffsetSize - LimitSize;
showContact();
}
public void next(){
OffsetSize = OffsetSize + LimitSize;
showContact();
}
public void LastPage(){
disable=true;
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
showContact();
}
public boolean getprev(){
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt(){
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
public pageReference Save(){
return null;
}
public class WrapperClass {
public Boolean checked {get;set;}
public contact con {get;set;}
public WrapperClass(contact con) {
this.con=con;
checked=false;
}
}
}
EmailDetail page
<apex:page controller="SearchRecords" showHeader="false" sidebar="false">
<script>
function openPopup(){
window.open('/apex/AttachmentPage','mywindow','width=600,height=400');
}
</script>
<apex:form >
<apex:pageBlock title="Send Email To Selected Contacts">
<div align="Middle">
<apex:commandButton value="Send" action="{!Send}" />
<apex:commandButton value="Add File" onclick="openPopup();return false;"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</div>
<apex:pageBlockSection title="Email" columns="1">
<apex:repeat value="{!listWrapper1}" var="wrap">
To:<apex:outputfield value="{!wrap.con.Name}" />
</apex:repeat>
<div class = "requiredInput">
Subject<div class = "requiredBlock"></div>
<apex:inputText title="Subject" required="true"/>
</div>
<apex:inputtextarea label="Body" richtext="true" value="{!Body}" cols="50" rows="15"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
- Gopal Chat
- June 12, 2018
- Like
- 0
My test class is not covering hole code
for(Appointments__c app :trigger.new){
if(app.Confirmed_Date_of_Appointment__c!=Null){
app.Confirmed_DateofAppointment__c = string.valueOf(app.Confirmed_Date_of_Appointment__c);
}
if(trigger.isInsert){
String lastDigit = '';
List<String> nameFormat = new List<String>();
List<Appointments__c> appn = [SELECT Id, Name, CreatedDate FROM Appointments__c
WHERE CreatedDate =THIS_YEAR ORDER BY CreatedDate DESC LIMIT 1];
Integer i=0;
string year=string.valueOf(System.today().year());
string test= year+'-';
if(appn.size()>0 && appn[0].Name.contains(test)){
if(appn[0].Name != Null)
nameFormat = String.valueOf(appn[0].Name).Split('-');
lastDigit = nameFormat[1];
i = Integer.valueOf(lastDigit);
system.debug('>>>>>>>>>'+i);
}
for(Appointments__c appoint:Trigger.new){
if(appn.size()>0 && appn[0].Name.contains(test)){
if(i>0 && i<9){
i +=1;
appoint.Name = year+'-'+'0000'+String.ValueOf(i);
}
else if(i>=9 && i<99){
i +=1;
appoint.Name = year+'-'+'000'+String.ValueOf(i);
}
else if(i>=99 && i<999){
i +=1;
appoint.Name = year+'-'+'00'+String.ValueOf(i);
}
else if(i>=999 && i<9999){
i +=1;
appoint.Name = year+'-'+'0'+String.ValueOf(i);
}
else if(i>=9999){
i+=1;
appoint.Name = year+'-'+String.ValueOf(i);
}
}
else{
appoint.Name = year+'-'+'00001';
}
system.debug('appoint.Name----------->'+appoint.Name);
}
}
}
}
@isTest
public class AppointmentConfirmdateChangeFormatTest {
@isTest
public static void testMthd(){
Id acId = Schema.getGlobalDescribe().get('Account').getDescribe().getRecordTypeInfosByName().get('Non-Accredited Doctors').getRecordTypeId();
Account acc = new Account();
acc.RecordTypeId = acId;
acc.Name = 'Test';
insert acc;
Id docRecord = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Doctors').getRecordTypeId();
Account testAcc3 = new Account();
testAcc3.RecordTypeId = docRecord;
testAcc3.LastName = 'Test Account';
testAcc3.Gender__c = 'Male';
testAcc3.Nationality__c = 'Singapore';
insert testAcc3;
Id caseId = Schema.getGlobalDescribe().get('Case').getDescribe().getRecordTypeInfosByName().get('Business Development').getRecordTypeId();
Case c = new Case();
c.RecordTypeId = caseId;
c.AccountId = acc.Id;
c.Actual_Request_Date__c = System.today();
c.Origin = 'Phone';
c.Status = 'Closed';
insert c;
Appointments__c appt = new Appointments__c();
appt.Name=system.today().year()+'-'+'00099';
appt.Case_Ref__c = c.Id;
appt.Doctors__c = testAcc3.id;
appt.Confirmed_Date_of_Appointment__c = System.now();
insert appt;
Appointments__c appt1 = new Appointments__c();
appt1.Name=system.today().year()+'-'+'00099';
appt1.Case_Ref__c = c.Id;
appt1.Doctors__c = testAcc3.id;
appt1.Confirmed_Date_of_Appointment__c = System.now();
insert appt1;
appt.Name=system.today().year()+'-'+'00098';
update appt;
Appointments__c appt2 = new Appointments__c();
appt2.Name=system.today().year()+'-'+'00999';
appt2.Case_Ref__c = c.Id;
appt2.Doctors__c = testAcc3.id;
appt2.Confirmed_Date_of_Appointment__c = System.now();
insert appt2;
appt2.Name=system.today().year()+'-'+'00998';
update appt;
}
}
- Gopal Chat
- June 03, 2018
- Like
- 0
How to implement send email button
Onclick of Attach a File button open a new window
Here is code
<apex:page controller="SearchRecords" showHeader="true" >
<apex:form id="frm">
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
<apex:commandButton action="{!searchRecords}" value="Search" id="theSearch" reRender="frm"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Detail" id="pb">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" name="group1" reRender="{!display}" />
<apex:actionSupport event="onclick" action="{!newClick}" reRender="conSection" >
<apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
</apex:actionSupport>
</apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.Phone}" />
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:outputPanel id="conSection">
<apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
<apex:outputPanel rendered="{!listWrapper.size != 0}">
<div align="center" draggable="false" >
<apex:commandButton value="Send Email" action="{!SendEmail}" />
<apex:commandButton value="Print Detail" action="{!PrintDetail}" />
</div>
<apex:pageBlockTable value="{!listWrapper}" id="pbt1" var="wrap">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
</apex:column>
<apex:column value="{!wrap.con.Name}"/>
<apex:column value="{!wrap.con.Phone}"/>
<apex:column value="{!wrap.con.Email}"/>
<apex:column value="{!wrap.con.Account.Name}"/>
<apex:column value="{!wrap.con.AccountId}"/>
<apex:column value="{!wrap.con.Id}"/>
</apex:pageBlockTable>
<apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
<apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled="{!disable}"/>
</apex:outputPanel>
<apex:outputPanel rendered="{!listWrapper.size == 0}">
<b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageblock>
</apex:form>
</apex:page>
public class SearchRecords {
public boolean display{get;set;}
public boolean disable{get;set;}
public String AccId{get;set;}
public string getstring{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> conList{get;set;}
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize=3;
public contact con{get;set;}
public void searchRecords(){
display=false;
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public List<WrapperClass> listWrapper {get;set;}
public List<WrapperClass> listWrapper1 {get;set;}
public void newClick(){
disable=false;
LimitSize=3;
OffsetSize=0;
showContact();
}
public void showContact(){
display=true;
listWrapper = new List<WrapperClass>();
List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize];
if(conlist!=NULL){
totalRecs = conlist.size();
for(contact con:conlist)
{
listWrapper.add(new WrapperClass(con));
}
}
}
public pageReference SendEmail(){
return null;
}
public pageReference PrintDetail(){
listWrapper1=new list<WrapperClass>();
for(WrapperClass wr: listWrapper){
if(wr.checked==true)
listWrapper1.add(wr);
}
PageReference acctPage = new pageReference('/Apex/printContactDetail');
return acctPage;
}
public void FirstPage(){
disable=false;
OffsetSize = 0;
showContact();
}
public void previous(){
disable=false;
OffsetSize = OffsetSize - LimitSize;
showContact();
}
public void next(){
OffsetSize = OffsetSize + LimitSize;
showContact();
}
public void LastPage(){
disable=true;
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
showContact();
}
public boolean getprev(){
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt(){
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
public class WrapperClass {
public Boolean checked {get;set;}
public contact con {get;set;}
public WrapperClass(contact con) {
this.con=con;
checked=false;
}
}
}
Print detail button code
<apex:page Controller="SearchRecords" renderAs="pdf">
<apex:form>
<apex:pageBlock title="Contact Detail">
<apex:pageBlockTable value="{!listWrapper1}" var="wrap" >
<apex:column value="{!wrap.con.Name}" width="25%"/>
<apex:column value="{!wrap.con.Phone}" width="25%"/>
<apex:column value="{!wrap.con.Email}" width="25%"/>
<apex:column value="{!wrap.con.Account.Name}" width="25%"/>
<apex:column value="{!wrap.con.Id}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
- Gopal Chat
- May 31, 2018
- Like
- 0
Below is my code where I have 4 pagination button,when i select radio button front of account,contact will display,when i reach
<apex:page controller="SearchRecords" showHeader="true" >
<apex:form id="frm">
<!----<apex:actionFunction name="showcon" action="{!showContact}" reRender="frm" /> --->
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
<apex:commandButton action="{!searchRecords}" value="Search" id="theSearch" reRender="frm"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Detail" id="pb">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" name="group1" reRender="{!display}" />
<apex:actionSupport event="onclick" action="{!showContact}" reRender="conSection" >
<apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
</apex:actionSupport>
</apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.Phone}" />
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:outputPanel id="conSection">
<apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
<apex:outputPanel rendered="{!listWrapper.size == 0}">
<b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b>
</apex:outputPanel>
<apex:outputPanel rendered="{!listWrapper.size != 0}">
<div align="center" draggable="false" >
<apex:commandButton value="Send Email" action="{!SendEmail}" />
<apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
</div>
<apex:pageBlockTable value="{!listWrapper}" id="pbt1" var="wrap">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
</apex:column>
<apex:column value="{!wrap.con.Name}"/>
<apex:column value="{!wrap.con.Phone}"/>
<apex:column value="{!wrap.con.Email}"/>
<apex:column value="{!wrap.con.Account.Name}"/>
<apex:column value="{!wrap.con.AccountId}"/>
<apex:column value="{!wrap.con.Id}"/>
</apex:pageBlockTable>
<apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
<apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled=""/>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageblock>
</apex:form>
</apex:page>
public class SearchRecords {
public boolean display{get;set;}
public String AccId{get;set;}
public string getstring{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> conList{get;set;}
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize=6;
public void searchRecords(){
display=false;
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public List<WrapperClass> listWrapper {get;set;}
public void showContact(){
display=true;
listWrapper = new List<WrapperClass>();
List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize];
if(conlist!=NULL){
totalRecs = conlist.size();
for(contact con:conlist)
{
listWrapper.add(new WrapperClass(con));
}
}
}
public class WrapperClass {
public boolean fgjj;
public Boolean checked {get;set;}
public contact con {get;set;}
public WrapperClass(contact con) {
this.con=con;
checked=false;
}
}
public pageReference SendEmail(){
return null;
}
public pageReference PrintDetail(){
return new pageReference('apex/PrintContactDetail');
}
public void FirstPage(){
OffsetSize = 0;
showContact();
}
public void previous(){
OffsetSize = OffsetSize - LimitSize;
showContact();
}
public void next(){
OffsetSize = OffsetSize + LimitSize;
System.debug('>>>>>OffsetSize '+OffsetSize);
showContact();
}
public void LastPage(){
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
system.debug('====>OffsetSize'+OffsetSize);
showContact();
}
public boolean getprev(){
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt(){
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}
- Gopal Chat
- May 30, 2018
- Like
- 0
In my code when i select the last page its showing first page and after reaching last,the message
<apex:page controller="SearchRecords" showHeader="true" >
<apex:form id="frm">
<!----<apex:actionFunction name="showcon" action="{!showContact}" reRender="frm" /> --->
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
<apex:commandButton action="{!searchRecords}" value="Search" id="theSearch" reRender="frm"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Detail" id="pb">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" name="group1" reRender="frm"/>
<apex:actionSupport event="onclick" action="{!showContact}" reRender="frm" >
<apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
</apex:actionSupport>
</apex:column>
<apex:column value="{!acc.Name}" />
<apex:column value="{!acc.Phone}" />
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
<apex:outputPanel rendered="{!listWrapper.size == 0}">
<b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b>
</apex:outputPanel>
<apex:outputPanel rendered="{!listWrapper.size != 0}">
<div align="center" draggable="false" >
<apex:commandButton value="Send Email" action="{!SendEmail}" />
<apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
</div>
<apex:pageBlockTable value="{!listWrapper}" var="wrap">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
</apex:column>
<apex:column value="{!wrap.con.Name}"/>
<apex:column value="{!wrap.con.Phone}"/>
<apex:column value="{!wrap.con.Email}"/>
<apex:column value="{!wrap.con.Account.Name}"/>
<apex:column value="{!wrap.con.AccountId}"/>
<apex:column value="{!wrap.con.Id}"/>
</apex:pageBlockTable>
<apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
<apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled=""/>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
public class SearchRecords {
public boolean display{get;set;}
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize=5;
public String AccId{get;set;}
public string getstring{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> conList{get;set;}
public void searchRecords(){
display=false;
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public List<WrapperClass> listWrapper {get;set;}
public void showContact()
{
display=true;
listWrapper = new List<WrapperClass>();
List<Contact> conlist = [SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize ];
if(conlist.size()>0)
{
for(contact con:conlist)
{
listWrapper.add(new WrapperClass(con));
}
}
}
public class WrapperClass
{
public boolean fgjj;
public Boolean checked {get;set;}
public contact con {get;set;}
public WrapperClass(contact con)
{
this.con=con;
checked=false;
}
}
public pageReference SendEmail(){
return null;
}
public pageReference PrintDetail(){
return new pageReference('apex/PrintContactDetail');
}
public void FirstPage(){
OffsetSize = 0;
showContact();
}
public void previous(){
OffsetSize = OffsetSize - LimitSize;
showContact();
}
public void next(){
OffsetSize = OffsetSize + LimitSize;
System.debug('>>>>>OffsetSize '+OffsetSize);
showContact();
}
public void LastPage(){
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
system.debug('====>OffsetSize'+OffsetSize);
showContact();
}
public boolean getprev(){
showContact();
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt(){
showContact();
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}
- Gopal Chat
- May 28, 2018
- Like
- 0
Want to set checkbox on contact which are displayed on radion button
<apex:page controller="SearchRecords" showHeader="true" >
<apex:form id="frm">
<!----<apex:actionFunction name="showcon" action="{!showContact}" reRender="frm" /> --->
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
<apex:commandButton action="{!searchRecords}" value="Search" id="theSearch" reRender="frm"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Detail">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" name="group1"/>
<apex:actionSupport event="onclick" action="{!dispalyContact}" ReRender="conpgblk" >
<apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
</apex:actionSupport>
</apex:column>
<apex:column value="{!acc.Name}" />
<apex:column value="{!acc.Phone}" />
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Related Contact" id="conpgblk" >
<apex:outputPanel rendered="{!conList.size == 0}">
<b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b>
</apex:outputPanel>
<apex:outputPanel rendered="{!conList.size != 0}">
<div align="center" draggable="false" >
<apex:commandButton value="Send Email" action="{!SendEmail}"/>
<apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
</div>
<apex:pageBlockTable value="{!conList}" var="con">
<apex:column value="{!con.Name}"/>
<apex:column value="{!con.Phone}"/>
<apex:column value="{!con.Email}"/>
</apex:pageBlockTable>
<apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
<apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled=""/>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Controller
public class SearchRecords {
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize=3;
public String AccId{get;set;}
public string getstring{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> conList{get;set;}
public void searchRecords(){
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public void dispalyContact() {
System.debug('>>>>>OffsetSize '+OffsetSize+'>>>>>'+LimitSize);
if(AccId != null)
conList=[SELECT id,Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize ];
system.debug('====>'+conList);
}
public pageReference SendEmail(){
return null;
}
public pageReference PrintDetail(){
return null;
}
public void FirstPage()
{
OffsetSize = 0;
dispalyContact();
}
public void previous()
{
OffsetSize = OffsetSize - LimitSize;
dispalyContact();
}
public void next()
{
OffsetSize = OffsetSize + LimitSize;
System.debug('>>>>>OffsetSize '+OffsetSize);
dispalyContact();
}public void LastPage()
{
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
}
public boolean getprev()
{
dispalyContact();
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt()
{
dispalyContact();
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}
- Gopal Chat
- May 25, 2018
- Like
- 0
When I select a account from radio button ,related contact will display, In my code all contacts records are displaying
<apex:form id="frm">
<apex:actionFunction name="showcon" action="{!showContact}" reRender="frm" />
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
</apex:pageBlockSection>
<apex:commandButton action="{!searchRecords}" value="Search" id="theSearch" reRender="frm"/>
<apex:pageBlockSection title="Account Detail">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" onclick="showcon()"/>
</apex:column>
<apex:column value="{!acc.name}" headerValue="Account Name"/>
<apex:column value="{!acc.Phone}" headerValue="Phone"/>
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Related Contact">
<apex:pageBlockTable value="{!Contactlist}" var="con">
<apex:column value="{!con.Name}" headerValue="Contact Name"/>
<apex:column value="{!con.Phone}" headerValue="Phone"/>
<apex:column value="{!con.Email}" headerValue="Email"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
public class SearchRecords {
public String AccId{get;set;}
public string getstring{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> Contactlist{get;set;}
public void searchRecords(){
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public void showContact(){
Contactlist=[select Id,Name,Email,Phone from contact where accountId =:Accid];
}
}
- Gopal Chat
- May 24, 2018
- Like
- 0
Salesforce Trigger is not working, anyone help me with this code
Fields :
1. First Name
2. Last name
3. Email
4. Phone
5. Status (In Progress , Completed , Rejected)
6. Candidate (Contact Lookup)
7. Description
Create Trigger on Hire_form__c
1. When hire_form__c record is insert set status = ‘In Progress’. Create new contact record with firstname , lastname , email, phone. Set contact id in Candidate field on Hire_form object. Create new case record for new created contact record. Set status in case = ‘New’.
2. When Hire_form is updated with status = ‘Completed’ , then update the status of related case ‘Closed’.
Create Trigger on Case
1. When case is updated with Status = ‘Closed’ , then check if parent contact’s related hire form status is not ‘Completed’ , then show error message ‘You can not close the case until hire form is completed’.
- Gopal Chat
- May 11, 2018
- Like
- 0
Component not updating the record on save button
<aura:attribute name="searchKeyword" type="String" default=""/>
<aura:attribute name="lstOfAccount" type="Account[]"/>
<aura:attribute name="listcontact" type="Contact[]"/>
<aura:attribute name="columns" type="List"/>
<aura:attribute name="isBlank" type="boolean" default="false"/>
<aura:attribute name="recordId" type="String"/>
<aura:attribute name="updatedRecord" type="Object[]" />
<div class="slds-m-around_medium" style="background:#fff">
<lightning:layout>
<lightning:layoutItem padding="around-small">
<lightning:spinner variant="brand" size="medium" aura:id="Id_spinner" class="slds-hide" />
<h1 class="slds-page-header__title slds-truncate slds-align-middle"
title="Enter Account Name">Enter Account Name</h1>
<lightning:input value="{!v.searchKeyword}" required="true" aura:id="searchKeyword"/>
</lightning:layoutItem>
</lightning:layout>
<lightning:layout>
<lightning:layoutItem size="2" padding="around-small">
<lightning:button onclick="{!c.Search}" variant="brand" label="Search" iconName="utility:search"/>
</lightning:layoutItem>
</lightning:layout>
<aura:if isTrue="{!and(v.isBlank, v.lstOfAccount!=NULL)}">
<lightning:card title="Account Records" variant="brand">
<lightning:datatable columns="{! v.columns }" data="{!v.lstOfAccount}"
hideCheckboxColumn="true" keyField="Id" onsave ="{!c.Save}"/>
</lightning:card>
</aura:if>
</div>
</aura:component>
({
Search : function(component, event, helper) {
component.set('v.columns', [
{label: 'Name', fieldName: 'Name', editable:'true', type: 'text'},
{label: 'Phone', fieldName: 'Phone', editable:'true', type: 'Phone'},
{label: 'Industry', fieldName: 'Industry', editable:'true', type: 'text'}]);
var action = component.get("c.fetchAccount");
action.setParams({
"searchKeyWord" : component.get("v.searchKeyword")
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
component.set("v.lstOfAccount", response.getReturnValue());
component.set("v.isBlank",true);
if(response.getReturnValue()==null){
var toast = $A.get("e.force:showToast");
toast.setParams({
"type":"Error",
"title":"Error",
"message":"No Account Found",
"duration":1000
});
toast.fire();
}
}
});
$A.enqueueAction(action);
},
Save : function (component,event,helper){
var action=component.get("c.saveAccount");
action.setParams({
"AccListStr":JSON.stringify(component.get("v.lstOfAccount"))
});
action.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
component.set("v.lstOfAccount", response.getReturnValue());
alert(response.getReturnValue());
var toast = $A.get("e.force:showToast");
toast.setParams({
"type":"Success",
"title":"Success",
"message":"Account Saved Successfully",
"duration":1000
});
toast.fire();
}
});
$A.enqueueAction(action);
}
})
public class AccountSearchController{
@AuraEnabled
public static List <Account> fetchAccount(String searchKeyWord) {
String searchKey = searchKeyWord +'%';
List <Account> lstOfAccount = [SELECT Id, Name,Phone,Industry FROM Account
WHERE Name LIKE:searchKey];
system.debug('==>'+lstOfAccount);
if(lstOfAccount.size() > 0)
return lstOfAccount;
else return null;
}
@auraEnabled
public static List<Account> saveAccount(String AccListStr){
List<Account> accList = (List<Account>)json.deserialize(AccListStr, List<Account>.class);
update accList;
system.debug('===>accList'+accList);
return accList;
}
}
- Gopal Chat
- September 11, 2018
- Like
- 0
Test Class Running - Error Exception 'System.QueryException: List has no rows for assignment to SObject'
I created this class
public class LNC01_Opp_Bonlivraison { @AuraEnabled public static String getAccountWeather(Id oppid) { try { //Recupetation Opportunity Id Opportunity opp = [SELECT id, AccountId, createddate, OwnerId, Traitement_Fiscal__c,Pricebook2Id FROM Opportunity WHERE Id=:oppid]; system.debug('oppid '+opp.id); //Recuperation de type de transaction Bon de livraison s2cor__Sage_INV_Trade_Document_Type__c typetransaction = [select id from s2cor__Sage_INV_Trade_Document_Type__c where name = :label.LNC_BonLivraison]; if (opp != null || Test.isRunningTest()) { //Creation Nouvelle transaction s2cor__Sage_INV_Trade_Document__c Newtransaction = new s2cor__Sage_INV_Trade_Document__c(); Date myDate = date.newinstance(opp.createddate.year(), opp.createddate.month(), opp.createddate.day()); Newtransaction.s2cor__Account__c= opp.AccountId; Newtransaction.Opportunite__c= oppid; Newtransaction.s2cor__Date__c= myDate; Newtransaction.OwnerId= opp.OwnerId; Newtransaction.s2cor__Tax_Treatment__c= opp.Traitement_Fiscal__c; Newtransaction.s2cor__Trade_Document_Type__c= typetransaction.id; Newtransaction.s2cor__Price_Book__c = opp.Pricebook2Id; insert Newtransaction; system.debug('Newtransaction '+Newtransaction.id); //Creation nouvelles lignes de transaction List<OpportunityLineItem> Opplineitem = [select id,Product2Id,Quantity,Dimension_Tag_Analytique__c,Dimension_Tag_budget__c,Dimension_Tag_BUDGET1__c,Dimension_Tag_BUDGET2__c from OpportunityLineItem where OpportunityId= :opp.id]; system.debug('Opplineitemsize '+Opplineitem.size()); id Product_Tag = NULL; list <s2cor__Sage_INV_Trade_Document_Item__c> listtransactionlinetoupdate = new list <s2cor__Sage_INV_Trade_Document_Item__c>(); for (OpportunityLineItem Opplineit : Opplineitem){ s2cor__Sage_INV_Trade_Document_Item__c transactionlinetoupdate = new s2cor__Sage_INV_Trade_Document_Item__c(); transactionlinetoupdate.s2cor__Trade_Document__c= Newtransaction.id; transactionlinetoupdate.s2cor__Product__c= Opplineit.Product2Id; transactionlinetoupdate.s2cor__Quantity__c = Opplineit.Quantity; listtransactionlinetoupdate.add(transactionlinetoupdate); } system.debug('listtransacsizetionlinetoupdate '+listtransactionlinetoupdate.size()); insert listtransactionlinetoupdate; } return '{"succes": "}'; }catch(Exception ex){ system.debug('Exception '+ex); return '{"error": "}'; } } }
and her test class:
@istest public class LNC01_Opp_Bonlivraison_Test { static testMethod void theTests(){ Opportunity Opp = new Opportunity(); Opp.name = 'testopp1'; Opp.StageName = '1 Pre-Qualified'; Opp.CloseDate= system.today(); Opp.AccountId = '001D0000024cW2MIAU'; insert Opp; LNC01_Opp_Bonlivraison.getAccountWeather(Opp.id); } }
I have this error when running test class:
Exception System.QueryException: List has no rows for assignment to SObject
- AichaSF
- August 10, 2018
- Like
- 0
- Force.platform
- August 10, 2018
- Like
- 0
Page is not working
But In EmailDetail page selected contact is not showing.
Here is code
<apex:page controller="SearchRecords" showHeader="false" sidebar="false" >
<apex:form id="frm">
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
<apex:commandButton action="{!searchRecord}" value="Search" id="theSearch" reRender="frm"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Detail" id="pb">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" name="group1" reRender="{!display}" />
<apex:actionSupport event="onclick" action="{!newClick}" reRender="conSection" >
<apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
</apex:actionSupport>
</apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.Phone}"/>
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:outputPanel id="conSection">
<apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
<apex:outputPanel rendered="{!listWrapper.size != 0}">
<div align="center" >
<apex:commandButton value="Send Email" action="{!SendEmail}"/>
<apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
</div>
<apex:pageBlockTable value="{!listWrapper}" id="pbt1" var="wrap">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
</apex:column>
<apex:column value="{!wrap.con.Name}"/>
<apex:column value="{!wrap.con.Phone}"/>
<apex:column value="{!wrap.con.Email}"/>
<apex:column value="{!wrap.con.Account.Name}"/>
<apex:column value="{!wrap.con.AccountId}"/>
<apex:column value="{!wrap.con.Id}"/>
</apex:pageBlockTable>
<apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
<apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled="{!disable}"/>
</apex:outputPanel>
<apex:outputPanel rendered="{!listWrapper.size == 0}">
<b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageblock>
</apex:form>
</apex:page>
public class SearchRecords {
public boolean display{get;set;}
public boolean disable{get;set;}
public String AccId{get;set;}
public string getstring{get;set;}
public string selectedvalie{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> conList{get;set;}
public list<Attachment> AttachmentList{get;set;}
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize=3;
public contact con{get;set;}
public Attachment Att{get;set;}
public string Body{get;set;}
public string Subject{get;set;}
public string selectAttachment{get;set;}
public boolean Attc{get;set;}
public boolean Docu{get;set;}
public boolean SysFil{get;set;}
public List<WrapperClass> listWrapper {get;set;}
public List<WrapperClass> listWrapper1 {get;set;}
public void searchRecord(){
display=False;
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public void newClick(){
disable=false;
LimitSize=3;
OffsetSize=0;
showContact();
}
public void showContact(){
display=true;
listWrapper = new List<WrapperClass>();
List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize];
if(conlist!=NULL){
totalRecs = conlist.size();
for(contact con:conlist)
{
listWrapper.add(new WrapperClass(con));
}
}
}
public pageReference PrintDetail(){
listWrapper1=new list<WrapperClass>();
for(WrapperClass wr: listWrapper){
if(wr.checked==true)
listWrapper1.add(wr);
}
pageReference acctPage = new pageReference('/Apex/printContactDetail');
return acctPage;
}
public pageReference SendEmail(){
listWrapper1=new list<WrapperClass>();
String str='';
for(WrapperClass wr: listWrapper){
if(wr.checked==true){
listWrapper1.add(wr);
str+=wr.con.id+',';
}
system.debug('====>listWrapper1'+listWrapper1);
}
str=str.removeEnd(',');
pageReference EmailPage = new pageReference('/Apex/EmailDetail?id='+str);
emailPage.setRedirect(true);
return EmailPage;
}
public pageReference AddFile(){
String str=ApexPages.currentPage().getParameters().get('id');
PageReference acctPage = new pageReference('/Apex/AttachmentPage?id='+str);
return acctPage;
}
set<id> contactId=new set<Id>();
public void Attachment(){
String str1=ApexPages.currentPage().getParameters().get('id');
system.debug('---line81'+str1);
for(string st:str1.split(',')){
contactid.add(st);
}
AttachmentList=[select Id,Name,Body,BodyLength,ContentType,ParentId from Attachment where ParentId IN:contactId];
system.debug('AttachmentList'+AttachmentList);
}
public void HideShow(){
system.debug('selectAttachment'+selectAttachment);
if(selectAttachment=='Attachment'){
Attc=True;
Docu=False;
SysFil=False;
Attachment();
}
else if(selectAttachment=='Document'){
Attc=False;
Docu=True;
SysFil=False;
}
else if(selectAttachment=='System File'){
Attc=False;
Docu=False;
SysFil=True;
}
}
public pageReference Send(){
return null;
}
public pageReference Cancel(){
return null;
}
public void FirstPage(){
disable=false;
OffsetSize = 0;
showContact();
}
public void previous(){
disable=false;
OffsetSize = OffsetSize - LimitSize;
showContact();
}
public void next(){
OffsetSize = OffsetSize + LimitSize;
showContact();
}
public void LastPage(){
disable=true;
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
showContact();
}
public boolean getprev(){
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt(){
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
public pageReference Save(){
return null;
}
public class WrapperClass {
public Boolean checked {get;set;}
public contact con {get;set;}
public WrapperClass(contact con) {
this.con=con;
checked=false;
}
}
}
EmailDetail page
<apex:page controller="SearchRecords" showHeader="false" sidebar="false">
<script>
function openPopup(){
window.open('/apex/AttachmentPage','mywindow','width=600,height=400');
}
</script>
<apex:form >
<apex:pageBlock title="Send Email To Selected Contacts">
<div align="Middle">
<apex:commandButton value="Send" action="{!Send}" />
<apex:commandButton value="Add File" onclick="openPopup();return false;"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</div>
<apex:pageBlockSection title="Email" columns="1">
<apex:repeat value="{!listWrapper1}" var="wrap">
To:<apex:outputfield value="{!wrap.con.Name}" />
</apex:repeat>
<div class = "requiredInput">
Subject<div class = "requiredBlock"></div>
<apex:inputText title="Subject" required="true"/>
</div>
<apex:inputtextarea label="Body" richtext="true" value="{!Body}" cols="50" rows="15"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
- Gopal Chat
- June 12, 2018
- Like
- 0
Below is my code where I have 4 pagination button,when i select radio button front of account,contact will display,when i reach
<apex:page controller="SearchRecords" showHeader="true" >
<apex:form id="frm">
<!----<apex:actionFunction name="showcon" action="{!showContact}" reRender="frm" /> --->
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
<apex:commandButton action="{!searchRecords}" value="Search" id="theSearch" reRender="frm"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Detail" id="pb">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" name="group1" reRender="{!display}" />
<apex:actionSupport event="onclick" action="{!showContact}" reRender="conSection" >
<apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
</apex:actionSupport>
</apex:column>
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.Phone}" />
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:outputPanel id="conSection">
<apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
<apex:outputPanel rendered="{!listWrapper.size == 0}">
<b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b>
</apex:outputPanel>
<apex:outputPanel rendered="{!listWrapper.size != 0}">
<div align="center" draggable="false" >
<apex:commandButton value="Send Email" action="{!SendEmail}" />
<apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
</div>
<apex:pageBlockTable value="{!listWrapper}" id="pbt1" var="wrap">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
</apex:column>
<apex:column value="{!wrap.con.Name}"/>
<apex:column value="{!wrap.con.Phone}"/>
<apex:column value="{!wrap.con.Email}"/>
<apex:column value="{!wrap.con.Account.Name}"/>
<apex:column value="{!wrap.con.AccountId}"/>
<apex:column value="{!wrap.con.Id}"/>
</apex:pageBlockTable>
<apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
<apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled=""/>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageblock>
</apex:form>
</apex:page>
public class SearchRecords {
public boolean display{get;set;}
public String AccId{get;set;}
public string getstring{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> conList{get;set;}
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize=6;
public void searchRecords(){
display=false;
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public List<WrapperClass> listWrapper {get;set;}
public void showContact(){
display=true;
listWrapper = new List<WrapperClass>();
List<Contact> conlist =[SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize];
if(conlist!=NULL){
totalRecs = conlist.size();
for(contact con:conlist)
{
listWrapper.add(new WrapperClass(con));
}
}
}
public class WrapperClass {
public boolean fgjj;
public Boolean checked {get;set;}
public contact con {get;set;}
public WrapperClass(contact con) {
this.con=con;
checked=false;
}
}
public pageReference SendEmail(){
return null;
}
public pageReference PrintDetail(){
return new pageReference('apex/PrintContactDetail');
}
public void FirstPage(){
OffsetSize = 0;
showContact();
}
public void previous(){
OffsetSize = OffsetSize - LimitSize;
showContact();
}
public void next(){
OffsetSize = OffsetSize + LimitSize;
System.debug('>>>>>OffsetSize '+OffsetSize);
showContact();
}
public void LastPage(){
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
system.debug('====>OffsetSize'+OffsetSize);
showContact();
}
public boolean getprev(){
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt(){
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}
- Gopal Chat
- May 30, 2018
- Like
- 0
In my code when i select the last page its showing first page and after reaching last,the message
<apex:page controller="SearchRecords" showHeader="true" >
<apex:form id="frm">
<!----<apex:actionFunction name="showcon" action="{!showContact}" reRender="frm" /> --->
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
<apex:commandButton action="{!searchRecords}" value="Search" id="theSearch" reRender="frm"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Detail" id="pb">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" name="group1" reRender="frm"/>
<apex:actionSupport event="onclick" action="{!showContact}" reRender="frm" >
<apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
</apex:actionSupport>
</apex:column>
<apex:column value="{!acc.Name}" />
<apex:column value="{!acc.Phone}" />
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Related Contact" id="conpgblk" rendered="{!display}" >
<apex:outputPanel rendered="{!listWrapper.size == 0}">
<b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b>
</apex:outputPanel>
<apex:outputPanel rendered="{!listWrapper.size != 0}">
<div align="center" draggable="false" >
<apex:commandButton value="Send Email" action="{!SendEmail}" />
<apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
</div>
<apex:pageBlockTable value="{!listWrapper}" var="wrap">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!wrap.checked}" id="inputBox"/>
</apex:column>
<apex:column value="{!wrap.con.Name}"/>
<apex:column value="{!wrap.con.Phone}"/>
<apex:column value="{!wrap.con.Email}"/>
<apex:column value="{!wrap.con.Account.Name}"/>
<apex:column value="{!wrap.con.AccountId}"/>
<apex:column value="{!wrap.con.Id}"/>
</apex:pageBlockTable>
<apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
<apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled=""/>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
public class SearchRecords {
public boolean display{get;set;}
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize=5;
public String AccId{get;set;}
public string getstring{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> conList{get;set;}
public void searchRecords(){
display=false;
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public List<WrapperClass> listWrapper {get;set;}
public void showContact()
{
display=true;
listWrapper = new List<WrapperClass>();
List<Contact> conlist = [SELECT id,Title,Fax,Birthdate,Name,Account.Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize ];
if(conlist.size()>0)
{
for(contact con:conlist)
{
listWrapper.add(new WrapperClass(con));
}
}
}
public class WrapperClass
{
public boolean fgjj;
public Boolean checked {get;set;}
public contact con {get;set;}
public WrapperClass(contact con)
{
this.con=con;
checked=false;
}
}
public pageReference SendEmail(){
return null;
}
public pageReference PrintDetail(){
return new pageReference('apex/PrintContactDetail');
}
public void FirstPage(){
OffsetSize = 0;
showContact();
}
public void previous(){
OffsetSize = OffsetSize - LimitSize;
showContact();
}
public void next(){
OffsetSize = OffsetSize + LimitSize;
System.debug('>>>>>OffsetSize '+OffsetSize);
showContact();
}
public void LastPage(){
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
system.debug('====>OffsetSize'+OffsetSize);
showContact();
}
public boolean getprev(){
showContact();
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt(){
showContact();
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}
- Gopal Chat
- May 28, 2018
- Like
- 0
Want to set checkbox on contact which are displayed on radion button
<apex:page controller="SearchRecords" showHeader="true" >
<apex:form id="frm">
<!----<apex:actionFunction name="showcon" action="{!showContact}" reRender="frm" /> --->
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
<apex:commandButton action="{!searchRecords}" value="Search" id="theSearch" reRender="frm"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Account Detail">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" name="group1"/>
<apex:actionSupport event="onclick" action="{!dispalyContact}" ReRender="conpgblk" >
<apex:param assignTo="{!AccId}" name="accname" value="{!acc.id}"/>
</apex:actionSupport>
</apex:column>
<apex:column value="{!acc.Name}" />
<apex:column value="{!acc.Phone}" />
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Related Contact" id="conpgblk" >
<apex:outputPanel rendered="{!conList.size == 0}">
<b> NO RELATED CONTACTS FOR THIS ACCOUNT.</b>
</apex:outputPanel>
<apex:outputPanel rendered="{!conList.size != 0}">
<div align="center" draggable="false" >
<apex:commandButton value="Send Email" action="{!SendEmail}"/>
<apex:commandButton value="Print Detail" action="{!PrintDetail}"/>
</div>
<apex:pageBlockTable value="{!conList}" var="con">
<apex:column value="{!con.Name}"/>
<apex:column value="{!con.Phone}"/>
<apex:column value="{!con.Email}"/>
</apex:pageBlockTable>
<apex:commandButton value="First Page" rerender="conpgblk" action="{!FirstPage}" disabled="{!prev}"/>
<apex:commandButton value="Previous" rerender="conpgblk" action="{!previous}" disabled="{!prev}"/>
<apex:commandButton value="Next" rerender="conpgblk" action="{!next}" disabled=""/>
<apex:commandButton value="Last Page" rerender="conpgblk" action="{!LastPage}" disabled=""/>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Controller
public class SearchRecords {
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize=3;
public String AccId{get;set;}
public string getstring{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> conList{get;set;}
public void searchRecords(){
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,AccountNumber,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public void dispalyContact() {
System.debug('>>>>>OffsetSize '+OffsetSize+'>>>>>'+LimitSize);
if(AccId != null)
conList=[SELECT id,Name,Phone,Email FROM Contact WHERE AccountId=:AccId LIMIT :LimitSize OFFSET :OffsetSize ];
system.debug('====>'+conList);
}
public pageReference SendEmail(){
return null;
}
public pageReference PrintDetail(){
return null;
}
public void FirstPage()
{
OffsetSize = 0;
dispalyContact();
}
public void previous()
{
OffsetSize = OffsetSize - LimitSize;
dispalyContact();
}
public void next()
{
OffsetSize = OffsetSize + LimitSize;
System.debug('>>>>>OffsetSize '+OffsetSize);
dispalyContact();
}public void LastPage()
{
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
}
public boolean getprev()
{
dispalyContact();
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnxt()
{
dispalyContact();
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}
- Gopal Chat
- May 25, 2018
- Like
- 0
When I select a account from radio button ,related contact will display, In my code all contacts records are displaying
<apex:form id="frm">
<apex:actionFunction name="showcon" action="{!showContact}" reRender="frm" />
<apex:pageblock >
<apex:pageBlockSection title="Search Account Records" columns="1">
Enter Name<apex:inputText value="{!getstring}" id="theTextInput"/>
</apex:pageBlockSection>
<apex:commandButton action="{!searchRecords}" value="Search" id="theSearch" reRender="frm"/>
<apex:pageBlockSection title="Account Detail">
<apex:pageBlocktable value="{!accountlist}" var="acc">
<apex:column >
<input type="radio" onclick="showcon()"/>
</apex:column>
<apex:column value="{!acc.name}" headerValue="Account Name"/>
<apex:column value="{!acc.Phone}" headerValue="Phone"/>
</apex:pageBlocktable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Related Contact">
<apex:pageBlockTable value="{!Contactlist}" var="con">
<apex:column value="{!con.Name}" headerValue="Contact Name"/>
<apex:column value="{!con.Phone}" headerValue="Phone"/>
<apex:column value="{!con.Email}" headerValue="Email"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
public class SearchRecords {
public String AccId{get;set;}
public string getstring{get;set;}
public List<Account> accountlist {get;set;}
public list<Contact> Contactlist{get;set;}
public void searchRecords(){
accountlist= new list<Account>();
if(getstring!=null){
accountlist= Database.query('select id,name,Phone from Account where name like \'%'+getstring+'%\'');
}
}
public void showContact(){
Contactlist=[select Id,Name,Email,Phone from contact where accountId =:Accid];
}
}
- Gopal Chat
- May 24, 2018
- Like
- 0
Salesforce Trigger is not working, anyone help me with this code
Fields :
1. First Name
2. Last name
3. Email
4. Phone
5. Status (In Progress , Completed , Rejected)
6. Candidate (Contact Lookup)
7. Description
Create Trigger on Hire_form__c
1. When hire_form__c record is insert set status = ‘In Progress’. Create new contact record with firstname , lastname , email, phone. Set contact id in Candidate field on Hire_form object. Create new case record for new created contact record. Set status in case = ‘New’.
2. When Hire_form is updated with status = ‘Completed’ , then update the status of related case ‘Closed’.
Create Trigger on Case
1. When case is updated with Status = ‘Closed’ , then check if parent contact’s related hire form status is not ‘Completed’ , then show error message ‘You can not close the case until hire form is completed’.
- Gopal Chat
- May 11, 2018
- Like
- 0
Hi,this is the trigger question,working on insert but not working on delete(before or after) and there is no error message showing
Update the above trigger to delete the Last Name from the Account field when a Contact is deleted without deleteing the other Last name.
trigger AddlastNmaeAccount on Contact (after insert,before delete)
{
if(trigger.isInsert)
{
set<id> s=new set<id>();
list<Account> listaccount=new list<Account>();
for(contact con:trigger.new)
{
s.add(con.accountId);
}
Map<id,account> mv=new Map<id,account>([select id,name from account where id IN:s]);
for(contact cont:trigger.new)
{
Account a=new Account();
a.Id=mv.get(cont.AccountId).id;
a.name=mv.get(cont.AccountId).Name+cont.LastName;
listaccount.add(a);
}
Update listaccount;
}
if(Trigger.isDelete)
{
set<id> s1=new set<id>();
list<Account> listaccount=new list<Account>();
for(Contact oContact : Trigger.Old)
{
if(oContact.lastName!= null)
s1.add(oContact.accountId);
}
Map<id,account> mv=new Map<id,account>([select id,name from account where id IN:s1]);
for(contact cont:trigger.new)
{
Account a=new Account();
a.Id=mv.get(cont.AccountId).id;
a.name=a.name.replace(cont.LastName,a.name);
listaccount.add(a);
}
update listaccount;
}
}
- Gopal Chat
- February 20, 2018
- Like
- 0
How to create a master detail relationship between account and opportunity using visualforce page.when we click on an account related opportunity will display
if anyone has the answer please mail me on amuraghav14@gmail.com
- Gopal Chat
- December 17, 2017
- Like
- 0
Challenge Not yet complete... here's what's wrong: The packingListItem Lightning Component's attribute tag doesn't exist or its attributes are not set correctly.
Here is the challenge:
Create a Lightning Component to display a single item for your packing list.
- Create a component called campingListItem that displays the name (ui:outputText) and the three custom fields using the appropriate output components.
- Add an attribute named 'item' for type Camping_Item__c.
<aura:component > <aura:attribute name="item" type="<my_domain>__Camping_Item__c"/> <ui:outputText value="{!v.item.Name}"/> <ui:outputCheckbox value="{!v.item.<my_domain>__Packed__c}"/> <ui:outputCurrency value="{!v.item.<my_domain>__Price__c}"/> <ui:outputNumber value="{!v.item.<my_domain>__Quantity__c}"/> </aura:component>
The error that I am getting is: "Challenge Not yet complete... here's what's wrong:
The packingListItem Lightning Component's attribute tag doesn't exist or its attributes are not set correctly."
With this, I tried to create another component, with the name "packingListItem", but It didn't work.
Can anyone help me?
Thanks,
- Eric Kendi Shiraishi
- June 06, 2016
- Like
- 4
Update pricebook entry when product is updated
The following code does not seem to work. Sorry new to Apex coding
trigger TrgPricebookEntry on Product2 (after insert, after update)
{
Set<ID> ids = Trigger.newMap.keySet();
sObject s = [select ID from Pricebook2 where IsStandard = TRUE and IsActive= TRUE];
list<PricebookEntry> entries=new list<PricebookEntry>();
if(trigger.isinsert)
{
for (Product2 p : Trigger.new)
{
entries.add( new PricebookEntry( Pricebook2Id=s.ID, Product2Id=p.ID, UnitPrice=p.Price__c, IsActive=p.IsActive, UseStandardPrice=FALSE) );
}
insert entries;
}
list<PricebookEntry> pbe = [SELECT Id FROM PricebookEntry WHERE Product2ID in : ids];
if(trigger.isupdate)
{
for (Product2 p : Trigger.new)
{
if (pbe != null)
{
pbe.UnitPrice=p.Price__c;
}
}
}
}
- IT Admin 35
- March 25, 2016
- Like
- 0