• Billu
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

From the Case object, we have a custom button that creates an RMA with case and account information filled in and then opens the new RMA record. It works fine in the normal salesforce.com.

 

In the Service Cloud Console, we have Accounts, Cases, and RMA's. If we create new Cases or new RMA's from the Account, the new records get create in new subtabs to the account.

 

But if we launch our CaseToRMA page from the case in a Service Cloud Console subtab, it results in a whole new instance of saleforce.com running in the original case tab. What we want is for the new RMA to open in a new subtab under the account and to leave the case open.

 

CasetoRMA class

 

public class CaseToRMA {
    public Case c {get; set;}
    public RMA__c rma {get; set;}
public CaseToRMA () { c = [ select c.Id, c.CaseNumber, c.Account.ShippingCountry, c.Account.ShippingPostalCode, c.Account.ShippingState, c.Account.ShippingCity, c.Account.ShippingStreet, c.Account.Name, c.AccountId from Case c where id = : apexPages.currentPage().getParameters().get('id')];
List<Settings__c> cs = [ select RMA_Warehouse__c from Settings__c]; RMA__c rma = new RMA__c( ZipPostalCode__c = c.Account.ShippingPostalCode, Warehouse__c = (cs.size() > 0) ? cs[0].RMA_Warehouse__c : null, Street__c = c.Account.ShippingStreet, StreetTextArea__c = c.Account.ShippingStreet, RMADate__c = system.today(), Country__c = c.Account.ShippingCountry, City__c = c.Account.ShippingCity, Case__c = c.Id, Account__c = c.AccountId, AccountName__c = c.Account.Name, Reference__c = c.CaseNumber); }

public PageReference NewRMA() {
insert rma;
return new PageReference('/' + rma.id);
}

 

 

 

 VisualForce Page

<!-- Old way -->
<apex:page controller="CaseToRMA" action="{!newRMA}" >
<!-- Attempt at opening in a new tab
<apex:page controller="CaseToRMA" action="{!newRMA}" >
    <apex:includeScript value="/support/console/20.0/integration.js"/>
    <script type="text/javascript">
        function init() {
                //First find the ID of the primary tab to put the new subtab in
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
        }
        var openSubtab = function openSubtab(result) {
                //Now that we've got the primary tab ID, we can open a new subtab in it
            var primaryTabId = result.id;
            sforce.console.openSubtab(primaryTabId , '/' + rma.id, false,
                rma.Name, null, null);
        };
    </script>
    <body onLoad="Init()"/>
-->
</apex:page>

 If someone has a working example of this, it would be great.