1

Salesforce doesn't support text wrapping when Case Comments have long strings of text. This means that the Case Page sometimes gets incredibly wide, which makes it difficult to edit / read.

Salesforce has a published workaround here using a bookmarklet: https://help.salesforce.com/articleView?id=000176537&language=en_US&type=1

This seems like a great opportunity to simply embed the JavaScript directly to the page via a Visualforce page, but I seem to be having trouble (I'm pretty new to JavaScript). Am I missing anything here? Is it even possible?

First try:

<apex:page standardController="Case">
    <script type="text/javascript">
        var sty = document.createElement('style');
        sty.innerHTML = "table.list{width:1200px;}td.dataCell{word-wrap:break-word;word-break:break-all;}";
        document.head.appendChild(sty);
    </script>
</apex:page>

Second try:

<apex:page standardController="Case">
    <script type="text/javascript">
        var css = "table.list{width:1200px;}td.dataCell{word-wrap:break-word;word-break:break-all;}",
        head = document.head || document.getElementsByTagName('head')[0],
        style = document.createElement('style');
        style.type = 'text/css';
        if (style.styleSheet){
            style.styleSheet.cssText = css;
        } else {
            style.appendChild(document.createTextNode(css));
        }
    </script>
</apex:page>

Any suggestions would be welcome!

1
  • What is happening? Are you not seeing the expected output?
    – javanoob
    Commented Feb 27, 2017 at 18:49

1 Answer 1

1

You can't embed the script in the page, because it won't have access to the parent page (it's an iframe). However, you can use apex:detail, and just override the entire page:

<apex:page standardController="Case">
    <script type="text/javascript">
        var sty = document.createElement('style');
        sty.innerHTML = "table.list{width:1200px;}td.dataCell{word-wrap:break-word;word-break:break-all;}";
        document.head.appendChild(sty);
    </script>
    <apex:detail subject="{!Case}" />
</apex:page>
5
  • Thank you! This makes a lot more sense. We have JavaScript that triggers a popup window on a separate page layout, but now I understand why it doesn't work here. Thanks!
    – Carolyn
    Commented Feb 28, 2017 at 18:04
  • Tangental question: do you know if there's a <apex:detail> equivalent for Activity History. I've got the same issue (long URls pushing the window quite wide), and was curious if there was a quick way to override it without going into a custom controller.
    – Carolyn
    Commented Mar 8, 2017 at 17:54
  • @Carolyn I think you'd mean apex:relatedList. apex:detail only shows a single record.
    – sfdcfox
    Commented Mar 8, 2017 at 18:10
  • It's actually the expanded related list that I'm considering (available when you click "View All" under the Activity History related list. Here's an example: 3.bp.blogspot.com/-sKcxIhYTSHE/U5wsdcYNBeI/AAAAAAAAAG8/…
    – Carolyn
    Commented Mar 8, 2017 at 19:10
  • @Carolyn Oh, that page. I don't believe there's a way to customize that page at all, so you'll probably have to end up writing code.
    – sfdcfox
    Commented Mar 8, 2017 at 19:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .