• Dan Dodd 3
  • NEWBIE
  • 55 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 14
    Questions
  • 28
    Replies
I want to send emails to all contacts on the cases in a related list.
We are adding a follow up object that contains the topic for future follow up. For example when we start up the tours again. People want to be notified when we start planning the next tour but it is not on the schedule yet.
We want to email them as a group with the information.
I can add a button to the related cases of a Follow up using the answer here: https://developer.salesforce.com/forums/?id=906F00000008z0FIAQ but still need to know how to make that email the cases contact.
 
We are switching to the Household account Model
I need to blank out the accounts for all my contacts ( 155k) after which Salesforce will create a new "Household" Account.

What is the best way to do this?
I found this How To Show HTML Email Right On Your Case Page (http://success.salesforce.com/ideaView?id=087300000007TOe) that really works great for what we want but cannot understand how to test it.
 
public with sharing class CaseHTMLEmailController {
    private final Case caseObj;

    public String firstHTMLEmail { get
        {return getFirstHTMLEmail(); }
    }
    
    public CaseHTMLEmailController(ApexPages.StandardController stdController) {
        this.caseObj = (Case)stdController.getRecord();
    }

    public String getFirstHTMLEmail() {
        EmailMessage firstEmail = [Select HtmlBody From EmailMessage where ParentId=:caseObj.Id order by LastModifiedDate asc limit 1];
        if (firstEmail!=null) {
            return firstEmail.HtmlBody;
        }
        
        return '';
    }
}

I need the email-to-case context where the case was generated by an email and test  it pulling the data from emailMessage for this visualforce page.
Our org in new to case managment and we are using email-to-case
We receive emails from a third party system that has a formatted body.
We would like to view the formatted body instead of the cse description that is plain text
I added a RichText field to save the body into and have tried a trigger, workflow and process builder.

Here is the section of the trigger ( before insert )
// bulkify by only doing this if Trigger.New.Size == 1
if ( true ) {
// Insert Email Body into custom field
EmailMessage emailMsg = [SELECT id, ParentId, FromName, FromAddress, HtmlBody, TextBody
FROM EmailMessage
WHERE Id = :cs.SourceId
AND Incoming = true
Limit 1];
if ( emailMsg != null && emailMsg.HtmlBody != null) {
cs.lutd_Description_Rich__c = 'Not Null htmlBody';
//cs.lutd_Description_Rich__c = emailMsg.HtmlBody;
} else if ( emailMsg != null && emailMsg.TextBody != null){
cs.lutd_Description_Rich__c = 'Checking textBody'; //emailMsg.textBody;
} else {
cs.lutd_Description_Rich__c = 'Null email message';
}
//cs.lutd_Description_Rich__c = cs.description ; works as expected
}
I dont get the htmlBody.
In the developer console I see the htmlBody using the same SOQL subtitutng the SourceId of the case. 


 
Using process builder to update a custom field on a new CASE record does not pull in the EmialMessage.htmlBody as expected.
I tried this with workflow as well.

Both allow me to make an action pulling from that field but do not update the record.

What do I need to do to get the htmlBody of a cases email (Email-to-case) so I can write it in a custom field
How do I referance a case EmailMessage textHTML field from a trigger before insert?

I tried this with a work flow and process builder it. Both allowed me to access the fields in the builder but does not add the data when it ran because the fields are empty.. 
The data displays in a SQOL query in the developer console but not sure how to grab it from the case.
In before insert trigger:
for(case cs: Trigger.new){ 
  // this works as expected as a test 
  // that I can do something in this trigger 
  cs.lutd_Description_Rich__c = cs.description

// Need something like:
  cs.lutd_Description_Rich__c = case.source.emailMessage.htmlBody 


// & etc.. 
}

 
We receive emails from a third party system that sends emails under its own name with the body contining the actual email address of the case opener.

When we receive this email-to-case, the before update trigger is successfully capturing the email body and parsing off the email address.

But when the case is replieed to via email the "To" address is the third party systems address.

I updated the SuppliedEmail field but that doesn't fix it

Where does the "From Address"  get set in email to case so that it can be used to reply to the case opner??

The
I have a custom object for trip registrations. 
I need to pair up the records to make roommates.
So a husband and wife sign up for the trip and e get two registrations records.  Sallie and Sam

Now I want to pair them up as room mates.

I could make a text fields roommate and enter Sam for Sallie's romie  and Sallie for Sam's roomie.

The problem with that method is that it could lead to typos .
Can I make a field that would lookup names in the registration finding only those not yet paired.
I have 50 registrations so the first lookup would have 49  names, everyone else but the first name selected to pair.
Once paired and on to the next, there would be 47 to pick from and so on going down by 2 every time a pairing was made.

How can I make this pairing and use the names in reports?

I wuld like to do this in LWC or even in the standard details of the customer object.
I have email-to-case working great until I add a trigger to the process and then email-to-case stops working.
I have commnted out most everything and it still fails to run. here is what I need to run:
 
trigger CaseInsertTrigger on Case(before insert, after insert){
if (Trigger.isBefore && Trigger.isInsert) {
 Set<String> conEmailSet = new Set<String> ();

 String userEmail;
 for(case cs: Trigger.new){
  if(cs.contactid == null) {
   if (cs.description !=null && cs.subject.mid(0, 12) == 'Issue Report') {
    userEmail = cs.description.substringBetween('Email: ',' EndEmail');
    if ( userEmail != null) {
      conEmailSet.add(userEmail);
      system.debug(userEmail);
    }
   }
  }
 }

Map<String, Contact> cEmailMap = new Map<String, Contact>();
for(Contact eMap : [select Email, Id from contact where Email IN :conEmailSet]) {
 cEmailMap.put(eMap.Email,eMap );
}
Contact tmpContact;
for(case cs: Trigger.new){
  if(cs.description !=null && cs.subject.contains('Issue Report') ) {
    userEmail = cs.description.substringBetween('Email: ',' EndEmail').trim();
    system.debug('Queue for Case:--->' + cs.OwnerId);
    system.debug('Email for case: ' + userEmail);
    if ( userEmail != null) {
      tmpContact = cEmailMap.get(userEmail);
      if ( tmpContact != null ) {
        cs.ContactId = tmpContact.Id;
        system.debug('Contact for Case:--->' + tmpContact.Id);
      } else {
        //here ToDo crreate a contact
    }
    cs.SuppliedEmail = userEmail;
    // ToDo OwnerId ie Queue app queue , why does ?
    // ToDo cs.SuppliedName
  } else {
    system.debug('Contact for Case:--->None ');
  }
 }
}
}

}

 
Hi,
I am using a third party software that collects my Issue reports from the original party (OP) and emails them to Salesforce Email-to-Case. 
It uses the OPs email address as the "FROM" address and Salesforce uses that email to connect it to the Contact. I get good matching when the Contact exists.

The problem comes in is that we should use our email NOT the OP's email as the "From" when sending email.
 
Now when we send the email we need to replace the "From" of Email-to-Case in the Case so it gets attached to the correct Contact.

I can put the "from" email anywhere in the body and was thinking of putting it at the start of the body:
'Email: ' + email + ' EndEmail'
  so I could use the string operator:
fromEmail = str1.substringBetween('Email: ' , ' EndEmail');
and put it in the Case from field in a before insert trigger.
Will this work with the the Email-To Case flow?

 
I am uploading case history to out new salesforce Helpdesk. 
We are receiving new cases via the Email-to-case method.

When a case is created by email-to-case an attachment is saved as a file connected to the case.

I am able to upload the case history via the API but I dont see how to pass a filename and get the file unloaded and attached.  
 
Importing from this CSV file:
"OWNERID","STATUS","ORIGIN","SUBJECT","PRIORITY","DESCRIPTION"
"3D00G1U000002xbcg","New","EMAIL","New order.","HIGH","Seven TwentyOne Main"

Gives me this success message showing new ID :
"ID","OWNERID","STATUS","ORIGIN","SUBJECT","PRIORITY","DESCRIPTION","STATUS"
"5002900000BrQN4AAN","3D00G1U000002xbcg","Item Created","EMAIL","New subscription renewal order.","HIGH","Seven TwentyOne Main","Item Created"
A Case is created but the detail is missing, Origin is blank, owner is me, not the OwnerId, subject blank, descriptrion blank, Just ... Nothing but the defaults for Status and Priority

I disabled the trigger.
I am getting this error when I import the csv below. 
Where do I find Trigger.caseTrigger?
And/Or what are are the minimum fields to insert a record
 
caseTrigger: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.caseTrigger: line 11, column 1

Imported CSV:
"OWNERID","CREATEDDATE","DESCRIPTION","ORIGIN","PRIORITY","STATUS","SUBJECT"
"00G1U000002xbviUAA","2019-07-21","Seven Twenty","EMAIL","Medium","New","New subscription renewal order."

​​​​​​​





 
I'm wondering what queue method I should use.
I want to use a trigger to enqueue an external httpRequest:
When a contact is created,  if it has a value in a custom field , add to the queue. 
The process servicing the queue will post that custom field to an external server and get the additional data associated with that customer field value. Then it will update the contact.
I am open to other ways to accomplish this.
sfdx force:source:push -f
PROJECT PATH                                                     ERROR
─────────────────────────────────────────
force-app/main/default/settings/OrgPreference.settings-meta.xml  An unexpected error occurred. Please include this ErrorId if you contact support: 1137805646-28686 (412474181)
ERROR running force:source:push:  Push failed.

This i the complete error message.

I am pushing into a new scratch org with source that was working yesterday's expired scratch org.

 
I want to send emails to all contacts on the cases in a related list.
We are adding a follow up object that contains the topic for future follow up. For example when we start up the tours again. People want to be notified when we start planning the next tour but it is not on the schedule yet.
We want to email them as a group with the information.
I can add a button to the related cases of a Follow up using the answer here: https://developer.salesforce.com/forums/?id=906F00000008z0FIAQ but still need to know how to make that email the cases contact.
 
We are switching to the Household account Model
I need to blank out the accounts for all my contacts ( 155k) after which Salesforce will create a new "Household" Account.

What is the best way to do this?
I found this How To Show HTML Email Right On Your Case Page (http://success.salesforce.com/ideaView?id=087300000007TOe) that really works great for what we want but cannot understand how to test it.
 
public with sharing class CaseHTMLEmailController {
    private final Case caseObj;

    public String firstHTMLEmail { get
        {return getFirstHTMLEmail(); }
    }
    
    public CaseHTMLEmailController(ApexPages.StandardController stdController) {
        this.caseObj = (Case)stdController.getRecord();
    }

    public String getFirstHTMLEmail() {
        EmailMessage firstEmail = [Select HtmlBody From EmailMessage where ParentId=:caseObj.Id order by LastModifiedDate asc limit 1];
        if (firstEmail!=null) {
            return firstEmail.HtmlBody;
        }
        
        return '';
    }
}

I need the email-to-case context where the case was generated by an email and test  it pulling the data from emailMessage for this visualforce page.
Our org in new to case managment and we are using email-to-case
We receive emails from a third party system that has a formatted body.
We would like to view the formatted body instead of the cse description that is plain text
I added a RichText field to save the body into and have tried a trigger, workflow and process builder.

Here is the section of the trigger ( before insert )
// bulkify by only doing this if Trigger.New.Size == 1
if ( true ) {
// Insert Email Body into custom field
EmailMessage emailMsg = [SELECT id, ParentId, FromName, FromAddress, HtmlBody, TextBody
FROM EmailMessage
WHERE Id = :cs.SourceId
AND Incoming = true
Limit 1];
if ( emailMsg != null && emailMsg.HtmlBody != null) {
cs.lutd_Description_Rich__c = 'Not Null htmlBody';
//cs.lutd_Description_Rich__c = emailMsg.HtmlBody;
} else if ( emailMsg != null && emailMsg.TextBody != null){
cs.lutd_Description_Rich__c = 'Checking textBody'; //emailMsg.textBody;
} else {
cs.lutd_Description_Rich__c = 'Null email message';
}
//cs.lutd_Description_Rich__c = cs.description ; works as expected
}
I dont get the htmlBody.
In the developer console I see the htmlBody using the same SOQL subtitutng the SourceId of the case. 


 
SOQL Query:
SELECT ClaimNumber__c, Program__c, ProgramDesc__C , ClaimStartDate__c, ClaimEndDate__c
FROM ClaimHeader__x WHERE (ClaimNumber__c = '13128E' AND  ProgramDesc__c = 'STAR') OR (ClaimNumber__c = '13128E' AND ProgramDesc__c = 'CHIP')  ORDER BY ClaimStartDate__c DESC LIMIT 11 OFFSET 0
                
We are expecting only one record for this query with claim number '13128E', but it is returning more records.
 
We receive emails from a third party system that sends emails under its own name with the body contining the actual email address of the case opener.

When we receive this email-to-case, the before update trigger is successfully capturing the email body and parsing off the email address.

But when the case is replieed to via email the "To" address is the third party systems address.

I updated the SuppliedEmail field but that doesn't fix it

Where does the "From Address"  get set in email to case so that it can be used to reply to the case opner??

The
I have a custom object for trip registrations. 
I need to pair up the records to make roommates.
So a husband and wife sign up for the trip and e get two registrations records.  Sallie and Sam

Now I want to pair them up as room mates.

I could make a text fields roommate and enter Sam for Sallie's romie  and Sallie for Sam's roomie.

The problem with that method is that it could lead to typos .
Can I make a field that would lookup names in the registration finding only those not yet paired.
I have 50 registrations so the first lookup would have 49  names, everyone else but the first name selected to pair.
Once paired and on to the next, there would be 47 to pick from and so on going down by 2 every time a pairing was made.

How can I make this pairing and use the names in reports?

I wuld like to do this in LWC or even in the standard details of the customer object.
I have email-to-case working great until I add a trigger to the process and then email-to-case stops working.
I have commnted out most everything and it still fails to run. here is what I need to run:
 
trigger CaseInsertTrigger on Case(before insert, after insert){
if (Trigger.isBefore && Trigger.isInsert) {
 Set<String> conEmailSet = new Set<String> ();

 String userEmail;
 for(case cs: Trigger.new){
  if(cs.contactid == null) {
   if (cs.description !=null && cs.subject.mid(0, 12) == 'Issue Report') {
    userEmail = cs.description.substringBetween('Email: ',' EndEmail');
    if ( userEmail != null) {
      conEmailSet.add(userEmail);
      system.debug(userEmail);
    }
   }
  }
 }

Map<String, Contact> cEmailMap = new Map<String, Contact>();
for(Contact eMap : [select Email, Id from contact where Email IN :conEmailSet]) {
 cEmailMap.put(eMap.Email,eMap );
}
Contact tmpContact;
for(case cs: Trigger.new){
  if(cs.description !=null && cs.subject.contains('Issue Report') ) {
    userEmail = cs.description.substringBetween('Email: ',' EndEmail').trim();
    system.debug('Queue for Case:--->' + cs.OwnerId);
    system.debug('Email for case: ' + userEmail);
    if ( userEmail != null) {
      tmpContact = cEmailMap.get(userEmail);
      if ( tmpContact != null ) {
        cs.ContactId = tmpContact.Id;
        system.debug('Contact for Case:--->' + tmpContact.Id);
      } else {
        //here ToDo crreate a contact
    }
    cs.SuppliedEmail = userEmail;
    // ToDo OwnerId ie Queue app queue , why does ?
    // ToDo cs.SuppliedName
  } else {
    system.debug('Contact for Case:--->None ');
  }
 }
}
}

}

 
Hi,
I am using a third party software that collects my Issue reports from the original party (OP) and emails them to Salesforce Email-to-Case. 
It uses the OPs email address as the "FROM" address and Salesforce uses that email to connect it to the Contact. I get good matching when the Contact exists.

The problem comes in is that we should use our email NOT the OP's email as the "From" when sending email.
 
Now when we send the email we need to replace the "From" of Email-to-Case in the Case so it gets attached to the correct Contact.

I can put the "from" email anywhere in the body and was thinking of putting it at the start of the body:
'Email: ' + email + ' EndEmail'
  so I could use the string operator:
fromEmail = str1.substringBetween('Email: ' , ' EndEmail');
and put it in the Case from field in a before insert trigger.
Will this work with the the Email-To Case flow?

 
I am uploading case history to out new salesforce Helpdesk. 
We are receiving new cases via the Email-to-case method.

When a case is created by email-to-case an attachment is saved as a file connected to the case.

I am able to upload the case history via the API but I dont see how to pass a filename and get the file unloaded and attached.  
 
Importing from this CSV file:
"OWNERID","STATUS","ORIGIN","SUBJECT","PRIORITY","DESCRIPTION"
"3D00G1U000002xbcg","New","EMAIL","New order.","HIGH","Seven TwentyOne Main"

Gives me this success message showing new ID :
"ID","OWNERID","STATUS","ORIGIN","SUBJECT","PRIORITY","DESCRIPTION","STATUS"
"5002900000BrQN4AAN","3D00G1U000002xbcg","Item Created","EMAIL","New subscription renewal order.","HIGH","Seven TwentyOne Main","Item Created"
A Case is created but the detail is missing, Origin is blank, owner is me, not the OwnerId, subject blank, descriptrion blank, Just ... Nothing but the defaults for Status and Priority

I disabled the trigger.
Hi FSL Experts
I have started a new project on FSL and facing one issue. We have one requirement where we need to optimise the route for the delivery guys so that they can see the optimised route for their journey from starting to end. 
- If there are 5 service appointments with 5 different addresses and once resource open the FSL app they can see all the SA's.(This is working)
- Then there should be a provision to accumulate these addresses and give the best optimised route to the delivery guy so that he starts his journey in a sequence rather than going from a same road again and again. The person should see optimised map of all the addresses and starts his journey according to the results given by optimised routing.

I hope the question is clear to you all and looking forward for the resolution from the experts.

Thanks