-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
33Questions
-
34Replies
How To Creare Gantt Chart In Aura Component ?? Anyone have an idea
Hi Everyone
How to create gantt chart in aura component any have created in aura component any idea how to achieve this functionality below is the screen i wanna to create in aura component
How to create gantt chart in aura component any have created in aura component any idea how to achieve this functionality below is the screen i wanna to create in aura component
-
- Neeraj Sharma 103
- November 04, 2020
- Like
- 0
- Continue reading or reply
How to use External Service for callouts
How to use external Service functionality for callout in salesforce with Process Builder
-
- Neeraj Sharma 103
- June 16, 2020
- Like
- 0
- Continue reading or reply
Hi Everyone I have three Custom Objects CustomObjA , CustomObjB, CustomObjc Now i wan to do roll up
Hi Everyone I have three Custom Objects
CustomObj A
Custom Obj B
Custom Obj C
CustomObj A is the lookup on Custom Obj B and Custom Obj C
But Custom Obj B and Custom Obj C in between there is no relation between us Now My Requirement is there is a Number fields on Custom Obj B and Custom Obj C I want to SumUp of both these fields and Populate on CustomObj A So How to achieve this requirement Please tell me
CustomObj A
Custom Obj B
Custom Obj C
CustomObj A is the lookup on Custom Obj B and Custom Obj C
But Custom Obj B and Custom Obj C in between there is no relation between us Now My Requirement is there is a Number fields on Custom Obj B and Custom Obj C I want to SumUp of both these fields and Populate on CustomObj A So How to achieve this requirement Please tell me
-
- Neeraj Sharma 103
- September 09, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone Anyone Help Me I want to use After Insert,After Update,After Delete in one trigger
Hi Everyone Anyone Help Me I want to use After Insert,After Update,After Delete in one trigger througth trigger Handler and
i want to call all these events in one method from trigger in trigger handler class
Anyone Have Example anyone do this types of scenarios when used these events so please help me
i want to call all these events in one method from trigger in trigger handler class
Anyone Have Example anyone do this types of scenarios when used these events so please help me
-
- Neeraj Sharma 103
- September 04, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone How to insert a record in custom object
Hi
Everyone How to insert a record in custom object which is under in Contact Standard Object Lookup RelationShip Between them
Attendance__c lookup (Contact)
Thanks and Regards
neeraj Sharma
Everyone How to insert a record in custom object which is under in Contact Standard Object Lookup RelationShip Between them
Attendance__c lookup (Contact)
Thanks and Regards
neeraj Sharma
-
- Neeraj Sharma 103
- August 27, 2019
- Like
- 0
- Continue reading or reply
Hi I have a one issue for Registration of Community User through Custom VF Page
Hi
I Have Created a Custom VF Page for Registration Community User
But When my domain url search on another browser then custom login page is open but when i click on register then its shows below error from site

