• Mark Moggy
  • NEWBIE
  • 0 Points
  • Member since 2013
  • Bizmarketing

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 8
    Replies
We are firing a visualforce template via workflow rule, work flow rule is on Opportunity and it is coming 100% empty in some cases and in some cases it's working fine. When we test the template manually it's working fine. Is there any limitation for visualforce template or what might be the issue?

Thanks in advance.

We have a repository that holds text for email as pure HTML.  I have some code to send email with this text as the html body and that works well and is fairly simple.  We can also add attachments.

What I haven't figured out how to do is embed and image in the email.  From what I understand, the email would have in it a "cid:" URL like --
 

<img width="128" height="128" id="Picture_x0020_1" src="cid:image001.png@01CF6E9E.C4B30B30">
I could compose a tag like that no problem.  The issue is the cid: for the image.  I know how to add attachments.  And I know you can set the inline flag to true or false.  What I can't see a way to do is set the id for an attachment I'm including (or get back an ID after attaching it) so I can then put that content id (cid:) in the URL in the HTML body.

It may be that the email and attachment classes in Apex are just not deep enough to perform this task.  But if anyone know's a way to do it, feel free to post suggestions.




I

Hi, 

 

New user, non techincal, so please bear with me. 

 

I'd reallty like to get some Chatter user activity with RFID tags. Has anyone used (RFID/NFC) the Chatter API in this way, to enable offline 'likes' of, for example poster sites or documents?

 

My only assumptions is that user identification/password verification might be a block for this? RFID could hold that data, but not sure if the API would allow that sort of interaction.

 

Any help gratefully received.

 

Thanks

 

Duncan

Hi, 

 

Can any one send the steps how to
"convert lookup reationship field to master detail realtionship"

Hi

 

I want to remove multi-user calendar view for chatter user or for particular profile. If not possible, is there way to hide calendar details display for users other than logged user.

Hi 

 

I am getting error  : Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 137.203KB 

 

we have button on case, to create Csae Time report, We have Comments, Child cases, emails and attachments. I think, I am getting error  because of  attachment method @ public void setupAttachments(Case c, list<caseHistoryItem>tList),  Please find controller  and Visualforce Page below.

 

Anybody have any idea let me know.

Thanks in advance.

 

Controller:

 

