- Devmen
- NEWBIE
- 20 Points
- Member since 2018
- Salesforce Developer
-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
11Questions
-
13Replies
how to create a task assigned to leadowner when the duplicate lead is found.
Hi ,
Im using trigger and class to check the duplicate lead using email and phone.It is working.When a lead exists a task should create under original lead and assigned to leadowner.How can i achieve this?
thanks
Im using trigger and class to check the duplicate lead using email and phone.It is working.When a lead exists a task should create under original lead and assigned to leadowner.How can i achieve this?
thanks
- Devmen
- November 05, 2018
- Like
- 0
Custom Date field is showing wrong time
Hi,
Below is my trigger .Here im trying to create task .Task is having custom duedatefield (Duedate) with time .when i create a task ,Due date should autopopulate in account based on type field in task.Now date is dispalying correct .But there is difference in timing .Timezone in both user and company information are same.
thanks
Below is my trigger .Here im trying to create task .Task is having custom duedatefield (Duedate) with time .when i create a task ,Due date should autopopulate in account based on type field in task.Now date is dispalying correct .But there is difference in timing .Timezone in both user and company information are same.
public class TaskHelper { public static void updateTask(List<Task> taskList) { Map<Id,Datetime> idActivityDate = new Map<Id,Datetime >(); Map<Id,Datetime> idActivityDate1=new Map<Id,Datetime>(); List<id> accountIdList = new List<Id>(); for(Task temp : taskList) { if(String.valueOf(temp.WhatId).subString(0,3) == '001') { accountIdList.add(temp.WhatId); } } for(Task temp : [Select Due_DateCustom__c,WhatId,Type,Status From Task where Type='Call' and Status='Completed' and whatid=:accountIdList and what.type = 'Account' order By Due_DateCustom__c DESC limit 1]) { system.debug('***********Call'+temp); idActivityDate.put(temp.WhatId,temp.Due_DateCustom__c); system.debug('IDACTIVITY*************'+ idActivityDate.put(temp.WhatId,temp.Due_DateCustom__c)); } for(Task temp1: [Select Due_DateCustom__c,WhatId,Type,Status From Task where Type='Email' and Status='Completed' and whatid=:accountIdList and what.type = 'Account' order By Due_DateCustom__c DESC limit 1]) { system.debug('***********Email'+temp1); idActivityDate1.put(temp1.WhatId,temp1.Due_DateCustom__c); } List<Account> accList = [Select id, Last_Calls__c,Last_Emails__c from Account where id in :idActivityDate.keySet() OR id in:idActivityDate1.keySet() ]; system.debug('ACCOUNTS***************'+accList); for(Account acc : accList) { DateTime acdt=Date.valueOf(idActivityDate.get(acc.id)); // DateTime acdt1=Date.valueOf(idActivityDate1.get(acc.id)); acc.Last_Calls__c= acdt.addMinutes(30); acc.Last_Emails__c =Date.valueOf(idActivityDate1.get(acc.id)); system.debug('********CALL*******'+ acdt); system.debug('********CALL11111111111111*******'+ acc.Last_Calls__c); //DateTime acdt1=Date.valueOf(idActivityDate1.get(acc.id)); // system.debug('********EMAIL1*******'+ acdt1); system.debug('********EMAIL*******'+ acc.Last_Emails__c); } update accList; } }
thanks
- Devmen
- October 23, 2018
- Like
- 0
Selectlist returning blank values
Hi,
Im using selectlist to get selected distributors from picklist. But its returning null values.
Thanks
Im using selectlist to get selected distributors from picklist. But its returning null values.
<div class="slds-grid slds-wrap" style="padding:20px;"> <div class="slds-col slds-size_4-of-12" style="padding:5px;"> <apex:outputLabel value="Distributor" styleClass="slds-output "/> </div> <div class="slds-col slds-size_6-of-12" style="padding:5px;"> <div class="slds-media__body" align="left"> <apex:selectList value="{!Selecteddistri}" id="r2" size="1" multiselect="false" styleClass="slds-input slds-size--1-of-1" style="width:100%;"> <apex:selectOptions Value="{!ListOfDistributors}"/> </apex:selectList> <script> </script> </div
public with sharing class DistributorOrderList_Ext { public String wrapOrder { get; set; } public Date fromdate1 {get;set;} public Date todate1 {get;set;} public String s{get;set;} public list<Order_C__c> OrdList {set;get;} public boolean orderflag{set;get;} public Order_C__c Ord1{set;get;} public String Selecteddistri {get;set;} public Account acc{set;get;} public Account acc1{set;get;} public list<wrapOrder> WrapList {get;set;} public List<wrapOrderSummary> WSumlist{get;set;} public boolean emailflag{set;get;} public map<string,list<Order_Line_Item_C__c>> mapWS{set;get;} public list<Order_Line_Item_C__c> ollist{set;get;} public map<string,wrapOrderSummary> mapWS1{set;get;} public integer Quant{set;get;} public decimal price{set;get;} public user u1{set;get;} public List<SelectOption> getListOfDistributors() { string AccountRecordTypename = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Distributor').getname(); List<SelectOption> AccountOptionList = new List<SelectOption>(); AccountOptionList.add(new SelectOption('','--None--')); for(Account p : [select id,Name FROM Account where recordtype.name=:AccountRecordTypename ]) { AccountOptionList.add(new SelectOption(p.id, p.Name)); system.debug('P>ID'+p.id+'^^^^^P>NAME'+p.Name); } system.debug('AccountOptionList^^^^^^^0+'+AccountOptionList); return AccountOptionList; } public DistributorOrderList_Ext(){ Ord1=new Order_C__c(); OrdList=new List<Order_C__c>(); orderflag=false; WrapList=new list<wrapOrder>(); WSumlist=new list<wrapOrderSummary>(); mapWS=new map<string,list<Order_Line_Item_C__c>>(); mapWS1=new map<string,wrapOrderSummary>(); emailflag=false; system.debug('Selecteddistri********************'+Selecteddistri); ollist=new list<Order_Line_Item_C__c>(); //Account acct=[select id,Name from Account where id=:Selecteddistri]; //system.debug('Account222222'+acct); OrdList=[select id,name,Total_Quantity_in_Sets__c,Distributor__c,Route__c,Order_Amount__c,Order_Date__c,Distributor__r.Email__c,Retailer_O__r.name,Order_Type__c,(select id,name,Quantity__c,Remarks__c,MRP__c,Product__r.Item_Code__c,Product__r.Remarks__c,Product__r.Tube_Weight_gm__c,Product__r.Unit_In_Dozens__c,Product__r.name from Order_Line_Items__r) from Order_C__c where Order_Date__c>=:fromdate1 AND Order_Date__c<=:todate1 AND Distributor__c=:Selecteddistri AND Order_Type__c=:'Secondary Order']; system.debug('ORDDDDDDDDDDDLIST'+OrdList[0].Distributor__c); system.debug('DISTRIBUTORSS'+Selecteddistri); List<String> lstselectedRecordIds = new List<String>();In debug distributors getting blank.hene it retrieving all records instead of selected distributors.Where is the issue ?
Thanks
- Devmen
- October 10, 2018
- Like
- 0
records are not visible in Visualforcepage when send as email attachment.
Hi,
Im using two Vf pages and 1 custom controller.first page has send button.When i click send button it should send second page as email attachment.In attachments records are not visible. Could anyone resolve this?
Thanks
Im using two Vf pages and 1 custom controller.first page has send button.When i click send button it should send second page as email attachment.In attachments records are not visible. Could anyone resolve this?
public Pagereference sendmail(){ pagereference pdf; orderflag=true; OrdList=[selectid,name,Total_Quantity_in_Sets__c,Order_Amount__c,Order_Date__c,Distributor__r.Email__c,Retailer_O__r.name,Order_Type__c,(select id,name,Quantity__c,Remarks__c,MRP__c,Product__r.Item_Code__c,Product__r.Remarks__c,Product__r.Tube_Weight_gm__c,Product__r.Unit_In_Dozens__c,Product__r.name from Order_Line_Items__r) from Order_C__c where Order_Date__c>=:fromdate1 AND Order_Date__c<=:todate1 AND Distributor__c=:Selecteddistri AND Order_Type__c=:'Secondary Order'];List<String> lstselectedRecordIds = new List<String>();for(Order_C__c o:OrdList){ wrapOrder w=new wrapOrder(); w.Ord=o; system.debug('ORRRRRRRRRRRDER'+w.Ord); w.OLlist1=o.Order_Line_Items__r; w.Retailername=o.Retailer_O__r.name;WrapList.add(w); system.debug('WRRRRRRRRRRAPLIST'+WrapList); }for(wrapOrder wo:WrapList){ for(Order_Line_Item_C__c o:wo.OLlist1){ ollist.add(o); system.debug('OLLLLLLLLIST'+ollist.add(o)); wrapOrderSummary w1=new wrapOrderSummary(); w1.productname=o.Product__r.name; w1.Quant=0; w1.price=0; mapWS1.put(o.Product__r.name,w1); }}for(Order_Line_Item_C__c ws:ollist){ if(mapWS1.containsKey(ws.Product__r.name)){mapWS1.get(ws.Product__r.name).Quant= mapWS1.get(ws.Product__r.name).Quant+ws.Quantity__c; mapWS1.get(ws.Product__r.name).price= mapWS1.get(ws.Product__r.name).price+ws.MRP__c;} }for(wrapOrderSummary w2:mapWS1.Values()) { WSumlist.add(w2);}for(Integer i=0;i<OrdList.size();i++){ lstselectedRecordIds.add(OrdList[i].Id); system.debug('ORDERIDDDDDDDDD'+lstselectedRecordIds); } string s=''; for(Integer i=0;i<lstselectedRecordIds.size();i++)if(i<lstselectedRecordIds.size()-1) s=s+lstselectedRecordIds[i]+':'; else s=s+lstselectedRecordIds[i];}acc1=[select id,name,Email__c from Account where id=:selecteddistri]; system.debug('ACCCCCCCCCCC'+acc1);user u=[select id,name,manager.email,manager.name,managerid from user whereid=:userinfo.getuserid()]; if(u.managerid!=null){ u1=[select id,name,email,manager.email from user where id=:u.managerid ];} try { Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment(); Blob body; // Who you are sending the email to List<String> sendTo = new List<String>(); if(acc1.Email__c!=null){ system.debug('EMMMMMMMMMMMMMMAIL'+acc1.Email__c); sendTo.add(acc1.Email__c); } mail.setToAddresses(sendTo);mail.setSubject('Sample'); mail.setHtmlBody('<p>Dear '+u.manager.name+', <br/><br/> The below are the orders in between '+fromdate1.day()+'-'+fromdate1.month()+'-'+fromdate1.year()+' to '+todate1.day()+'-'+todate1.month()+'-'+todate1.year()+'.<br/><br/></p>'pdf= Page.Distributororderpdf; system.debug('PDDDDDDDF'+pdf); body = pdf.getContentAsPDF(); attach.setContentType('application/pdf'); attach.setFileName('DistributorOrder.pdf'); attach.setBody(body); mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});emailflag=true; }catch(Exception e) {} return pdf; }
1st VF page: <table width="100%"><tr><td> <div align="center"> <apex:outputpanel id="op3" rendered="{!emailflag=false}"><apex:commandButton value="Send" action="{!sendmail}" styleclass="slds-button slds-button_neutral" /> <apex:commandButton value="Cancel" action="{!Cancel}" styleclass="slds-button slds-button_neutral" /> </apex:outputpanel> </div> </td></tr></table> 2nd VF page <table border="1" cellspacing="0" cellpadding="3" width="80%" rendered="{!orderflag=true}" > <apex:variable value="{!1}" var="count"/> <apex:repeat value="{!OrdList}" var="w1"> <tr> <td align="left" style="text-align:left;font-weight:bold" colspan="4" > Retailer Name: {!w1.Retailer_O__r.name} </td> </tr> <tr> <td align="center" style="text-align:center;font-weight:bold;" width="25%">Order Number : {!w1.name}</td> <td align="center" style="text-align:center;font-weight:bold;" width="25%">Order Date : <apex:outputtext value="{0,date,MM/dd/yy}"><apex:param value="{!w1.Order_Date__c}" /></apex:outputtext></td> <td align="center" style="text-align:center;font-weight:bold;" width="25%">Total Qty : {!w1.Total_Quantity_in_Sets__c}</td> <td align="center" style="text-align:center;font-weight:bold;" width="25%">Total Value :{!w1.Order_Amount__c}</td> </tr> <tr> <td colspan="4"> <table> <tr> <td style="text-align:center;font-weight:bold;" width="12%"></td> <td style="text-align:center;font-weight:bold;" width="12%">Product Code</td> <td style="text-align:center;font-weight:bold;" width="12%">Product Name</td> <td style="text-align:center;font-weight:bold;" width="12%">Price</td> <td style="text-align:center;font-weight:bold;" width="12%">Quantity</td> </tr> <apex:repeat value="{!ollist}" var="o"> <tr> <td style="text-align:center;font-weight:bold;" width="12%"></td> <td width="12%" style="text-align:center;">{!o.Product__r.Item_Code__c}</td> <td width="12%" style="text-align:center;">{!o.Product__r.Name}</td> <td width="12%" style="text-align:center;">{!o.MRP__c}</td> <td width="12%" style="text-align:center;">{!o.Quantity__c}</td> </tr> </apex:repeat></table> </td> </tr> <apex:variable value="{!Count+1}" var="count"/> </apex:repeat> </table>
Thanks
- Devmen
- October 05, 2018
- Like
- 0
i want to add ,display and delete records in VF page.
Hi,
I want to add ,display and delete child records through Vf page .How to solve this ?
Thanks
I want to add ,display and delete child records through Vf page .How to solve this ?
Thanks
- Devmen
- September 25, 2018
- Like
- 0
code coverage for trigger in for loop
Hi ,
Here is the trigger im getting 57% code coverage.Commented area in trigger is not getting covered ,Below is the test class.
Here is the trigger im getting 57% code coverage.Commented area in trigger is not getting covered ,Below is the test class.
For(Opportunity svp:trigger.new) { if(svp.Generate_Payment_Schedule__c== true) { /* for(Payment_Schedule_Template__c P:PSTList) { system.debug('*************************PS'+PSTList); taxlist = [select id,Name from Tax_Master__c WHERE Name='GST' OR Name= 'Vat & Stax']; system.debug('TTTTTTTTTTTTTTTTAXLIST'+taxlist); for(Tax_Master__c tm:taxlist) { taxid=tm.id; taxName=tm.Name; } system.debug('TTTTTTTTTTTTTTTTAXID'+taxid); // Prec+=P.Percentage__c; if(taxName=='GST') { PSList.add(new Schedule__c(Display_Order__c = P.Display_Order__c, Name = P.Name, Cumulative_Percentage__c=p.Cumulative_Percentage__c, Cumulative_Installment_Amt__c=p.Cumulative_Percentage__c/100*svp.Total_Agreement_Value__c, Percentage__c = P.Percentage__c, Tentative_Due_Date__c=p.Tentative_Due_Date__c, Installment_Amount__c=p.Percentage__c/100*svp.Total_Agreement_Value__c, Opportunity__c = myatd[1], Tax_Master__c = taxid )); } else if(taxName=='Vat & Stax') { PSList.add(new Schedule__c(Display_Order__c = P.Display_Order__c, Name = P.Name, Cumulative_Percentage__c=p.Cumulative_Percentage__c, Cumulative_Installment_Amt__c=p.Cumulative_Percentage__c/100*svp.Agreement_Value__c, Percentage__c = P.Percentage__c, Tentative_Due_Date__c=p.Tentative_Due_Date__c, Installment_Amount__c=p.Percentage__c/100*svp.Agreement_Value__c, Opportunity__c = myatd[1], // Cumulative_Percentage__c=Prec, Tax_Master__c = taxid )); */ } } } } insert PSList; PSList.clear(); PSTList.clear(); ut.clear(); myatd.clear(); } }
static testMethod void ScheduleTest() { Tax_Master__c tm = new Tax_Master__c(Name='GST'); insert tm; Account a = new Account(name='Ravi'); insert a; Project__c pr = new Project__c(Name='Laplazzo'); insert pr; Block__c b = new Block__c(Name='block one',Project_Name__c=pr.id); insert b; Apartment__c ap = new Apartment__c(Name='112', Block__c=b.Id, Status__c='Available'); insert ap; List<Payment_Schedule_Template__c> PSTList = new List<Payment_Schedule_Template__c>(); for (integer i = 1; i <10; i++) { PSTList.add(new Payment_Schedule_Template__c( Name = 'Payment schedule One', Percentage__c = 0.00, Block__c = b.id, Tentative_Due_Date__c = System.Today(),Display_Order__c = i)); } Insert PSTList; Opportunity o=new Opportunity(Name='raviopp',AccountId=a.Id,StageName='Blocking', Apartment__c =ap.id,CloseDate=Date.today(), Generate_Payment_Schedule__c = True); insert o; system.debug('OPPPPPPPPPPPP'+o); if(o.Generate_Payment_Schedule__c) { system.debug('OOOOOOOOOOOOOOOOO'+o.Generate_Payment_Schedule__c); List<Payment_Schedule_Template__c> PSList = new List<Payment_Schedule_Template__c>(); for (Payment_Schedule_Template__c P: PSTList) { system.debug('PPPPPPPPPPSTLIST'+PSTList); Tax_Master__c tm1 = new Tax_Master__c(Name='GST'); insert tm1; Schedule__c sch= new Schedule__c(Display_Order__c=1,Name='sch1',Cumulative_Percentage__c=0.06,Tentative_Due_Date__c=System.Today(),Opportunity__c=o.id); insert sch; PSList.add(new Payment_Schedule_Template__c( Name = P.Name,Block__c=b.id,Percentage__c = P.Percentage__c, Tentative_Due_Date__c = System.Today(), Display_Order__c = P.Display_Order__c)); } Insert PSList; update PSList; } update o; } }Pls help me to resolve this .
- Devmen
- September 15, 2018
- Like
- 0
pop up message in custom button using visualforce page
Hi,
I have a visual force page in custom button and pop message should display in detail page when i click the custom button .I cannot use javascript as it willl not support in lightning mode. Im using a formula field in detail page like when discount>=50% we can generate pdf else it will show alert and cannot generate pdf.How can i implement this without using javascript.
Thanks
I have a visual force page in custom button and pop message should display in detail page when i click the custom button .I cannot use javascript as it willl not support in lightning mode. Im using a formula field in detail page like when discount>=50% we can generate pdf else it will show alert and cannot generate pdf.How can i implement this without using javascript.
Thanks
- Devmen
- September 07, 2018
- Like
- 0
Visualforce page in pdf into word file
Hi,
I want to send and attach visalforce page into attachemnt related list as word file format.I tried so many ways as suggested in discussion board.But still when i opened doc file its showing in html format.How to display pdf file into word format.
Thanks
I want to send and attach visalforce page into attachemnt related list as word file format.I tried so many ways as suggested in discussion board.But still when i opened doc file its showing in html format.How to display pdf file into word format.
<apex:page standardController="Quotation__c" showheader="false" extensions="QuoteClass" contentType="application/msWord" sidebar="false" standardStylesheets="false" applyHtmlTag="false" applyBodyTag="false" renderAs="pdf"> <html xmlns:w="urn:schemas-microsoft-com:office:word"> <body> <head> <style type="text/css"> @page { size: 9in 12in; @bottom-left { content: element(footer); } } div.footer { display: block; padding:20px: height:30px; position:running(footer); border-top: solid 1px; } .pagenumber:before { content: counter(page); } .pagecount:before { content: counter(pages); } } </style> </head> <table width="100%" style="font-family:sans-serif;"> <tr> <td align="center" style="font-size:16pt;"><b>Quotation1</b></td> </tr> <tr> <td align="center" style="font-size:16pt;"><b> SAMPLE LTD.</b></td> </tr> <tr> <td align="center" style="font-size:10pt;"></td> </tr><br clear="all" style="page-break-before:always" /> <table width="100%" style="font-family:sans-serif;"> <tr> <td width="20%" align="left" style="font-size:10pt;"><b><u>Customer Details:</u></b></td> <td width="30%" style="font-size:10pt;"></td> <td width="15%" align="left" style="font-size:10pt;"><b>Quotation Ref</b></td> <td width="35%" style="font-size:10pt;"> :{!qtn.Quotation_Number__c} / <apex:outputText value="{0,date,dd MMMM, yyyy}"><apex:param value="{!qtn.Quotation_Date__c}"/></apex:outputText></td> </tr> <tr> <td align="left" style="font-size:10pt;"><b>Name</b></td> <td align="left" style="font-size:10pt;">:{!qtn.Contact__r.Name}</td> <td align="left" style="font-size:10pt;"><b>Sales Rep</b></td> <td style="font-size:10pt;">:{!currentuser.Name}</td> </tr> <tr> <td align="left" style="font-size:10pt;"><b>City</b></td> <td style="font-size:10pt;">:{!qtn.Contact__r.MailingCity}</td> <td align="left" style="font-size:10pt;"><b>Branch</b></td> <td style="font-size:10pt;">:{!qtn.Branch__r.Name}</td> </tr> <tr> <td align="left" style="font-size:10pt;"><b>Email</b></td> <td style="font-size:10pt;">:{!qtn.Contact__r.Email}</td> <td align="left" style="font-size:10pt;"><b>Contact No</b></td> <td style="font-size:10pt;">:{!currentuser.Phone} </td> </tr> <tr> <td align="left" style="font-size:10pt;"><b>Mobile</b></td> <td style="font-size:10pt;">:{!qtn.Contact__r.MobilePhone}</td> <td align="left" style="font-size:10pt;"><b>Email</b></td> <td style="font-size:10pt;">:{!currentuser.Email}</td> </tr><br clear="all" style="page-break-before:always" /> </table> </table> <apex:variable value="{!0}" var="qtotal1"/> <apex:variable value="{!1}" var="qno"/> <table style="font-family:sans-serif;" width="100%" id="table4" border="1" colspan="0" cellspacing="0"> <tr style="color:black;font-weight:bold;font-size:10pt;"> <td align="center">Sl. No.</td> <td align="center">Brand</td> <td align="center">Product</td> <td align="center">Image</td> <td align="center">QTY</td> <td width="10%" align="center">Price per Unit</td> <td align="center">Total Value</td> <td align="center">Delivery Time</td> <td align="center">Remarks</td> </tr> <apex:repeat value="{!qlitems}" var="q"> <tr style="font-size:10pt;"> <td align="center"><apex:outputText value="{!qno}"/></td> <apex:variable var="qno" value="{!qno+ 1}"/> <td align="center">{!q.Product__r.Brand__c}</td> <td align="center"> {!q.Product__r.name}</td> <td align="center"><img src='{!q.Product__r.Product_Image_Url__c}' width="135" height="100"/></td> <td align="right">{!q.Quantity__c}</td> <td width="10%" align="right">{!q.Price__c}</td> <td align="right">{!q.Total_Price__c}</td> <apex:variable value="{!qtotal1+q.Total_Price__c}" var="qtotal1"/> <td align="center">{!q.Delevery_Time__c}</td> <td align="center">{!q.Remarks__c}</td> </tr> </apex:repeat> <tr style="color:black;font-weight:bold;font-size:10pt;"> <td colspan="6" align="right">TOTAL</td> <td align="right">{!qtotal1}</td> <td colspan="2"></td> </tr><br clear="all" style="page-break-before:always" /> </table> <table width="100%" style="font-family:sans-serif;"> <tr> <td width="20%" align="left" style="font-size:10pt;font-family:sans-serif;"><b><u>Payment Terms:</u></b></td><br clear="all" style="page-break-before:always" /> </tr> <tr> <td style="font-family:sans-serif;font-size:9pt;"> <apex:outputText value="{!qtn.Payment_Terms__c}" escape="false"/> </td> </tr> <tr> <td width="20%" align="left" style="font-size:10pt;font-family:sans-serif;"><b><u>Special Instructions:</u></b></td><br clear="all" style="page-break-before:always" /> </tr> <tr> <td style="font-family:sans-serif;font-size:9pt;"> <apex:outputText value="{!qtn.Special_Instructions__c}" escape="false"/> </td> </tr> <tr> <td width="20%" align="left" style="font-size:10pt;font-family:sans-serif;"><b><u>Terms & Conditions:</u></b></td> </tr> <tr> <td style="font-family:sans-serif;font-size:9pt;"> <apex:outputText value="{!qtn.Terms_Conditions__c}" escape="false"/> </td> </tr> </table> <table width="100%" style="font-family:sans-serif;font-size:10pt;"> <tr style="font-family:sans-serif;font-size:10pt;"> <td align="left"><b>E&O.E.</b></td><br clear="all" style="page-break-before:always" /> </tr> <tr style="font-family:sans-serif;font-size:10pt;"> <td align="left">Thanking You,</td> </tr> <tr style="font-family:sans-serif;font-size:10pt;"> <td align="left">Best Regards</td> </tr> <tr style="font-family:sans-serif;font-size:10pt;"> <td align="left"></td> </tr> </table> </body> </html> </apex:page>Please help me to resolve this.
Thanks
- Devmen
- September 05, 2018
- Like
- 0
add records from lookup and display in visualforce page
Hi,
im creating a record in object (Sample) using visualforce page.There is a field name testname which is a lookup to an another object named (Test).Im trying to add record from lookup and display in VF page. Its is displaying Id not name.When i add more records it is adding same record IDs which i last entered.Test name should create as seperate object(TestSample) record in instance.Now it is creating Test sample record.But instead of name it is displaying id.
Canyone pls help me to resolve this
Thanks
Devmen
im creating a record in object (Sample) using visualforce page.There is a field name testname which is a lookup to an another object named (Test).Im trying to add record from lookup and display in VF page. Its is displaying Id not name.When i add more records it is adding same record IDs which i last entered.Test name should create as seperate object(TestSample) record in instance.Now it is creating Test sample record.But instead of name it is displaying id.
public class AddSampleCls { public Visit_Samples__c visitSmaple{get;set;} public Boolean allowSampleCreation{get;set;} public Boolean isMobile{get;set;} public Event currentEve{get;set;} public list<wrapPm> wrp1{get;set;} public boolean testflag{get;set;} public map<id,string> testlist{set;get;} public string selectedtest{set;get;} public Sample__c sampleRec{get;set;} public Test_Sample__c sampleTest{get;set;} public List<Sample__c> sampleReclist{get;set;} public List<SelectOption> list_AllsampleTypes{get;set;} public List<SelectOption> list_businessSegments{get;set;} public transient Blob sampleImage{get;set;} public List<String> list_SampleTypesSelected{get;set;} public List<String> list_BusinessSegSelected{get;set;} public AddSampleCls(ApexPages.StandardController controller) { wrp1=new list<wrapPm>(); isMobile = UserInfo.getUiTheme() == 'Theme4t'; if(!String.IsBlank(ApexPages.CurrentPage().getParameters().get('Id'))) { currentEve = [SELECT Id,WhoId,Visit_Type__c,Subject,Visit_Samples__c,StartDateTime,EndDateTime FROM Event WHERE Id =: ApexPages.CurrentPage().getParameters().get('Id')]; if(currentEve.WhoId != Null && currentEve.WhoId.getSObjectType() == Contact.sObjectType) { if(currentEve.Visit_Type__c=='Sample Collection') { if(currentEve.Visit_Samples__c != Null) { visitSmaple = [SELECT Id,Name,From_Date__c,To_Date__c FROM Visit_Samples__c WHERE Id =: currentEve.Visit_Samples__c]; system.debug('VVVVVVVVVVVVVVisitSample'+visitSmaple); } else { visitSmaple = new Visit_Samples__c(); } sampleRec = new Sample__c(Doctor__c=currentEve.WhoId,Visit_Samples__c=visitSmaple.Id); allowSampleCreation = true; list_AllsampleTypes = new List<SelectOption>(); list_businessSegments = new List<SelectOption>(); list_SampleTypesSelected = new List<String>(); list_BusinessSegSelected = new List<String>(); Schema.DescribeFieldResult fieldResult = Sample__c.Sample_Type__c.getDescribe(); List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); for( Schema.PicklistEntry f : ple) { list_AllsampleTypes.add(new SelectOption(f.getLabel(), f.getValue())); } Schema.DescribeFieldResult fieldResult1 = Sample__c.Business_Segments__c.getDescribe(); List<Schema.PicklistEntry> ple1 = fieldResult1.getPicklistValues(); for( Schema.PicklistEntry f : ple1) { list_businessSegments.add(new SelectOption(f.getLabel(), f.getValue())); } } else { allowSampleCreation = false; ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,Label.Visit_Type_Sample_Collection_Validation)); } } else { allowSampleCreation = false; ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,Label.Doctor_s_Visit_Validation)); } } } public void addTest() { wrapPm w=new wrapPm(); w.sampleRec1=sampleRec; wrp1.add(w); sampleTest =new Test_Sample__c(); selectedtest=null; } Public void removetest() { Integer indexVal = Integer.valueof(system.currentpagereference().getparameters().get('index')); wrp1.remove(indexVal - 1); } public class wrapPm { public Sample__c sampleRec1{get;set;} public String name{get; set;} public Test_Sample__c sampleTest1{get;set;} //public String Test_Code__c {get;set;} } public pageReference saveAll() { Savepoint sp = DataBase.setSavePoint(); try { if(currentEve.Visit_Samples__c != Null) { sampleRec.Visit_Samples__c = visitSmaple.Id; } else { visitSmaple.Name = currentEve.Subject+'- Samples'; visitSmaple.From_Date__c=currentEve.StartDateTime.date(); visitSmaple.To_Date__c=currentEve.EndDateTime.date(); insert visitSmaple; currentEve.Visit_Samples__c = visitSmaple.Id; Update currentEve; } sampleRec.Sample_Type__c = String.join(list_SampleTypesSelected,';'); sampleRec.Business_Segments__c = String.join(list_BusinessSegSelected,';'); sampleRec.Visit_Samples__c = visitSmaple.Id; Insert sampleRec; if(sampleImage != Null) { Attachment att = new Attachment(); att.Name = 'Sample'; att.ContentType = 'image/jpeg'; att.Body = sampleImage; att.ParentId = sampleRec.Id; Insert att; } if(sampleTest != Null) { Test_Sample__c ts=new Test_Sample__c(); ts.Name=sampleRec.Test_Code__r.Test_Name__c; ts.Test_Name__c=sampleRec.Test_Code__c; ts.Sample__c=sampleRec.id; ts.Visit_Samples__c=visitSmaple.Id; insert ts; } return new PageReference('/'+currentEve.Id); } catch(exception e) { ApexPages.addMessages(e); DataBase.RollBack(sp); return null; } } }
Canyone pls help me to resolve this
Thanks
Devmen
- Devmen
- September 03, 2018
- Like
- 0
system.assertion failed
hi,
i have a test class.It is throwing error System.Assertexception
the result.success is getting false.how can i resolve this error
thanks
i have a test class.It is throwing error System.Assertexception
Lead newLead = new Lead(); newLead.LastName='TestName'; newLead.Company = 'TestCompany'; newLead.Email='test@test.com'; newLead.Status ='Open'; newLead.Cc__c='test@test.com'; newLead.Description='Subject:TextBody'; insert newlead; Messaging.InboundEmail email = new Messaging.InboundEmail() ; Messaging.InboundEnvelope env = new Messaging.InboundEnvelope(); email.plainTextBody = 'teset'; email.fromAddress = 'test@test.com'; email.subject = 'Test Lead'; // email.ToAddress ='test@gmail.com'; CreateLeadExample edr = new CreateLeadExample(); edr.handleInboundEmail(email,env); Test.startTest(); Messaging.InboundEmailResult result = edr.handleInboundEmail(email, env); System.assert(result.success, 'Error processing email...'); Test.stopTest(); Lead [] leadDb = [SELECT Id FROM Lead where LastName=:email.FromAddress]; // System.assertEquals (1, leadDb.size(),'Lead was not inserted'); System.debug('Size'+leadDb.size()); attachment.body = blob.valueOf('my attachment text'); attachment.fileName = 'text'; email.binaryAttachments = new Messaging.inboundEmail.BinaryAttachment[] { attachment }; Attachment attach=new Attachment(); attach.Name='Test'; Blob bodyBlob=Blob.valueOf('Testing Body of Attachment'); attach.body=bodyBlob; insert attach;
the result.success is getting false.how can i resolve this error
thanks
- Devmen
- August 07, 2018
- Like
- 0
How to get bcc mail id in emailservice class?
Hi,
I've created a email field (bcc) in lead.I want to populate bcc mail id here using email service class.How can i acheive this?
Thanks
Devmen
I've created a email field (bcc) in lead.I want to populate bcc mail id here using email service class.How can i acheive this?
Thanks
Devmen
- Devmen
- August 05, 2018
- Like
- 0
records are not visible in Visualforcepage when send as email attachment.
Hi,
Im using two Vf pages and 1 custom controller.first page has send button.When i click send button it should send second page as email attachment.In attachments records are not visible. Could anyone resolve this?
Thanks
Im using two Vf pages and 1 custom controller.first page has send button.When i click send button it should send second page as email attachment.In attachments records are not visible. Could anyone resolve this?
public Pagereference sendmail(){ pagereference pdf; orderflag=true; OrdList=[selectid,name,Total_Quantity_in_Sets__c,Order_Amount__c,Order_Date__c,Distributor__r.Email__c,Retailer_O__r.name,Order_Type__c,(select id,name,Quantity__c,Remarks__c,MRP__c,Product__r.Item_Code__c,Product__r.Remarks__c,Product__r.Tube_Weight_gm__c,Product__r.Unit_In_Dozens__c,Product__r.name from Order_Line_Items__r) from Order_C__c where Order_Date__c>=:fromdate1 AND Order_Date__c<=:todate1 AND Distributor__c=:Selecteddistri AND Order_Type__c=:'Secondary Order'];List<String> lstselectedRecordIds = new List<String>();for(Order_C__c o:OrdList){ wrapOrder w=new wrapOrder(); w.Ord=o; system.debug('ORRRRRRRRRRRDER'+w.Ord); w.OLlist1=o.Order_Line_Items__r; w.Retailername=o.Retailer_O__r.name;WrapList.add(w); system.debug('WRRRRRRRRRRAPLIST'+WrapList); }for(wrapOrder wo:WrapList){ for(Order_Line_Item_C__c o:wo.OLlist1){ ollist.add(o); system.debug('OLLLLLLLLIST'+ollist.add(o)); wrapOrderSummary w1=new wrapOrderSummary(); w1.productname=o.Product__r.name; w1.Quant=0; w1.price=0; mapWS1.put(o.Product__r.name,w1); }}for(Order_Line_Item_C__c ws:ollist){ if(mapWS1.containsKey(ws.Product__r.name)){mapWS1.get(ws.Product__r.name).Quant= mapWS1.get(ws.Product__r.name).Quant+ws.Quantity__c; mapWS1.get(ws.Product__r.name).price= mapWS1.get(ws.Product__r.name).price+ws.MRP__c;} }for(wrapOrderSummary w2:mapWS1.Values()) { WSumlist.add(w2);}for(Integer i=0;i<OrdList.size();i++){ lstselectedRecordIds.add(OrdList[i].Id); system.debug('ORDERIDDDDDDDDD'+lstselectedRecordIds); } string s=''; for(Integer i=0;i<lstselectedRecordIds.size();i++)if(i<lstselectedRecordIds.size()-1) s=s+lstselectedRecordIds[i]+':'; else s=s+lstselectedRecordIds[i];}acc1=[select id,name,Email__c from Account where id=:selecteddistri]; system.debug('ACCCCCCCCCCC'+acc1);user u=[select id,name,manager.email,manager.name,managerid from user whereid=:userinfo.getuserid()]; if(u.managerid!=null){ u1=[select id,name,email,manager.email from user where id=:u.managerid ];} try { Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment(); Blob body; // Who you are sending the email to List<String> sendTo = new List<String>(); if(acc1.Email__c!=null){ system.debug('EMMMMMMMMMMMMMMAIL'+acc1.Email__c); sendTo.add(acc1.Email__c); } mail.setToAddresses(sendTo);mail.setSubject('Sample'); mail.setHtmlBody('<p>Dear '+u.manager.name+', <br/><br/> The below are the orders in between '+fromdate1.day()+'-'+fromdate1.month()+'-'+fromdate1.year()+' to '+todate1.day()+'-'+todate1.month()+'-'+todate1.year()+'.<br/><br/></p>'pdf= Page.Distributororderpdf; system.debug('PDDDDDDDF'+pdf); body = pdf.getContentAsPDF(); attach.setContentType('application/pdf'); attach.setFileName('DistributorOrder.pdf'); attach.setBody(body); mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});emailflag=true; }catch(Exception e) {} return pdf; }
1st VF page: <table width="100%"><tr><td> <div align="center"> <apex:outputpanel id="op3" rendered="{!emailflag=false}"><apex:commandButton value="Send" action="{!sendmail}" styleclass="slds-button slds-button_neutral" /> <apex:commandButton value="Cancel" action="{!Cancel}" styleclass="slds-button slds-button_neutral" /> </apex:outputpanel> </div> </td></tr></table> 2nd VF page <table border="1" cellspacing="0" cellpadding="3" width="80%" rendered="{!orderflag=true}" > <apex:variable value="{!1}" var="count"/> <apex:repeat value="{!OrdList}" var="w1"> <tr> <td align="left" style="text-align:left;font-weight:bold" colspan="4" > Retailer Name: {!w1.Retailer_O__r.name} </td> </tr> <tr> <td align="center" style="text-align:center;font-weight:bold;" width="25%">Order Number : {!w1.name}</td> <td align="center" style="text-align:center;font-weight:bold;" width="25%">Order Date : <apex:outputtext value="{0,date,MM/dd/yy}"><apex:param value="{!w1.Order_Date__c}" /></apex:outputtext></td> <td align="center" style="text-align:center;font-weight:bold;" width="25%">Total Qty : {!w1.Total_Quantity_in_Sets__c}</td> <td align="center" style="text-align:center;font-weight:bold;" width="25%">Total Value :{!w1.Order_Amount__c}</td> </tr> <tr> <td colspan="4"> <table> <tr> <td style="text-align:center;font-weight:bold;" width="12%"></td> <td style="text-align:center;font-weight:bold;" width="12%">Product Code</td> <td style="text-align:center;font-weight:bold;" width="12%">Product Name</td> <td style="text-align:center;font-weight:bold;" width="12%">Price</td> <td style="text-align:center;font-weight:bold;" width="12%">Quantity</td> </tr> <apex:repeat value="{!ollist}" var="o"> <tr> <td style="text-align:center;font-weight:bold;" width="12%"></td> <td width="12%" style="text-align:center;">{!o.Product__r.Item_Code__c}</td> <td width="12%" style="text-align:center;">{!o.Product__r.Name}</td> <td width="12%" style="text-align:center;">{!o.MRP__c}</td> <td width="12%" style="text-align:center;">{!o.Quantity__c}</td> </tr> </apex:repeat></table> </td> </tr> <apex:variable value="{!Count+1}" var="count"/> </apex:repeat> </table>
Thanks
- Devmen
- October 05, 2018
- Like
- 0
i want to add ,display and delete records in VF page.
Hi,
I want to add ,display and delete child records through Vf page .How to solve this ?
Thanks
I want to add ,display and delete child records through Vf page .How to solve this ?
Thanks
- Devmen
- September 25, 2018
- Like
- 0
pop up message in custom button using visualforce page
Hi,
I have a visual force page in custom button and pop message should display in detail page when i click the custom button .I cannot use javascript as it willl not support in lightning mode. Im using a formula field in detail page like when discount>=50% we can generate pdf else it will show alert and cannot generate pdf.How can i implement this without using javascript.
Thanks
I have a visual force page in custom button and pop message should display in detail page when i click the custom button .I cannot use javascript as it willl not support in lightning mode. Im using a formula field in detail page like when discount>=50% we can generate pdf else it will show alert and cannot generate pdf.How can i implement this without using javascript.
Thanks
- Devmen
- September 07, 2018
- Like
- 0
Visualforce page in pdf into word file
Hi,
I want to send and attach visalforce page into attachemnt related list as word file format.I tried so many ways as suggested in discussion board.But still when i opened doc file its showing in html format.How to display pdf file into word format.
Thanks
I want to send and attach visalforce page into attachemnt related list as word file format.I tried so many ways as suggested in discussion board.But still when i opened doc file its showing in html format.How to display pdf file into word format.
<apex:page standardController="Quotation__c" showheader="false" extensions="QuoteClass" contentType="application/msWord" sidebar="false" standardStylesheets="false" applyHtmlTag="false" applyBodyTag="false" renderAs="pdf"> <html xmlns:w="urn:schemas-microsoft-com:office:word"> <body> <head> <style type="text/css"> @page { size: 9in 12in; @bottom-left { content: element(footer); } } div.footer { display: block; padding:20px: height:30px; position:running(footer); border-top: solid 1px; } .pagenumber:before { content: counter(page); } .pagecount:before { content: counter(pages); } } </style> </head> <table width="100%" style="font-family:sans-serif;"> <tr> <td align="center" style="font-size:16pt;"><b>Quotation1</b></td> </tr> <tr> <td align="center" style="font-size:16pt;"><b> SAMPLE LTD.</b></td> </tr> <tr> <td align="center" style="font-size:10pt;"></td> </tr><br clear="all" style="page-break-before:always" /> <table width="100%" style="font-family:sans-serif;"> <tr> <td width="20%" align="left" style="font-size:10pt;"><b><u>Customer Details:</u></b></td> <td width="30%" style="font-size:10pt;"></td> <td width="15%" align="left" style="font-size:10pt;"><b>Quotation Ref</b></td> <td width="35%" style="font-size:10pt;"> :{!qtn.Quotation_Number__c} / <apex:outputText value="{0,date,dd MMMM, yyyy}"><apex:param value="{!qtn.Quotation_Date__c}"/></apex:outputText></td> </tr> <tr> <td align="left" style="font-size:10pt;"><b>Name</b></td> <td align="left" style="font-size:10pt;">:{!qtn.Contact__r.Name}</td> <td align="left" style="font-size:10pt;"><b>Sales Rep</b></td> <td style="font-size:10pt;">:{!currentuser.Name}</td> </tr> <tr> <td align="left" style="font-size:10pt;"><b>City</b></td> <td style="font-size:10pt;">:{!qtn.Contact__r.MailingCity}</td> <td align="left" style="font-size:10pt;"><b>Branch</b></td> <td style="font-size:10pt;">:{!qtn.Branch__r.Name}</td> </tr> <tr> <td align="left" style="font-size:10pt;"><b>Email</b></td> <td style="font-size:10pt;">:{!qtn.Contact__r.Email}</td> <td align="left" style="font-size:10pt;"><b>Contact No</b></td> <td style="font-size:10pt;">:{!currentuser.Phone} </td> </tr> <tr> <td align="left" style="font-size:10pt;"><b>Mobile</b></td> <td style="font-size:10pt;">:{!qtn.Contact__r.MobilePhone}</td> <td align="left" style="font-size:10pt;"><b>Email</b></td> <td style="font-size:10pt;">:{!currentuser.Email}</td> </tr><br clear="all" style="page-break-before:always" /> </table> </table> <apex:variable value="{!0}" var="qtotal1"/> <apex:variable value="{!1}" var="qno"/> <table style="font-family:sans-serif;" width="100%" id="table4" border="1" colspan="0" cellspacing="0"> <tr style="color:black;font-weight:bold;font-size:10pt;"> <td align="center">Sl. No.</td> <td align="center">Brand</td> <td align="center">Product</td> <td align="center">Image</td> <td align="center">QTY</td> <td width="10%" align="center">Price per Unit</td> <td align="center">Total Value</td> <td align="center">Delivery Time</td> <td align="center">Remarks</td> </tr> <apex:repeat value="{!qlitems}" var="q"> <tr style="font-size:10pt;"> <td align="center"><apex:outputText value="{!qno}"/></td> <apex:variable var="qno" value="{!qno+ 1}"/> <td align="center">{!q.Product__r.Brand__c}</td> <td align="center"> {!q.Product__r.name}</td> <td align="center"><img src='{!q.Product__r.Product_Image_Url__c}' width="135" height="100"/></td> <td align="right">{!q.Quantity__c}</td> <td width="10%" align="right">{!q.Price__c}</td> <td align="right">{!q.Total_Price__c}</td> <apex:variable value="{!qtotal1+q.Total_Price__c}" var="qtotal1"/> <td align="center">{!q.Delevery_Time__c}</td> <td align="center">{!q.Remarks__c}</td> </tr> </apex:repeat> <tr style="color:black;font-weight:bold;font-size:10pt;"> <td colspan="6" align="right">TOTAL</td> <td align="right">{!qtotal1}</td> <td colspan="2"></td> </tr><br clear="all" style="page-break-before:always" /> </table> <table width="100%" style="font-family:sans-serif;"> <tr> <td width="20%" align="left" style="font-size:10pt;font-family:sans-serif;"><b><u>Payment Terms:</u></b></td><br clear="all" style="page-break-before:always" /> </tr> <tr> <td style="font-family:sans-serif;font-size:9pt;"> <apex:outputText value="{!qtn.Payment_Terms__c}" escape="false"/> </td> </tr> <tr> <td width="20%" align="left" style="font-size:10pt;font-family:sans-serif;"><b><u>Special Instructions:</u></b></td><br clear="all" style="page-break-before:always" /> </tr> <tr> <td style="font-family:sans-serif;font-size:9pt;"> <apex:outputText value="{!qtn.Special_Instructions__c}" escape="false"/> </td> </tr> <tr> <td width="20%" align="left" style="font-size:10pt;font-family:sans-serif;"><b><u>Terms & Conditions:</u></b></td> </tr> <tr> <td style="font-family:sans-serif;font-size:9pt;"> <apex:outputText value="{!qtn.Terms_Conditions__c}" escape="false"/> </td> </tr> </table> <table width="100%" style="font-family:sans-serif;font-size:10pt;"> <tr style="font-family:sans-serif;font-size:10pt;"> <td align="left"><b>E&O.E.</b></td><br clear="all" style="page-break-before:always" /> </tr> <tr style="font-family:sans-serif;font-size:10pt;"> <td align="left">Thanking You,</td> </tr> <tr style="font-family:sans-serif;font-size:10pt;"> <td align="left">Best Regards</td> </tr> <tr style="font-family:sans-serif;font-size:10pt;"> <td align="left"></td> </tr> </table> </body> </html> </apex:page>Please help me to resolve this.
Thanks
- Devmen
- September 05, 2018
- Like
- 0
system.assertion failed
hi,
i have a test class.It is throwing error System.Assertexception
the result.success is getting false.how can i resolve this error
thanks
i have a test class.It is throwing error System.Assertexception
Lead newLead = new Lead(); newLead.LastName='TestName'; newLead.Company = 'TestCompany'; newLead.Email='test@test.com'; newLead.Status ='Open'; newLead.Cc__c='test@test.com'; newLead.Description='Subject:TextBody'; insert newlead; Messaging.InboundEmail email = new Messaging.InboundEmail() ; Messaging.InboundEnvelope env = new Messaging.InboundEnvelope(); email.plainTextBody = 'teset'; email.fromAddress = 'test@test.com'; email.subject = 'Test Lead'; // email.ToAddress ='test@gmail.com'; CreateLeadExample edr = new CreateLeadExample(); edr.handleInboundEmail(email,env); Test.startTest(); Messaging.InboundEmailResult result = edr.handleInboundEmail(email, env); System.assert(result.success, 'Error processing email...'); Test.stopTest(); Lead [] leadDb = [SELECT Id FROM Lead where LastName=:email.FromAddress]; // System.assertEquals (1, leadDb.size(),'Lead was not inserted'); System.debug('Size'+leadDb.size()); attachment.body = blob.valueOf('my attachment text'); attachment.fileName = 'text'; email.binaryAttachments = new Messaging.inboundEmail.BinaryAttachment[] { attachment }; Attachment attach=new Attachment(); attach.Name='Test'; Blob bodyBlob=Blob.valueOf('Testing Body of Attachment'); attach.body=bodyBlob; insert attach;
the result.success is getting false.how can i resolve this error
thanks
- Devmen
- August 07, 2018
- Like
- 0
How to get bcc mail id in emailservice class?
Hi,
I've created a email field (bcc) in lead.I want to populate bcc mail id here using email service class.How can i acheive this?
Thanks
Devmen
I've created a email field (bcc) in lead.I want to populate bcc mail id here using email service class.How can i acheive this?
Thanks
Devmen
- Devmen
- August 05, 2018
- Like
- 0