Email Message Model not returning any rows

  • 4
  • Question
  • Updated 9 months ago
  • Answered
I am creating a very simple model of type "Email Message" and then displaying all rows in a table.

For some reason the table returns "No email message to display", however I can query the same object in Developer Console and it returns 5 rows.

There are not filter conditions on the model.
Photo of Devendra Dhaka

Devendra Dhaka

  • 110 Points 100 badge 2x thumb
  • frustrated

Posted 2 years ago

  • 4
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Here is where you want to dig into the developer tools in the browser and explore the model's javascript objects in the console. (Not the Salesforce Developer Console)

Open the console and type:
skuid.$M('YourModelName')  

This will return the full javascript object related to the model.   I look at the following nodes of that object.

data:   Here you will see whether you are actually getting data on your page.  If data is there,  there is a problem with the table component you put on the page.

accessible:   Here you will see whether skuid can actually query the model.

soql:   Here you will see the actual query passed to the database by skuid.  Does this match exactly what you put in the sf dev console?

Etc....   Happy debugging    
Photo of Devendra Dhaka

Devendra Dhaka

  • 110 Points 100 badge 2x thumb
Thanks Rob for your response.

I followed your steps and looked at the javascript generated for the model. As per the js object's properties :

isQueryable = True

accessible = true

query  = SELECT ActivityId,Subject,Id FROM EmailMessage LIMIT 21 (returning proper results in the console)

however data array is empty.

I also compared the javascript object with another contact model and everything looked exactly same.
(Edited)
Photo of Gary

Gary

  • 1,518 Points 1k badge 2x thumb
I did some investigation into this - it seems that if an Email Message does not have a parent case, Skuid does not receive it in the model. However, running the query from the Skuid model in the Salesforce Developer Console returns records as expected.

@Rob - any ideas as to why this would be? Seems like something on the platform level, but no idea what...
Photo of giovanni pravadelli

giovanni pravadelli

  • 272 Points 250 badge 2x thumb
We too are experiencing the same issue... 
Photo of Gary

Gary

  • 1,518 Points 1k badge 2x thumb
Giovanni - try activating Enhanced Email under settings. The reason we had this issue was that in one of our sandboxes that received Summer 16 but another (where it wasn't working) hadn't. Once Summer 16 was released and we activated Enhanced Email, it worked as we expected.

Hope that helps!
Photo of giovanni pravadelli

giovanni pravadelli

  • 272 Points 250 badge 2x thumb
Hi Gary, thanks for the suggestion: we checked and we already have the Enhanced Email activated. So the problem should be somwhere else..

What we are trying to achieve is to put in a table in the Lead View all the emails that were sent to each lead, so that our salespeople can see immediately what they already sent.
Right now we managed to connect to the Task model the description field, but that is quite ugly to see, as there is everything in one field.
We would like to put in the different fields for the EmailMessage model (like subject, body of the mail and so on).
We tried with this condition: activityId is in the set of values of the id field of the task model. 
We also tried putting in directly the id of a specific message, but the answer was always "No email message to display"

So right now we are trying to understand if it's we that are missing something, of it's a problem with Skuid..
Photo of Gary

Gary

  • 1,518 Points 1k badge 2x thumb
I can't check right now, but try having your model connect to Email or EmailMessage. If I get time, I'll see if I can check what we did and reply, but may not be right away I'm afraid! Good luck!
Photo of Joseph Ortiz

Joseph Ortiz

  • 594 Points 500 badge 2x thumb
My org is still running into the same issue. We are able to see the email on the task but want to pull it back through the EmailMessage. We have email templates with html and would like to display this for our users.

We have checked the following
1. We have enhanced email on
2. The model says it is accessible = true and  isQueryable = true



Is there a workaround for this? If not, will this be fixed in a skuid patch coming up?
Photo of Tim Shores

Tim Shores

  • 542 Points 500 badge 2x thumb
Bump. I just ran into the same problem. Is there a workaround or an expected fix for this?

Enhanced Email is enabled for my org. The model should be working but gets no data. Console output: 

Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Tim,

I see ActivityId as a field on EmailMessage, but I don't have any records linked by this field.

I only see records linked to RelatedToId field.  Is this what you are asking?

Thanks,

Bill
Photo of Tim Shores

Tim Shores

  • 542 Points 500 badge 2x thumb
Hmm, I guess that must be! What object are those records in the RelatedToId field?
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Tim,

I see Opportunities and a custom object in the RelatedToId field.

Thanks,

Bill
Photo of Tim Shores

Tim Shores

  • 542 Points 500 badge 2x thumb
Outstanding, now I understand. Thank you so much, Bill. We've arrived at different solutions -- one can use RelatedToId to get EmailMessage records, and/or one can use ActivityID. But the information you provided helped me understand the EmailMessage object better, and got me on the right path.

What I'm working on is a Page Include with a table of Activities (aka Task model). I created a drawer to show the email body when the Activity is an email. I had an EmailMessage model with an ActivityID condition that was referring to my Task model ... however I was not thinking correctly about this. I was relying on an EmailMessage model condition that looked to the Task model, but it just happened that the first Task model record had no EmailMessage record. Instead of a model condition, I needed a Row Context condition in the Field Editor.

I also had to learn about the urlDecode Global Merge:
https://docs.skuid.com/latest/en/skuid/merge-syntax/global-merge-variables.html
My EmailMessage template field now has this content: {{#urlDecode}}{{{HtmlBody}}}{{/urlDecode}}

I'm thrilled about this because with Skuid I'm now able to give my users a way to review email history on a record that is way better than Lightning, which doesn't render html when viewing activities/"log a call" in a list or a report. We've been making big use of Lightning for Gmail, and trying out Cirrus Insight, which means our users are pushing in a lot of EmailMessage records. 
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Tim,

Glad you got it working and thanks for posting your solution.  I have used the {{#urlEncode}} quite a lot, but I forgot that there is also a {{#urlDecode}}.  Makes it simple to render HTML from a field.

Thanks!

Bill