• Srikanth Sunkara 23
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hi,

I am receiving Internal salesforce Error when running the test class and I found the line of code(c.RecordTypeId= accountsRecordType) that is causing the problem by trial and error method . Can you please suggest the workaround to overcome it.

Scenairo: Trying to change the recordtype of  a case record and updating other values through Controller and VF page during a button click.

Controller Class: 

 Id  accountsRecordType =        Schema.SobjectType.case.getRecordTypeInfosByname().get('Accounts').getRecordtypeId();
   Id  cancellationsRecordType =   Schema.SobjectType.case.getRecordTypeInfosByname().get('Cancellations').getRecordtypeId();
Case c = [Select id, Stage__c,status,Division_Display_Name__c,Policy_AppNumber__c,Application_ID__c,Agent_Handover_From__c,RecordTypeId,contactId From Case Where RecordtypeId=:cancellationsRecordType and Id = :ApexPages.currentPage().getParameters().get('id')];
            PageReference retURL;
           //c.Policy_AppNumber__c!=null || c.Application_ID__c!=null
           if(c.Policy_AppNumber__c!=null || c.Application_ID__c!=null){
            c.status= 'New'; 
            c.stage__c= 'Refund Required'; 
            c.ownerID='005900000072URy'; 
            //c.RecordTypeId= accountsRecordType;
            c.Action_Refund_Time__c = system.Now();
             update c;
             retURL = new PageReference('/' + c.id);
             retURL.setRedirect(true);

 Test class passes by commenting out the code c.RecordTypeId= accountsRecordType in controller but this logic is required.
Hi,

I am having this code under Custom button click ffor case record and it works fine in Sales Cloud but the same code is not working as expected in service console(redirection to Case owner change page doesnt happen)

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/support/console/29.0/integration.js")} 

var recId = window.location.href.substring(window.location.href.lastIndexOf('/') + 1); 
var c = new sforce.SObject("Case"); 
c.id = "{!Case.Id}"; 

// make the field change 
//c.Agent_Handover_From__c= '{!$User.Id}'; 
c.Agent_Handover_From__c= '{!$User.FirstName}'+ ' ' + '{!$User.LastName}'; 
//{!$User.FirstName} {!$User.LastName}"; 
c.Agent_Handover_Time__c = new Date(); 
c.Stage__c='Sales HandOver'; 
c.RecordTypeId ='01290000000iaw4'; 
// save the change 
sforce.connection.update([c]); 
var redirectURL = '/'+ recId + '/' + 'a?retURL=%2F' + recId ; 
//window.location = '/'+ recId + '/' + 'a?retURL=%2F' + recId ; 
if (sforce.console.isInConsole()) { 
sforce.console.getEnclosingTabId(function(enclosingResult){ 
sforce.console.getEnclosingPrimaryTabId(function(primaryResult){ 
sforce.console.openSubtab(primaryResult.id, redirectURL, true, '', null); 
}); 
}); 

else { 
window.location.href = redirectURL; 
}

Can you please suggest the change in the code to make it work in service console.


Regards
Srikanth Sunkara
Hi,

I am receiving Internal salesforce Error when running the test class and I found the line of code(c.RecordTypeId= accountsRecordType) that is causing the problem by trial and error method . Can you please suggest the workaround to overcome it.

Scenairo: Trying to change the recordtype of  a case record and updating other values through Controller and VF page during a button click.

Controller Class: 

 Id  accountsRecordType =        Schema.SobjectType.case.getRecordTypeInfosByname().get('Accounts').getRecordtypeId();
   Id  cancellationsRecordType =   Schema.SobjectType.case.getRecordTypeInfosByname().get('Cancellations').getRecordtypeId();
Case c = [Select id, Stage__c,status,Division_Display_Name__c,Policy_AppNumber__c,Application_ID__c,Agent_Handover_From__c,RecordTypeId,contactId From Case Where RecordtypeId=:cancellationsRecordType and Id = :ApexPages.currentPage().getParameters().get('id')];
            PageReference retURL;
           //c.Policy_AppNumber__c!=null || c.Application_ID__c!=null
           if(c.Policy_AppNumber__c!=null || c.Application_ID__c!=null){
            c.status= 'New'; 
            c.stage__c= 'Refund Required'; 
            c.ownerID='005900000072URy'; 
            //c.RecordTypeId= accountsRecordType;
            c.Action_Refund_Time__c = system.Now();
             update c;
             retURL = new PageReference('/' + c.id);
             retURL.setRedirect(true);

 Test class passes by commenting out the code c.RecordTypeId= accountsRecordType in controller but this logic is required.
Hi,

I am having this code under Custom button click ffor case record and it works fine in Sales Cloud but the same code is not working as expected in service console(redirection to Case owner change page doesnt happen)

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/support/console/29.0/integration.js")} 

var recId = window.location.href.substring(window.location.href.lastIndexOf('/') + 1); 
var c = new sforce.SObject("Case"); 
c.id = "{!Case.Id}"; 

// make the field change 
//c.Agent_Handover_From__c= '{!$User.Id}'; 
c.Agent_Handover_From__c= '{!$User.FirstName}'+ ' ' + '{!$User.LastName}'; 
//{!$User.FirstName} {!$User.LastName}"; 
c.Agent_Handover_Time__c = new Date(); 
c.Stage__c='Sales HandOver'; 
c.RecordTypeId ='01290000000iaw4'; 
// save the change 
sforce.connection.update([c]); 
var redirectURL = '/'+ recId + '/' + 'a?retURL=%2F' + recId ; 
//window.location = '/'+ recId + '/' + 'a?retURL=%2F' + recId ; 
if (sforce.console.isInConsole()) { 
sforce.console.getEnclosingTabId(function(enclosingResult){ 
sforce.console.getEnclosingPrimaryTabId(function(primaryResult){ 
sforce.console.openSubtab(primaryResult.id, redirectURL, true, '', null); 
}); 
}); 

else { 
window.location.href = redirectURL; 
}

Can you please suggest the change in the code to make it work in service console.


Regards
Srikanth Sunkara