You need to sign in to do that
Don't have an account?

Pass record data to class in process builder
hi, the following code creates a csv and sends it attached by email. When I paste this into dev console and execute, it works perfectly.
However, I need to create this as a class and process via a process builder and pass 3 variables of information to the class; strEmailTo, strPhone and strTreatment. I'm not sure how to do this. Any help much appreciated thanks.
string header = 'Telephone;Content \n';
string finalstr = header ;
string mStr;
string strPhone;
string strDate;
string strEmailTo;
string strTreatment;
strDate = '01/09/2019';
strPhone = '12345678';
strEmailTo = 'me@me.com';
strTreatment = 'test123';
mStr='Hi, your '+strTreatment+ ' treatment is scheduled for '+strDate ;
string recordString = +strphone+';'+mstr+'\n';
finalstr = finalstr +recordString;
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(finalstr);
string csvname= 'custom.csv';
csvAttc.setFileName(csvname);
csvAttc.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] toAddresses = new list<string> {strEmailTo};
String subject ='Visit';
email.setSubject(subject);
email.setToAddresses( toAddresses );
email.setPlainTextBody('%Content%');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
However, I need to create this as a class and process via a process builder and pass 3 variables of information to the class; strEmailTo, strPhone and strTreatment. I'm not sure how to do this. Any help much appreciated thanks.
string header = 'Telephone;Content \n';
string finalstr = header ;
string mStr;
string strPhone;
string strDate;
string strEmailTo;
string strTreatment;
strDate = '01/09/2019';
strPhone = '12345678';
strEmailTo = 'me@me.com';
strTreatment = 'test123';
mStr='Hi, your '+strTreatment+ ' treatment is scheduled for '+strDate ;
string recordString = +strphone+';'+mstr+'\n';
finalstr = finalstr +recordString;
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(finalstr);
string csvname= 'custom.csv';
csvAttc.setFileName(csvname);
csvAttc.setBody(csvBlob);
Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
String[] toAddresses = new list<string> {strEmailTo};
String subject ='Visit';
email.setSubject(subject);
email.setToAddresses( toAddresses );
email.setPlainTextBody('%Content%');
email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvAttc});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
All Answers