public with sharing class CaseHistoryController {
private static String CLASSNAME = '\n\n**** CaseHistoryController.@@METHODNAME()';
public list<CaseHistoryItem> CHIlist {get; set;}
public Case aCase {get; set;}
public String caseID {get; set;}
public list<Task> tasks {get; set;}
public boolean showAll {get; set;}
public Set<String> prefixSet {get; set;}
public boolean isReachout {get; set;}
public Boolean showPrivate {get; set;}
public Boolean showEmail {get; set;}
public Boolean showComment {get; set;}
public Boolean showAttach {get; set;}
public Boolean showpAttach {get; set;}
public Boolean showHist {get; set;}
public Boolean showRCase {get; set;}
public map <integer,List<caseHistoryItem>> listIndex {get; set;}
public integer listIndexInt {get; set;}

public string filterString { get; set; }

public string sortField { get; set; }
public string previousSortField { get; set; }
public string order { get; set; }
public string rCaseSortMethod { get; set; }

public string emailSubject { get; set; }
public string emailBody { get; set; }
public string additionalTo { get; set; }
public boolean bccOwner { get; set; }
public boolean sendToCaseContact { get; set; }

public CaseHistoryController()
{
caseId = Apexpages.currentPage().getParameters().get('id');

showPrivate = true;

showEmail = true;

showComment = true;

showAttach = true;

showHist = true;

showRCase = true;

showpAttach = true;

rCaseSortMethod = 'separate';

order = 'asc';

sortField = 'CreateDate';

previousSortField = 'CreateDate';

sendToCaseContact = false;
bccOwner = false;

refreshHistory();

emailSubject = 'Case ' + aCase.CaseNumber + ' Timeline Report';
emailBody = 'Your Case Timeline Report is attached.';
}

public Case queryCase(id cId)
{
String METHODNAME = CLASSNAME.replace('@@METHODNAME','queryCase');
String emailWhere = 'where Subject like \'Email%\'';
String commentWhere = 'where id != null';
String histWhere = 'where id != null';
String rCaseWhere = 'where id != null';
String attachWhere = 'where id != null';

if (showPrivate == False) {
commentWhere += ' and isPublished = True';
emailWhere += ' and isVisibleinSelfService = True';
rCaseWhere += ' and isVisibleinSelfService = True';
// phani Emmanni on 04/15/2012
//attachWhere += ' and ispublic = true';
}

//building select all for case using describe info
Schema.DescribeSObjectResult d = Schema.Sobjecttype.Case;

map<string, Schema.SobjectField> fieldMap = d.fields.getMap();

list<Schema.SObjectField> tempFields = fieldMap.values();

string caseAllFields = '';

for(Schema.Sobjectfield sof:tempFields)
{
caseAllFields += (','+sof.getDescribe().getName());
}

String caseQuery = 'select RecordType.Name, Account.Name, Contact.Name, Contact.Email, Contact.Phone, Owner.Email ,CreatedBy.Name, Owner.Name, Contact.Contact_Full_Name__c' + caseAllFields;
String emailQuery = ',(Select Id, CreatedById, CreatedBy.Name, WhatId, What.Name, Subject, ActivityDate, Status, OwnerId, Description, CreatedDate, Owner.Name, isVisibleInSelfService From Tasks '+emailWhere+')';
String commentQuery = ',(Select Id, CreatedDate, CreatedBy.Name, CreatedById, CommentBody, isPublished From CaseComments '+commentWhere+')';
String histQuery = ',(Select Id, CreatedById, CreatedBy.Name, CreatedDate, Field, OldValue, NewValue From Histories '+histWhere+')';
String rCaseQuery = ',(select Id from ReachOutCases__r '+rCaseWhere+')';
String attachQuery = ',(select Id, CreatedById, CreatedBy.Name, CreatedDate, Name, Owner.Name, isprivate from Attachments '+attachWhere+')';

if (showPrivate) {
if (showEmail) {
caseQuery += emailQuery;
}
if (showComment) {
caseQuery += commentQuery;
}
if (showRCase) {
caseQuery += rCaseQuery;
}
if (showHist) {
caseQuery += histQuery;
}
if (showAttach) {
caseQuery += attachQuery;
}

} else {
if (showEmail) {
caseQuery += emailQuery;
}
if (showComment) {
caseQuery += commentQuery;
}
if (showRCase) {
caseQuery += rCaseQuery;
}
}

caseQuery += ' from Case where ID = \''+cID+'\'';
//System.debug('------------------------->'+caseQuery);
system.debug(LoggingLevel.INFO, METHODNAME + ' :: caseQuery = ' + caseQuery +'\n\n');
case c = database.query(caseQuery);
return c;
}

public void refreshHistory() {
CHIlist= new List<CaseHistoryItem>();
listIndex = new Map<integer,List<CaseHistoryItem>>();

listIndex.put(0,CHIlist);

aCase = queryCase(caseId);

isReachout = (aCase.RecordType.Name.Contains('Reachout')||aCase.RecordType.Name.Contains('Reach Out'));

if (showPrivate)
{
if (showEmail)
{
setupEmails(aCase, CHIList);
}
if (showComment)
{
setupCaseComments(aCase, CHIList);
}
if (showRCase)
{
setupReachOutCases(aCase, CHIList);
}
if (showHist)
{
setupHistories(aCase, CHIList);
}
if (showAttach) {
setupAttachments(aCase, CHIList);
}
}
else
{
if (showEmail)
{
setupEmails(aCase, CHIList);
}
if (showComment)
{
setupCaseComments(aCase, CHIList);
}
if (showRCase)
{
setupReachOutCases(aCase, CHIList);
}
//Phani Emmanni on 04/14/
if (showAttach) {
setupAttachments(aCase, CHIList);
}

}
filterByKeyword();
caseHistoryUtil.sortList(CHIlist,sortField,order);
}

public pageReference previewPDF()
{
PageReference pdf = Page.caseHistoryPDF;

return pdf;
}

public pageReference sendEmail()
{
if(sendToCaseContact && showPrivate)
{
apexPages.addMessage(new apexPages.Message(apexPages.severity.ERROR,'There was an error with your request. Please try to send your email again.'));
showPrivate = false;
refreshHistory();
return null;
}


Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();

PageReference pdf = page.caseHistoryPDF;

Blob b = pdf.getContent();

Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName('CaseHistory.pdf');
efa.setBody(b);

list<string> toAddresses = new list<string>();
if(sendToCaseContact && acase.Contact.Email != Null && acase.IsVisibleInSelfService)toAddresses.add(acase.Contact.Email);

list<string> additionalToList = new list<string>();

if(additionalTo != Null)
{
additionalToList = additionalTo.split(';', 0);

for(string s:additionalToList)
{
if(s.trim()!='')toAddresses.add(s);
}

}

list<string> bccAddresses = new list<string>();
if(bccOwner && aCase.Owner.Email != null)
bccAddresses.add(aCase.Owner.Email);

email.setSubject(emailSubject);
email.setToAddresses(toAddresses);
email.setBccAddresses(bccAddresses);
email.setPlainTextBody(emailBody);
email.setFileAttachments(new Messaging.Emailfileattachment[]{efa});
try
{
Messaging.Sendemailresult[] r= Messaging.SendEmail(new messaging.Singleemailmessage[]{email});
}
catch(exception e)
{
apexpages.addmessages(e);
return null;
}

apexPages.addMessage(new apexPages.Message(apexPages.severity.CONFIRM,'Your message has been sent.'));

string toString = 'to: ';
for(string s:toAddresses)
toString += (s + '; ');
toString += '\n';

string bccString = 'bcc: ';
for(string s:bccAddresses)
bccString += (s + '; ');
bccString += '\n\n';

Task newTask = new Task(
Description = toString + bccString + email.plainTextBody,
Priority = 'Normal',
Status = 'Completed',
Subject = 'Email: ' + email.Subject,
ActivityDate = System.Today(),
Whatid = acase.id
);

if(sendToCaseContact)newTask.whoId = aCase.ContactId;

insert newTask;

attachment a = new attachment(
body=b
,name = 'CaseHistory.pdf'
,parentId = newTask.Id
);

insert a;

pageReference pageRef = page.caseHistory;

pageRef.getParameters().put('id',caseId);

return pageRef;
}

public void filterByKeyword()
{
if(filterString != Null && filterString.length()>1)
{
string filter = filterString.tolowercase();

list<caseHistoryItem> temp = new list<caseHistoryItem>();

for(casehistoryitem i: CHIList)
{
boolean keep = false;

if(i.subject != Null)
{
string subject = i.subject.tolowercase();

if(subject.contains(filter))keep = true;
}

if(i.taskDescription != Null)
{
string description = i.taskDescription.tolowercase();

if(description.contains(filter))keep = true;
}

if(i.itemTypeName == 'Reachout Case' && rCaseSortMethod == 'separate')
{
list<caseHistoryItem> rTemp = new list<caseHistoryItem>();

for(casehistoryitem ri: i.rCaseCHIList)
{
boolean rKeep = false;

if(ri.subject != Null)
{
string rSubject = ri.subject.tolowercase();

if(rSubject.contains(filter))rKeep = true;
}

if(ri.taskDescription != Null)
{
string rDescription = ri.taskDescription.tolowercase();

if(rDescription.contains(filter))rKeep = true;
}

if(rKeep)
{
rTemp.add(ri);
keep = true;
}
}
i.rCaseCHIList = rTemp;
}

if(keep)temp.add(i);
}

CHIList = temp;
}

}

public void doSort() {
order = 'desc';

/*This checks to see if the same header was click two times in a row, if so
it switches the order.*/
if(previousSortField == sortField){
order = 'asc';
previousSortField = null;
} else {
previousSortField = sortField;
}

caseHistoryUtil.sortList(listIndex.get(listIndexInt),sortField,order);
}

public void setupHistories(Case c, list<caseHistoryItem>tList){
list<CaseHistory> cHistories = c.Histories;
String subject;
String oldVal;
String newVal;

setupPrefix();

for (CaseHistory ch:cHistories){
oldVal=String.valueOf(ch.oldValue);
newVal=String.valueOf(ch.newValue);

if(isId(oldVal)||isId(newVal))
subject=null;
else if(ch.OldValue==null&&ch.NewValue==null)
subject = ch.Field+'--Modified, or Created';
else if(ch.OldValue==null)
subject = ch.Field+' changed or set to '+newVal;
else if(ch.newValue==null)
subject = ch.Field+' changed or set to '+oldVal;
else{
subject = ch.Field+' changed from '+oldVal+' to '+newVal;
}


if(subject!=null)
tList.add(new CaseHistoryItem(c.CaseNumber, c.Id, ch.CreatedDate, subject, ch.CreatedBy.Name, ch.CreatedById, null, 'History', null, null, null, null,false,null,null,null));
}
}

public void setupEmails(Case c, list<caseHistoryItem>tList){
tasks = c.Tasks;
for (task t: tasks){
tList.add(new CaseHistoryItem(c.CaseNumber, c.Id, t.CreatedDate, t.Subject, t.CreatedBy.Name, t.CreatedById, t.Id, 'Email', t.ActivityDate, t.Owner.Name, '-- '+t.Description, t.OwnerId, t.isVisibleInSelfService,null,t,null));
}
}

private void setupPrefix(){
prefixSet=new Set<String>();
map<String, Schema.SObjectType> gD = Schema.getGlobalDescribe();
Set<String>keys=gD.keySet();
for(String key:keys){
Schema.DescribeSObjectResult r = gD.get(key).getDescribe();
if(r!=null &&r.getKeyPrefix()!=null && r.getKeyPrefix()!='')
prefixSet.add(r.getKeyPrefix());
}
}

public boolean isId(String at){
if(at==null)
return false;
else if(at.length()<5)
return false;
else{
String testVal = at.substring(0,3);
for(String prefix : prefixSet){
if(prefix.equals(testVal))
return true;
}
}
return false;
}

public void setupCaseComments(Case c, list<caseHistoryItem>tList)
{
String METHODNAME = CLASSNAME.replace('@@METHODNAME','setupCaseComments');

list <CaseComment> cComments = new list<CaseComment>();
List<CaseComment> cclist = new List<CaseComment>([Select Id,parentId,isPublished,CreatedDate,CommentBody,CreatedById,CreatedBy.Name from CaseComment c where parentId = :c.Id]);
for(CaseComment cc : cclist){
cComments.add(cc);
}

//for(CaseComment cc : c.CaseComments)cComments.add(cc);

for(CaseComment cc: cComments){

//System.debug('--------------------------->' + cc.isPublished);
System.debug(LoggingLevel.INFO, METHODNAME + ' :: cc.isPublished = ' + cc.isPublished +'\n\n');

tList.add(new CaseHistoryItem(c.CaseNumber, c.Id, cc.CreatedDate, cc.CommentBody, cc.CreatedBy.Name, cc.CreatedById, null,'Comment', null, null, null, null,cc.IsPublished,cc,null,null));
}
}

public void setupReachOutCases(Case c, list<caseHistoryItem>tList){
Case[] cases = c.ReachOutCases__r;
for (Case r: cases){
list<CaseHistoryItem> CHItems = new list<CaseHistoryItem>();
if(rCaseSortMethod == 'integrate')CHItems = CHIlist;
integer indexSize = listIndex.keyset().size();
listIndex.put(indexSize,CHItems);
case rCase = queryCase(r.id);
CaseHistoryItem CHItem = new CaseHistoryItem(c.CaseNumber, c.Id, rCase.CreatedDate, rCase.Subject, rCase.CreatedBy.Name, rCase.CreatedById, rCase.Id, 'Reachout Case', null, rCase.Owner.Name, '-- '+rCase.Description, rCase.OwnerId, rCase.isVisibleinSelfService,null,null,rCase);

if (showPrivate)
{
if (showEmail)
{
setupEmails(rCase, CHItems);
}
if (showComment)
{
setupCaseComments(rCase, CHItems);
}
if (showHist)
{
setupHistories(rCase, CHItems);
}
if (showAttach)
{
setupAttachments(rCase, CHItems);
}
}
else
{
if (showEmail)
{
setupEmails(rCase, CHItems);
}
if (showComment)
{
setupCaseComments(rCase, CHItems);
}
}


if(rCaseSortMethod == 'separate')
{
caseHistoryUtil.sortList(CHItems,sortField,order);
CHItem.listIndex = indexSize;
CHItem.rCaseCHIList = CHItems;
}

system.debug('CHITEMS----------------------->>>' + CHItems);

tList.add(CHItem);
}
}


public void setupAttachments(Case c, list<caseHistoryItem>tList){
String METHODNAME = CLASSNAME.replace('@@METHODNAME','setupCaseComments');

list <Attachment> attmnts = new list<Attachment>();
list <Attachment> atts = new list<Attachment>([Select Id, parentId, OwnerId, Name, CreatedDate, CreatedById, CreatedBy.Name, Owner.Name from Attachment c where parentId = :c.Id]);

for(Attachment aa : atts){
attmnts.add(aa);
}
for (Attachment a: attmnts){
System.debug(LoggingLevel.INFO, METHODNAME + ' :: a.Name = ' + a.Name +'\n\n');
tList.add(new CaseHistoryItem(c.CaseNumber, c.Id, a.CreatedDate, a.Name, a.CreatedBy.Name, a.CreatedById, a.Id, 'Attachment', null, a.Owner.Name, '-- ', a.OwnerId,false,null,null,null));
}
}

I'm trying to tab out our account layout.  I'm unable to create a tab for some related lists that are standard objects (Partners, Content Deliveries, Activity History, etc)  The custom objects were no problem, but for these and a few other standard objects I receive the "not a valid child relationship error"

 

here is the code I'm using - taken from the infamous tabbed accounts in 30 seconds wiki

 

<apex:tabPanel switchType="client" selectedTab=" tabdetails" id="AccountTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">   
      <apex:tab label="Contacts" name="Contacts" id="tabContact">
         <apex:relatedList subject="{!account}" list="contacts" />
      </apex:tab>
      <apex:tab label="Opportunities" name="Opportunities" id="tabOpp">
         <apex:relatedList subject="{!account}" list="opportunities" />
      </apex:tab>
      <apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct">
         <apex:relatedList subject="{!account}" list="OpenActivities" />
      </apex:tab>
      <apex:tab label="Notes and Attachments" name="NotesAndAttachments" id="tabNoteAtt">
         <apex:relatedList subject="{!account}" list="NotesAndAttachments" />
      </apex:tab>
       <apex:tab label="Activity History" name="Activity History" id="tabActivityHistory">
         <apex:relatedList subject="{!account}" list="ActivityHistory" />
      </apex:tab>

 

 

I've searched through the boards here and was unable to locate an answer for standard objects only custom.

 

Any help would be appreciated.

 

Thanks,