1

I'm building Custom Console Component pages to display with Case detail in Service Console to display other recent cases, assets, related Contact/Account details, etc. leveraging the Case.Id that is passed to the Controller Extension. This is fine for view/edit on existing Cases, but not on [New].

StandardController has access to ContactId, as it pulls it onto the Case detail in edit/create from the Contact, but it is not passed to the Controller extension, and in a Create() event, there is no Case.Id passed either (as it hasn't been assigned yet). These are the only parameters that I have clear access to:

[id=5004000000eKviT (only for pre-existing Cases)], inContextPane=true, isdtp=vw, nonce=f9b448c3f48a718360f5fdcdb10b14d9b3c675268a84903a9fb17f72e18c84da, sfdcIFrameOrigin=https://cs8.salesforce.com

Is there any way to access StandardController's params?

  • At the moment, I'll take it as given that there's no (current) way to access this -- moving on to other issues. – Duncan Stewart Feb 23 '15 at 19:48
0

I've managed to hack up a solution, but YMMV.

My requirement was to display Account related details, but it's a refactored Case view page, therefore it is using standard Case controller with extension.

Essentially you need a container page that checks if id is present. If not, render VF page and get the id via JS, then redirect to intended footer page. If id is already present - redirect to footer via Apex.

Container page:

<apex:includeScript value="/support/console/37.0/integration.js"/>
<script type="text/javascript">
        var pageLoad = window.onload;
        window.onload = function() {
                if (pageLoad) {
                        pageLoad();
                }
                testGetFocusedPrimaryTabId();
        }

        function testGetFocusedPrimaryTabId() {
                 sforce.console.getFocusedPrimaryTabObjectId(showTabId);
         }
         var showTabId = function showTabId(result) {
                 document.location.href='/apex/ConsoleFooter?accountid='+result.id;
         };
</script>

Container controller:

public with sharing class ConsoleFooterContainer {
    public pagereference redir(){
        if ( System.currentPageReference().getParameters().get('id') == null )
            return null;
        else
            return new pagereference ('/apex/ConsoleFooter?id=' + System.currentPageReference().getParameters().get('id'));
    }
}

Finally in my extension constructor, I am getting the accountId and doing some checks if case id is present.

    case current;
    if ( controller.getId() != null )
        current = [select accountid, parent.accountid
                                    from case 
                                    where id =: 
                                    controller.getId()];

    id accountId = ( current != null ) ? 
         ( current.accountId == null ) ? current.parent.accountId : current.accountId : 
        System.currentPageReference().getParameters().get('accountid');
    // retrieve main record
    account a = [select id, name, foo__c from account where id=: accountid];

It's takes an extra few seconds on new case screen, but works. Let me know if you need any help! Cheers.

  • Thanks @dzh -- I ended up creating a custom button on the Contact layout that creates a 'shell' Case (a minimal info. Case recordtype) which can be edited by selecting the correct Case recordtype and continuing. By creating the shell case and saving it, I can then use the new Case.Id to access Account/Contact/Asset/custom object details and display/use them in the various header/footer/side panes as needed. Your solution looks very streamlined by comparison :D Thanks for making it available! – Duncan Stewart Oct 18 '16 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.