I have a button that needs to open in the Service Console, and here is my javascript, any ideas? This is a new error and I am not sure how to handle, that is stopping a lot of activities


Cannot read property 'getEnclosingPrimaryTabId of undefined


try { 
var query = "SELECT Id,Name,Contact__r.Name FROM TripProfile__c WHERE Trip__c = '{!Trip__c.Id}'"; 
var tripprofile = sforce.connection.query(query); 
var tripProfileArr = tripprofile.getArray("records"); 
if(typeof tripProfileArr === 'undefined' || tripProfileArr.length === 0 ) 
alert('There is no Trip Profile built yet'); 
}else if (typeof(srcUp) === 'function'){ 
var url = '/apex/tripprofile?tpid=' + tripProfileArr[0].Id; 
var callOpenSubtab = function callOpenSubtab(result) { 
sforce.console.openSubtab(result.id, '/apex/tripprofile?tpid=' + tripProfileArr[0].Id + '&isdtp=vw', true, 'TP - ' + tripProfileArr[0].Contact__r.Name); 
} else { 
var url = '/apex/tripprofile?tpid=' + tripProfileArr[0].Id; 
} catch (e) { 

sforce.console is in the Console Integration Toolkit's script along with that method you're trying to call: getEnclosingPrimaryTabId.

It looks like you're only loading the Ajax Toolkit. (connection.js & apex.js)

If you add the console integration toolkit to your button, you should be good to go.



| improve this answer | |

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.