Cannot read property 'editor' of undefined

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
I wanted to display an error message on a popup and what I did was,

1. add a page Title component into the popup
2. gave a unique name to the page title component
3. in a custom javascript, on click of a button on the popup, used the below mechanism to display the custom message,

<some code>

var pageTitle = $('#searchContacts'); 
var editor = pageTitle.data('object').editor;

<more and more code>

 editor.handleMessages([{message: 'an error', severity:'ERROR'}]);

<more code>


However this works fine if I logging as an Administrator, The problem is If I logging another user (which doesn't have some permission to the page title component I guess) It gives me the below error

Uncaugh TypeError: Cannot read property 'editor' of undefined

1. What am I doing wrong here?
2. Is this really a permission issue?
3. Is there another way to display the custom js error?

Thanks in advance
Photo of Hasantha Liyanage

Hasantha Liyanage

  • 1,446 Points 1k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Hasantha Liyanage

Hasantha Liyanage

  • 1,446 Points 1k badge 2x thumb
Could someone be able to answer this?
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
What happens if you log in as the "other" user, open Dev Console, and execute the lines

var pageTitle = $('#searchContacts'); 
var editor = pageTitle.data('object').editor;
Photo of Hasantha Liyanage

Hasantha Liyanage

  • 1,446 Points 1k badge 2x thumb
Irvin, Appriciate your help on this,

I did as you said and still getting the same error; please see the attach image to see the error log



Thanks again
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
The output of var pageTitle seems correct.  What do you get when you type in pageTitle.data('object')?

Maybe it is a permission issue as you suggest with the model associated with the page title.  Have you checked the profiles/perm sets?  I would expect to see another sort of error if this was the case, however.

These sorts of issues are hard for me to diagnose without being hands on.  Maybe other community members can chime in.
Photo of Hasantha Liyanage

Hasantha Liyanage

  • 1,446 Points 1k badge 2x thumb
Irvin, Thanks for all your support which led me to the right path of debugging the issue. The issue here was I haven't assign the correct model to the page title and secondly I found that my 'other' user doesn't have access to the Lead record.

Finally, problem solved! Thanks again for your support
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Awesome, happy Skuid-ing.