My Domain URL IS :
https://pmportal-developer-edition.ap15.force.com/PMPortal
Thanks & Regards
Neeraj Sharma
I Have Created a Custom VF Page for Registration Community User
But When my domain url search on another browser then custom login page is open but when i click on register then its shows below error from site
My Domain URL IS :
https://pmportal-developer-edition.ap15.force.com/PMPortal
Thanks & Regards
Neeraj Sharma
-
- Neeraj Sharma 103
- August 27, 2019
- Like
- 0
- Continue reading or reply
Hi I have a issue for Registration of Community User through Custom VF Page
Hi
I Have Created a Custom VF Page for Registration Community User
But When my domai n url search on another browser then custom login page is open but when i click on register then its shows below error from site
My Domain URL IS :
https://pmportal-developer-edition.ap15.force.com/PMPortal
Thanks & Regards
Neeraj Sharma
I Have Created a Custom VF Page for Registration Community User
But When my domai n url search on another browser then custom login page is open but when i click on register then its shows below error from site
https://pmportal-developer-edition.ap15.force.com/PMPortal
Thanks & Regards
Neeraj Sharma
-
- Neeraj Sharma 103
- August 26, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone Anyone Create Custom VF page for Registration for Community User and Controller Class
Hi Everyone
Anyone Create Custom VF page for Registration of Community User and Controller Class Anyone Do So Please Share With me
Thanks
Neeraj Sharma
Anyone Create Custom VF page for Registration of Community User and Controller Class Anyone Do So Please Share With me
Thanks
Neeraj Sharma
-
- Neeraj Sharma 103
- August 26, 2019
- Like
- 0
- Continue reading or reply
How to Create Registration Visual force Page for community user anyone create so please help me any example
Hi Everyone Please Help me
How to Create Registration Visual force Page for community user anyone create so please help me any example
How to Create Registration Visual force Page for community user anyone create so please help me any example
-
- Neeraj Sharma 103
- August 23, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone how to write test class for below trigger with Trigger handler
Trigger trigger LeadTrigger on Lead(before insert, before Update) { if (trigger.isInsert && trigger.isBefore) { LeadTriggerHandler.onBeforeInsert(trigger.new); } else if (trigger.isUpdate && trigger.isBefore) { LeadTriggerHandler.onBeforeUpdate(trigger.new, trigger.oldMap); } }
TrigerHandlerClass public class LeadTriggerHandler { public static String STATUS_SELF_REPRESENTED = 'Self Represented'; public static void onBeforeInsert(list <Lead> newLeadList){ updateFldsOnLead(newLeadList, null); } public static void onBeforeUpdate(list <Lead> newLeadList, map <Id, Lead> oldLeadMap){ updateFldsOnLead(newLeadList, oldLeadMap); } public static void updateFldsOnLead(list <Lead> newLeadList, map <Id, Lead> oldLeadMap){ map<String, list<lead>> zipCodeLeadMap = new Map <String, list<lead>> (); for(Lead ld: newLeadList){ if(ld.Status != STATUS_SELF_REPRESENTED && ld.PostalCode != null){ if(!zipCodeLeadMap.containsKey(ld.PostalCode)){ zipCodeLeadMap.put(ld.PostalCode, new list<lead>()); } zipCodeLeadMap.get(ld.PostalCode).add(ld); } } if(zipCodeLeadMap.size() > 0){ for(Lead_WF_Configuration__mdt ldConfigCMD: [Select Id, Zip_Postal__c, State__c, County__c,OwnerID__c From Lead_WF_Configuration__mdt]){ for(String zip: zipCodeLeadMap.keySet()){ if(String.valueOf(ldConfigCMD.Zip_Postal__c).contains(zip)){ for(Lead ld: zipCodeLeadMap.get(zip)){ ld.State = ldConfigCMD.State__c; ld.County__c = ldConfigCMD.County__c; ld.OwnerId = ldConfigCMD.OwnerID__c; } } } } } } }
-
- Neeraj Sharma 103
- August 14, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone When i used Bootstrap 4 in visualforce page then the tag color will be different how its is possbile
Hi Experts
Hi Everyone When i used Bootstrap 4 in visualforce page then the tag color will be different how its is possbile and developer console is not showing any error
Hi Everyone When i used Bootstrap 4 in visualforce page then the tag color will be different how its is possbile and developer console is not showing any error
-
- Neeraj Sharma 103
- July 04, 2019
- Like
- 0
- Continue reading or reply
Hi Experts i have a Simple vf page and in vf page some fields are input and a save button
Hi Experts i have a Simple vf page and in vf page some fields are input and a save button when user fill the form and then clicked on save button then the data will be stored as a pdf and download it
So Any Example how to achieve this functionaliy
So Any Example how to achieve this functionaliy
-
- Neeraj Sharma 103
- July 01, 2019
- Like
- 0
- Continue reading or reply
In below Apex class my test class code covered is 55%
Hi Please help for test class public with sharing class schedulexpensecontroller { public list<Expense_Management__c> con{get;set;} public list<Expense_Management__c> em{get;set;} public double total1{get;set;} public Date fromdate{get;set;} public Date todate{get;set;} public Id parent {get;set;} public schedulexpensecontroller(){ Id conId = apexpages.currentpage().getparameters().get('id'); parent = UserInfo.getUserId(); if(apexpages.currentpage().getparameters().get('fromdate') !=null && apexpages.currentpage().getparameters().get('todate')!=null) { fromdate = Date.Parse(apexpages.currentpage().getparameters().get('fromdate')); todate = Date.Parse(apexpages.currentpage().getparameters().get('todate')); con = [Select Date__c,From__c,To__c,Purpose_of_Travel__c,Mode_of_Travel__c, Opening_KM__c,Closing_KM__c,Rate__c,Total_Km__c,Total_Travel_Expense__c , Lodging_Expense__c,Miscellaneous_Expense__c, Description__c,Total_Expenses__c,Local_Conveyance__c, Paid_Amount__c,Payment__c, Name_of_Employee__r.EmployeeNumber,Name_of_Employee__r.UserRole.Name,Name_of_Employee__r.Name from Expense_Management__c where Name_of_Employee__c =: parent AND CreatedDate >=: fromdate AND CreatedDate <=: todate]; em = [Select Payment__c,Total_Expenses__c from Expense_Management__c where Payment__c = 'unpaid' AND Name_of_Employee__c =: parent]; }else { con = [Select Date__c,From__c,To__c,Purpose_of_Travel__c,Mode_of_Travel__c, Opening_KM__c,Closing_KM__c,Rate__c,Total_Km__c,Total_Travel_Expense__c , Lodging_Expense__c,Miscellaneous_Expense__c, Description__c,Total_Expenses__c,Local_Conveyance__c, Paid_Amount__c,Payment__c, Name_of_Employee__r.EmployeeNumber,Name_of_Employee__r.UserRole.Name,Name_of_Employee__r.Name from Expense_Management__c where Name_of_Employee__c =: conId ]; em = [Select Payment__c,Total_Expenses__c from Expense_Management__c where Payment__c = 'unpaid' AND Name_of_Employee__c =: conId]; } } }
@isTest public class Testclassforscheduleexpensecontroller { @isTest static void testmethod1() { schedulexpensecontroller cons= new schedulexpensecontroller(); // Date from1; // cons.fromdate=from1.parse('06/18/2019'); //fromdate = Date.Parse(apexpages.currentpage().getparameters().get('fromdate')); } }
-
- Neeraj Sharma 103
- June 18, 2019
- Like
- 0
- Continue reading or reply
How to Write test Class for below Apex Class Controller Please Replay ASAP
public class EmailInvoiceA { @auraEnabled public static void sendMailWithPDF(String recordId){ for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){ list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>(); Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage(); List<String> sendTo = new List<String>(); Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment(); PageReference pref = page.PdfEmailInvoice; pref.getParameters().put('Id',recordId); pref.setRedirect(true); Blob b; b = pref.getContent(); attach.setFileName('Invoice.pdf'); attach.setBody(b); semail.setSubject('Invoice details'); semail.setReplyTo('noreply@gmail.com'); semail.setSenderDisplayName('salesforce User'); sendTo.add(cc.Distributor__r.E_mail__c); List<String> send = new List<String>(); if(cc.Distributor__r.E_mail__c==null && cc.Distributor__r.CC_to_if_any__c != null) { send.add(cc.Distributor__r.CC_to_if_any__c); semail.setToAddresses(send); } else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c != null) { sendTo.add(cc.Distributor__r.E_mail__c); send.add(cc.Distributor__r.CC_to_if_any__c); semail.setccAddresses(send); semail.setToAddresses(sendTo); } else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c == null) { sendTo.add(cc.Distributor__r.E_mail__c); semail.setToAddresses(sendTo); } mails.add(semail); String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>'; semail.setHtmlBody(emailBody); semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach}); Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail}); } } @auraEnabled public static void sendMailWith(String recordId,String mMail){ for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){ list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>(); Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage(); List<String> sendTo = new List<String>(); sendTo.add(mMail); Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment(); PageReference pref = page.PdfEmailInvoice; pref.getParameters().put('Id',recordId); pref.setRedirect(true); Blob b; b = pref.getContent(); attach.setFileName('Invoice.pdf'); attach.setBody(b); semail.setSubject('Invoice details'); semail.setReplyTo('noreply@gmail.com'); semail.setSenderDisplayName('salesforce User'); List<String> send = new List<String>(); if(cc.Distributor__r.CC_to_if_any__c != null) { send.add(cc.Distributor__r.CC_to_if_any__c); } mails.add(semail); semail.setCcAddresses(send); semail.setToAddresses(sendTo); String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>'; semail.setHtmlBody(emailBody); semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach}); Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail}); } } @auraEnabled public static void Mail(String recordId,String mMail,boolean checkCmp){ for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){ list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>(); Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage(); List<String> sendTo = new List<String>(); Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment(); PageReference pref = page.PdfEmailInvoice; pref.getParameters().put('Id',recordId); pref.setRedirect(true); Blob b; b = pref.getContent(); attach.setFileName('Invoice.pdf'); attach.setBody(b); semail.setSubject('Invoice details'); semail.setReplyTo('noreply@gmail.com'); semail.setSenderDisplayName('salesforce User'); if(checkCmp==true) { sendTo.add(mMail); semail.setToAddresses(sendTo); } else if(checkCmp==false) { if(mMail != null) { sendTo.add(mMail); semail.setToAddresses(sendTo); } if(cc.Distributor__r.E_mail__c != null) { sendTo.add(cc.Distributor__r.E_mail__c); semail.setToAddresses(sendTo); } if(cc.Distributor__r.CC_to_if_any__c != null) { List<String> send = new List<String>();//cc string send.add(cc.Distributor__r.CC_to_if_any__c); semail.setCcAddresses(send); } } mails.add(semail); String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>'; semail.setHtmlBody(emailBody); semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach}); Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail}); } } }
-
- Neeraj Sharma 103
- June 14, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone can we create custom salesforce bell notification
Hi Experts
Can we create a salesforce bell notification for approval process using Apex Trigger,Apex class , Lightning Component I searched on google also its says By Using Process builder we create a salesforce custom notification but i want to send notification when user clicked on the submit for approval button i am and in approval process My Users in queues so salesforce not sent bell notification to Queue Users so how to send bell notificatio Queue Users If any one doing this type of scenario so please share with me Any Example
Thanks in Advance
Neeraj Sharma
Can we create a salesforce bell notification for approval process using Apex Trigger,Apex class , Lightning Component I searched on google also its says By Using Process builder we create a salesforce custom notification but i want to send notification when user clicked on the submit for approval button i am and in approval process My Users in queues so salesforce not sent bell notification to Queue Users so how to send bell notificatio Queue Users If any one doing this type of scenario so please share with me Any Example
Thanks in Advance
Neeraj Sharma
-
- Neeraj Sharma 103
- June 14, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone i created a lightning data table in component but its not shows properly in mobile view
Hi Experts Please Help me For Below Code
in this code i used lightning data table it show not proper in salesforce1 mobile app its shows like this:
So Please Replay ASAP
Thanks in Advance
Neeraj
in this code i used lightning data table it show not proper in salesforce1 mobile app its shows like this:
<aura:component implements="force:LightningQuickAction,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="Eventrecordcomponent"> <!-- attributes --> <aura:attribute name="recordId" type="String"></aura:attribute> <aura:attribute name="recordTypes" type="String"></aura:attribute> <aura:attribute name="mydata" type="Object"></aura:attribute> <aura:attribute name="mycolumns" type="List"></aura:attribute> <aura:attribute name="noResults" type="String"></aura:attribute> <!-- handlers--> <aura:handler name="init" value="{!this }" action="{!c.init }"></aura:handler> <article aura:id="gridContainer" class="slds-card slds-card_boundary"> <lightning:card title="Check In/Check Out Manager" iconName="standard:document"> <div class="slds-card__header slds-grid"> <aura:if isTrue="{!not(empty(v.mydata))}" > <!-- the container element determine the height of the datatable --> <lightning:datatable keyField="id" data="{! v.mydata }" columns="{! v.mycolumns }" hideCheckboxColumn="true" ></lightning:datatable> </aura:if> <aura:if isTrue="{!empty(v.mydata)}" > <p Style="color:red;">{! v.noResults }</p> </aura:if> </div> </lightning:card> </article> </aura:component>
So Please Replay ASAP
Thanks in Advance
Neeraj
-
- Neeraj Sharma 103
- June 12, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone How to calculate distance between two marker and show them on the Map like CheckIn and CheckOut
Hi
Everyone How to calculate distance between two marker and show them on the Map like CheckIn and CheckOut when user check in then its show on the map i doing this already now i want to show checkout also on the map and also distance calculate between them and distance show on the checkin marker
Please Replay ASAP
Thanks in Advance
Neeraj
Everyone How to calculate distance between two marker and show them on the Map like CheckIn and CheckOut when user check in then its show on the map i doing this already now i want to show checkout also on the map and also distance calculate between them and distance show on the checkin marker
Please Replay ASAP
Thanks in Advance
Neeraj
-
- Neeraj Sharma 103
- June 10, 2019
- Like
- 0
- Continue reading or reply
How to write test Class for below apex class controller
Please Help me to write test class for below apex class controller
abc.apexclass
public class EmailInvoiceA {
@auraEnabled
public static void sendMailWithPDF(String recordId){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();//to string
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
sendTo.add(cc.Distributor__r.E_mail__c);
List<String> send = new List<String>();//cc string
system.debug('sendlis'+send);
// if(cc.Distributor__r.CC_to_if_any__c != null)
// {
// send.add(cc.Distributor__r.CC_to_if_any__c);
// }
if(cc.Distributor__r.E_mail__c==null && cc.Distributor__r.CC_to_if_any__c != null)
{
send.add(cc.Distributor__r.CC_to_if_any__c);
//semail.setccAddresses(sendTo);
semail.setToAddresses(send);
}
else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c != null)
{
sendTo.add(cc.Distributor__r.E_mail__c);
send.add(cc.Distributor__r.CC_to_if_any__c);
semail.setccAddresses(send);
semail.setToAddresses(sendTo);
}
else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c == null)
{
sendTo.add(cc.Distributor__r.E_mail__c);
semail.setToAddresses(sendTo);
}
mails.add(semail);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
}
}
@auraEnabled
public static void sendMailWith(String recordId,String mMail){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(mMail);
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
//sendTo.add(cc.Distributor__r.E_mail__c);
List<String> send = new List<String>();
if(cc.Distributor__r.CC_to_if_any__c != null)
{
send.add(cc.Distributor__r.CC_to_if_any__c);
}
mails.add(semail);
semail.setCcAddresses(send);
semail.setToAddresses(sendTo);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
system.debug('email send');
}
}
@auraEnabled
public static void Mail(String recordId,String mMail,boolean checkCmp){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();//to string
system.debug(checkCmp);
// semail.setToAddresses(sendTo);
//shrutinigam1998@gmail.com
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
if(checkCmp==true)
{
sendTo.add(mMail);
semail.setToAddresses(sendTo);
}
else if(checkCmp==false)
{
system.debug('hi check'+checkCmp);
if(mMail != null)
{
system.debug('hi mMail'+mMail);
sendTo.add(mMail);
semail.setToAddresses(sendTo);
}
if(cc.Distributor__r.E_mail__c != null)
{ system.debug('hi Distributor mail'+cc.Distributor__r.E_mail__c);
sendTo.add(cc.Distributor__r.E_mail__c);
semail.setToAddresses(sendTo);
}
if(cc.Distributor__r.CC_to_if_any__c != null)
{
system.debug('hi Distributor cc mail'+cc.Distributor__r.CC_to_if_any__c);
List<String> send = new List<String>();//cc string
send.add(cc.Distributor__r.CC_to_if_any__c);
semail.setCcAddresses(send);
}
}
mails.add(semail);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
system.debug('email send');
}
}
}
abc.apexclass
public class EmailInvoiceA {
@auraEnabled
public static void sendMailWithPDF(String recordId){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();//to string
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
sendTo.add(cc.Distributor__r.E_mail__c);
List<String> send = new List<String>();//cc string
system.debug('sendlis'+send);
// if(cc.Distributor__r.CC_to_if_any__c != null)
// {
// send.add(cc.Distributor__r.CC_to_if_any__c);
// }
if(cc.Distributor__r.E_mail__c==null && cc.Distributor__r.CC_to_if_any__c != null)
{
send.add(cc.Distributor__r.CC_to_if_any__c);
//semail.setccAddresses(sendTo);
semail.setToAddresses(send);
}
else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c != null)
{
sendTo.add(cc.Distributor__r.E_mail__c);
send.add(cc.Distributor__r.CC_to_if_any__c);
semail.setccAddresses(send);
semail.setToAddresses(sendTo);
}
else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c == null)
{
sendTo.add(cc.Distributor__r.E_mail__c);
semail.setToAddresses(sendTo);
}
mails.add(semail);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
}
}
@auraEnabled
public static void sendMailWith(String recordId,String mMail){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(mMail);
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
//sendTo.add(cc.Distributor__r.E_mail__c);
List<String> send = new List<String>();
if(cc.Distributor__r.CC_to_if_any__c != null)
{
send.add(cc.Distributor__r.CC_to_if_any__c);
}
mails.add(semail);
semail.setCcAddresses(send);
semail.setToAddresses(sendTo);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
system.debug('email send');
}
}
@auraEnabled
public static void Mail(String recordId,String mMail,boolean checkCmp){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();//to string
system.debug(checkCmp);
// semail.setToAddresses(sendTo);
//shrutinigam1998@gmail.com
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
if(checkCmp==true)
{
sendTo.add(mMail);
semail.setToAddresses(sendTo);
}
else if(checkCmp==false)
{
system.debug('hi check'+checkCmp);
if(mMail != null)
{
system.debug('hi mMail'+mMail);
sendTo.add(mMail);
semail.setToAddresses(sendTo);
}
if(cc.Distributor__r.E_mail__c != null)
{ system.debug('hi Distributor mail'+cc.Distributor__r.E_mail__c);
sendTo.add(cc.Distributor__r.E_mail__c);
semail.setToAddresses(sendTo);
}
if(cc.Distributor__r.CC_to_if_any__c != null)
{
system.debug('hi Distributor cc mail'+cc.Distributor__r.CC_to_if_any__c);
List<String> send = new List<String>();//cc string
send.add(cc.Distributor__r.CC_to_if_any__c);
semail.setCcAddresses(send);
}
}
mails.add(semail);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
system.debug('email send');
}
}
}
-
- Neeraj Sharma 103
- May 29, 2019
- Like
- 0
- Continue reading or reply
need help in lightning component
HI all,
I habve created a quick lightning action button and in the pop up i have placed one checkbox.
Problrm is that when condition is false it is working perfectly when it is true it is not calling the aura enabled class in controller.
I habve created a quick lightning action button and in the pop up i have placed one checkbox.
Problrm is that when condition is false it is working perfectly when it is true it is not calling the aura enabled class in controller.
-
- Neeraj Sharma 103
- May 24, 2019
- Like
- 0
- Continue reading or reply
How to validate Standard Phone Field of Account Object with Apex Class with validation is Only 10Digit is input by user
Hi
I am new in Salesforce Begineer
My Question is:
How to validate Phone field of Account Object with Use of Apex Class and the validation is ONly 10 Digit is input by user no sepcial character no characters Only digits and digit will be 10
and if user input digit according the condition then the record will be save and user not input 10digit then error will be show on the Phone field "Please Provide Valid Number" on Custom Visual force Page
Please help me ASAP
Thanks
Neeraj Sharma
I am new in Salesforce Begineer
My Question is:
How to validate Phone field of Account Object with Use of Apex Class and the validation is ONly 10 Digit is input by user no sepcial character no characters Only digits and digit will be 10
and if user input digit according the condition then the record will be save and user not input 10digit then error will be show on the Phone field "Please Provide Valid Number" on Custom Visual force Page
Please help me ASAP
Thanks
Neeraj Sharma
-
- Neeraj Sharma 103
- February 08, 2019
- Like
- 1
- Continue reading or reply
How to use External Service for callouts
How to use external Service functionality for callout in salesforce with Process Builder
- Neeraj Sharma 103
- June 16, 2020
- Like
- 0
- Continue reading or reply
Hi Everyone I have three Custom Objects CustomObjA , CustomObjB, CustomObjc Now i wan to do roll up
Hi Everyone I have three Custom Objects
CustomObj A
Custom Obj B
Custom Obj C
CustomObj A is the lookup on Custom Obj B and Custom Obj C
But Custom Obj B and Custom Obj C in between there is no relation between us Now My Requirement is there is a Number fields on Custom Obj B and Custom Obj C I want to SumUp of both these fields and Populate on CustomObj A So How to achieve this requirement Please tell me
CustomObj A
Custom Obj B
Custom Obj C
CustomObj A is the lookup on Custom Obj B and Custom Obj C
But Custom Obj B and Custom Obj C in between there is no relation between us Now My Requirement is there is a Number fields on Custom Obj B and Custom Obj C I want to SumUp of both these fields and Populate on CustomObj A So How to achieve this requirement Please tell me
- Neeraj Sharma 103
- September 09, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone How to insert a record in custom object
Hi
Everyone How to insert a record in custom object which is under in Contact Standard Object Lookup RelationShip Between them
Attendance__c lookup (Contact)
Thanks and Regards
neeraj Sharma
Everyone How to insert a record in custom object which is under in Contact Standard Object Lookup RelationShip Between them
Attendance__c lookup (Contact)
Thanks and Regards
neeraj Sharma
- Neeraj Sharma 103
- August 27, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone how to write test class for below trigger with Trigger handler
Trigger trigger LeadTrigger on Lead(before insert, before Update) { if (trigger.isInsert && trigger.isBefore) { LeadTriggerHandler.onBeforeInsert(trigger.new); } else if (trigger.isUpdate && trigger.isBefore) { LeadTriggerHandler.onBeforeUpdate(trigger.new, trigger.oldMap); } }
TrigerHandlerClass public class LeadTriggerHandler { public static String STATUS_SELF_REPRESENTED = 'Self Represented'; public static void onBeforeInsert(list <Lead> newLeadList){ updateFldsOnLead(newLeadList, null); } public static void onBeforeUpdate(list <Lead> newLeadList, map <Id, Lead> oldLeadMap){ updateFldsOnLead(newLeadList, oldLeadMap); } public static void updateFldsOnLead(list <Lead> newLeadList, map <Id, Lead> oldLeadMap){ map<String, list<lead>> zipCodeLeadMap = new Map <String, list<lead>> (); for(Lead ld: newLeadList){ if(ld.Status != STATUS_SELF_REPRESENTED && ld.PostalCode != null){ if(!zipCodeLeadMap.containsKey(ld.PostalCode)){ zipCodeLeadMap.put(ld.PostalCode, new list<lead>()); } zipCodeLeadMap.get(ld.PostalCode).add(ld); } } if(zipCodeLeadMap.size() > 0){ for(Lead_WF_Configuration__mdt ldConfigCMD: [Select Id, Zip_Postal__c, State__c, County__c,OwnerID__c From Lead_WF_Configuration__mdt]){ for(String zip: zipCodeLeadMap.keySet()){ if(String.valueOf(ldConfigCMD.Zip_Postal__c).contains(zip)){ for(Lead ld: zipCodeLeadMap.get(zip)){ ld.State = ldConfigCMD.State__c; ld.County__c = ldConfigCMD.County__c; ld.OwnerId = ldConfigCMD.OwnerID__c; } } } } } } }
- Neeraj Sharma 103
- August 14, 2019
- Like
- 0
- Continue reading or reply
Hi Experts i have a Simple vf page and in vf page some fields are input and a save button
Hi Experts i have a Simple vf page and in vf page some fields are input and a save button when user fill the form and then clicked on save button then the data will be stored as a pdf and download it
So Any Example how to achieve this functionaliy
So Any Example how to achieve this functionaliy
- Neeraj Sharma 103
- July 01, 2019
- Like
- 0
- Continue reading or reply
In below Apex class my test class code covered is 55%
Hi Please help for test class public with sharing class schedulexpensecontroller { public list<Expense_Management__c> con{get;set;} public list<Expense_Management__c> em{get;set;} public double total1{get;set;} public Date fromdate{get;set;} public Date todate{get;set;} public Id parent {get;set;} public schedulexpensecontroller(){ Id conId = apexpages.currentpage().getparameters().get('id'); parent = UserInfo.getUserId(); if(apexpages.currentpage().getparameters().get('fromdate') !=null && apexpages.currentpage().getparameters().get('todate')!=null) { fromdate = Date.Parse(apexpages.currentpage().getparameters().get('fromdate')); todate = Date.Parse(apexpages.currentpage().getparameters().get('todate')); con = [Select Date__c,From__c,To__c,Purpose_of_Travel__c,Mode_of_Travel__c, Opening_KM__c,Closing_KM__c,Rate__c,Total_Km__c,Total_Travel_Expense__c , Lodging_Expense__c,Miscellaneous_Expense__c, Description__c,Total_Expenses__c,Local_Conveyance__c, Paid_Amount__c,Payment__c, Name_of_Employee__r.EmployeeNumber,Name_of_Employee__r.UserRole.Name,Name_of_Employee__r.Name from Expense_Management__c where Name_of_Employee__c =: parent AND CreatedDate >=: fromdate AND CreatedDate <=: todate]; em = [Select Payment__c,Total_Expenses__c from Expense_Management__c where Payment__c = 'unpaid' AND Name_of_Employee__c =: parent]; }else { con = [Select Date__c,From__c,To__c,Purpose_of_Travel__c,Mode_of_Travel__c, Opening_KM__c,Closing_KM__c,Rate__c,Total_Km__c,Total_Travel_Expense__c , Lodging_Expense__c,Miscellaneous_Expense__c, Description__c,Total_Expenses__c,Local_Conveyance__c, Paid_Amount__c,Payment__c, Name_of_Employee__r.EmployeeNumber,Name_of_Employee__r.UserRole.Name,Name_of_Employee__r.Name from Expense_Management__c where Name_of_Employee__c =: conId ]; em = [Select Payment__c,Total_Expenses__c from Expense_Management__c where Payment__c = 'unpaid' AND Name_of_Employee__c =: conId]; } } }
@isTest public class Testclassforscheduleexpensecontroller { @isTest static void testmethod1() { schedulexpensecontroller cons= new schedulexpensecontroller(); // Date from1; // cons.fromdate=from1.parse('06/18/2019'); //fromdate = Date.Parse(apexpages.currentpage().getparameters().get('fromdate')); } }
- Neeraj Sharma 103
- June 18, 2019
- Like
- 0
- Continue reading or reply
Hi Everyone can we create custom salesforce bell notification
Hi Experts
Can we create a salesforce bell notification for approval process using Apex Trigger,Apex class , Lightning Component I searched on google also its says By Using Process builder we create a salesforce custom notification but i want to send notification when user clicked on the submit for approval button i am and in approval process My Users in queues so salesforce not sent bell notification to Queue Users so how to send bell notificatio Queue Users If any one doing this type of scenario so please share with me Any Example
Thanks in Advance
Neeraj Sharma
Can we create a salesforce bell notification for approval process using Apex Trigger,Apex class , Lightning Component I searched on google also its says By Using Process builder we create a salesforce custom notification but i want to send notification when user clicked on the submit for approval button i am and in approval process My Users in queues so salesforce not sent bell notification to Queue Users so how to send bell notificatio Queue Users If any one doing this type of scenario so please share with me Any Example
Thanks in Advance
Neeraj Sharma
- Neeraj Sharma 103
- June 14, 2019
- Like
- 0
- Continue reading or reply
How to write test Class for below apex class controller
Please Help me to write test class for below apex class controller
abc.apexclass
public class EmailInvoiceA {
@auraEnabled
public static void sendMailWithPDF(String recordId){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();//to string
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
sendTo.add(cc.Distributor__r.E_mail__c);
List<String> send = new List<String>();//cc string
system.debug('sendlis'+send);
// if(cc.Distributor__r.CC_to_if_any__c != null)
// {
// send.add(cc.Distributor__r.CC_to_if_any__c);
// }
if(cc.Distributor__r.E_mail__c==null && cc.Distributor__r.CC_to_if_any__c != null)
{
send.add(cc.Distributor__r.CC_to_if_any__c);
//semail.setccAddresses(sendTo);
semail.setToAddresses(send);
}
else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c != null)
{
sendTo.add(cc.Distributor__r.E_mail__c);
send.add(cc.Distributor__r.CC_to_if_any__c);
semail.setccAddresses(send);
semail.setToAddresses(sendTo);
}
else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c == null)
{
sendTo.add(cc.Distributor__r.E_mail__c);
semail.setToAddresses(sendTo);
}
mails.add(semail);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
}
}
@auraEnabled
public static void sendMailWith(String recordId,String mMail){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(mMail);
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
//sendTo.add(cc.Distributor__r.E_mail__c);
List<String> send = new List<String>();
if(cc.Distributor__r.CC_to_if_any__c != null)
{
send.add(cc.Distributor__r.CC_to_if_any__c);
}
mails.add(semail);
semail.setCcAddresses(send);
semail.setToAddresses(sendTo);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
system.debug('email send');
}
}
@auraEnabled
public static void Mail(String recordId,String mMail,boolean checkCmp){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();//to string
system.debug(checkCmp);
// semail.setToAddresses(sendTo);
//shrutinigam1998@gmail.com
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
if(checkCmp==true)
{
sendTo.add(mMail);
semail.setToAddresses(sendTo);
}
else if(checkCmp==false)
{
system.debug('hi check'+checkCmp);
if(mMail != null)
{
system.debug('hi mMail'+mMail);
sendTo.add(mMail);
semail.setToAddresses(sendTo);
}
if(cc.Distributor__r.E_mail__c != null)
{ system.debug('hi Distributor mail'+cc.Distributor__r.E_mail__c);
sendTo.add(cc.Distributor__r.E_mail__c);
semail.setToAddresses(sendTo);
}
if(cc.Distributor__r.CC_to_if_any__c != null)
{
system.debug('hi Distributor cc mail'+cc.Distributor__r.CC_to_if_any__c);
List<String> send = new List<String>();//cc string
send.add(cc.Distributor__r.CC_to_if_any__c);
semail.setCcAddresses(send);
}
}
mails.add(semail);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
system.debug('email send');
}
}
}
abc.apexclass
public class EmailInvoiceA {
@auraEnabled
public static void sendMailWithPDF(String recordId){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();//to string
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
sendTo.add(cc.Distributor__r.E_mail__c);
List<String> send = new List<String>();//cc string
system.debug('sendlis'+send);
// if(cc.Distributor__r.CC_to_if_any__c != null)
// {
// send.add(cc.Distributor__r.CC_to_if_any__c);
// }
if(cc.Distributor__r.E_mail__c==null && cc.Distributor__r.CC_to_if_any__c != null)
{
send.add(cc.Distributor__r.CC_to_if_any__c);
//semail.setccAddresses(sendTo);
semail.setToAddresses(send);
}
else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c != null)
{
sendTo.add(cc.Distributor__r.E_mail__c);
send.add(cc.Distributor__r.CC_to_if_any__c);
semail.setccAddresses(send);
semail.setToAddresses(sendTo);
}
else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c == null)
{
sendTo.add(cc.Distributor__r.E_mail__c);
semail.setToAddresses(sendTo);
}
mails.add(semail);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
}
}
@auraEnabled
public static void sendMailWith(String recordId,String mMail){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(mMail);
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
//sendTo.add(cc.Distributor__r.E_mail__c);
List<String> send = new List<String>();
if(cc.Distributor__r.CC_to_if_any__c != null)
{
send.add(cc.Distributor__r.CC_to_if_any__c);
}
mails.add(semail);
semail.setCcAddresses(send);
semail.setToAddresses(sendTo);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
system.debug('email send');
}
}
@auraEnabled
public static void Mail(String recordId,String mMail,boolean checkCmp){
for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
list<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();//to string
system.debug(checkCmp);
// semail.setToAddresses(sendTo);
//shrutinigam1998@gmail.com
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
PageReference pref = page.PdfEmailInvoice;
pref.getParameters().put('Id',recordId);
pref.setRedirect(true);
Blob b;
b = pref.getContent();
attach.setFileName('Invoice.pdf');
attach.setBody(b);
semail.setSubject('Invoice details');
semail.setReplyTo('noreply@gmail.com');
semail.setSenderDisplayName('salesforce User');
if(checkCmp==true)
{
sendTo.add(mMail);
semail.setToAddresses(sendTo);
}
else if(checkCmp==false)
{
system.debug('hi check'+checkCmp);
if(mMail != null)
{
system.debug('hi mMail'+mMail);
sendTo.add(mMail);
semail.setToAddresses(sendTo);
}
if(cc.Distributor__r.E_mail__c != null)
{ system.debug('hi Distributor mail'+cc.Distributor__r.E_mail__c);
sendTo.add(cc.Distributor__r.E_mail__c);
semail.setToAddresses(sendTo);
}
if(cc.Distributor__r.CC_to_if_any__c != null)
{
system.debug('hi Distributor cc mail'+cc.Distributor__r.CC_to_if_any__c);
List<String> send = new List<String>();//cc string
send.add(cc.Distributor__r.CC_to_if_any__c);
semail.setCcAddresses(send);
}
}
mails.add(semail);
String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br> Regards, <br> IT Team <br> Sayaji Groups.</p></body></html>';
semail.setHtmlBody(emailBody);
semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
system.debug('email send');
}
}
}
- Neeraj Sharma 103
- May 29, 2019
- Like
- 0
- Continue reading or reply
How to write test class for below trigger Please help me
Hi Everyone this is my trigger i want to write test class for this so please help me i tried but not accomplish my requirement code coverge approx 75%
trigger Distributor on Account (before insert) {
String role;
String owner;
list<Account> changeOwner=new list<Account>();
for(Account acc:trigger.new){
if(acc.Under__c=='Chhattisgarh'){
role=' CG';
changeOwner.add(acc);
}
else if(acc.Under__c=='Bihar'){
role=' BI';
changeOwner.add(acc);
}
else if(acc.Under__c=='Rajasthan') {
role=' RJ';
changeOwner.add(acc);
}
else if(acc.Under__c=='Gujarat'){
role=' GJ';
changeOwner.add(acc);
}
else if(acc.Under__c=='Haryana'){
role=' HR';
changeOwner.add(acc);
}
else if(acc.Under__c=='Jharkhand'){
role=' JH';
changeOwner.add(acc);
}
else if(acc.Under__c=='Maharashtra'){
role=' MH';
changeOwner.add(acc);
}
else if(acc.Under__c=='Madhya Pradesh'){
role=' MP';
changeOwner.add(acc);
}
else if(acc.Under__c=='Uttar Pradesh'){
role=' UP';
changeOwner.add(acc);
}
}
String SOSTR = String.valueOf('SO') + String.valueOf(role);
String ASMSTR = String.valueOf('ASM') + String.valueOf(role);
String DRMSTR = String.valueOf('DRM') + String.valueOf(role);
String RMSTR = String.valueOf('RM') + String.valueOf(role);
list <User> socg1=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :SOSTR Order By FirstName,LastName');
list <User> socg2=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :ASMSTR Order By FirstName,LastName');
list <User> socg3=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :DRMSTR Order By FirstName,LastName');
list <User> socg4=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :RMSTR Order By FirstName,LastName');
if(socg1.size()>0){
owner=socg1.get(0).id;
}
else if(socg1.size()<=0){
if(socg2.size()>0){
owner=socg2.get(0).id;
}
else if(socg2.size()<=0){
if(socg3.size()>0){
owner=socg2.get(0).id;
}
else if(socg3.size()<=0){
if(socg4.size()>0) {
owner=socg4.get(0).id;
}
}
}
}
for(Account acc:changeOwner){
if(socg1!=null){
acc.OwnerId=Owner;
}
}
}
trigger Distributor on Account (before insert) {
String role;
String owner;
list<Account> changeOwner=new list<Account>();
for(Account acc:trigger.new){
if(acc.Under__c=='Chhattisgarh'){
role=' CG';
changeOwner.add(acc);
}
else if(acc.Under__c=='Bihar'){
role=' BI';
changeOwner.add(acc);
}
else if(acc.Under__c=='Rajasthan') {
role=' RJ';
changeOwner.add(acc);
}
else if(acc.Under__c=='Gujarat'){
role=' GJ';
changeOwner.add(acc);
}
else if(acc.Under__c=='Haryana'){
role=' HR';
changeOwner.add(acc);
}
else if(acc.Under__c=='Jharkhand'){
role=' JH';
changeOwner.add(acc);
}
else if(acc.Under__c=='Maharashtra'){
role=' MH';
changeOwner.add(acc);
}
else if(acc.Under__c=='Madhya Pradesh'){
role=' MP';
changeOwner.add(acc);
}
else if(acc.Under__c=='Uttar Pradesh'){
role=' UP';
changeOwner.add(acc);
}
}
String SOSTR = String.valueOf('SO') + String.valueOf(role);
String ASMSTR = String.valueOf('ASM') + String.valueOf(role);
String DRMSTR = String.valueOf('DRM') + String.valueOf(role);
String RMSTR = String.valueOf('RM') + String.valueOf(role);
list <User> socg1=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :SOSTR Order By FirstName,LastName');
list <User> socg2=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :ASMSTR Order By FirstName,LastName');
list <User> socg3=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :DRMSTR Order By FirstName,LastName');
list <User> socg4=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :RMSTR Order By FirstName,LastName');
if(socg1.size()>0){
owner=socg1.get(0).id;
}
else if(socg1.size()<=0){
if(socg2.size()>0){
owner=socg2.get(0).id;
}
else if(socg2.size()<=0){
if(socg3.size()>0){
owner=socg2.get(0).id;
}
else if(socg3.size()<=0){
if(socg4.size()>0) {
owner=socg4.get(0).id;
}
}
}
}
for(Account acc:changeOwner){
if(socg1!=null){
acc.OwnerId=Owner;
}
}
}
- Neeraj Sharma 103
- May 09, 2019
- Like
- 0
- Continue reading or reply
I want to change account owner based on custom state field (Picklist) and account owner change based on role hierarchy and in role hierarchy the role will by state wise
Hi Everyone Please help me out from this scenario
I want to update Account record owner incase custom state field is anyone selected from picklist(Gujarat,Rajasthan,Bihar,etc) with higher role and role checked
four levels above in role hiearchy if state chandigarh is select then (SOCG (SalesOfficer Chandigarh)) in this role the user will be updated on record owner and if no user in role of (SOCG) then above him(ASM CG) user is update on record owner this level go up to last level at (RM CG)
and if RMCG in this role there is no user then by default record owner will be update to this role user(RM CG)
- Neeraj Sharma 103
- May 06, 2019
- Like
- 0
- Continue reading or reply