You need to sign in to do that
Don't have an account?
Create Javascript in Service Cloud Console
Hi,
I have a great need in enabling Javascript in Service Cloud Console.
For example, I have a javascript in home page component which expand the range of the Calendar for date field. This works fine for Accounts and Contacts in regular Sales console when I enable the home page component in home page layout. However when it goes to SCC everything is in an iframe.
What I'm doing right now is in SCC Account page -> edit page layout -> click Custom Console Components
In Primary Tab Components -> Right Sidebar, I choose Type: Visualforce Page, Visualforce Page: HomePageLoader (this visualforce page is basically load the Home Page in an iframe of the VF page so javascript in Home Page component can make change to the main page. Note: this is a hack since VF page and standard SF page are using different domains)
This works most of the time but doesn't seem to be a good practise. It seems like sometimes run into a concurrency problem and javascripts (home page in the iframe) will never finish loading.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(
function() {
var startYear = 1930;
var endYear = 2050;
var optionsString = '';
if (startYear < endYear) {
for (i = startYear; i < endYear + 1; i++) {
optionsString += "<option value=\""+i+"\">" + i
+ "</option>";
}
$('#calYearPicker').html(optionsString); //change calYearPicker in regular sales console
for (j = 0; j < window.top.frames.length; j++) {
//travers thru the frames in SCC and change calYearPicker in SCC
$('#calYearPicker', window.top.frames[j].document)
.html(optionsString);
}
}
});
</script>
Any advise or workaround will be great.
Thanks in advance,
Ricky
Very very creative..!
<apex:page >
<apex:includeScript value="/support/console/25.0/integration.js"/>
<script type="text/javascript">
(function () {
setTimeout(function () {
sforce.console.getEnclosingPrimaryTabId(function (result) {
var subdomain = '{!URLFOR(JSENCODE($Action.Account.Tab), JSENCODE($ObjectType.Account), null, true)}';
subdomain = subdomain.substring(0, subdomain.indexOf(".salesforce.com"));
var homePageUrl = subdomain + ".salesforce.com/home/home.jsp?tabId=" + encodeURIComponent(result.id);
setTimeout(function () {
var iframe = "<iframe src='" + homePageUrl + "'></iframe>";
document.write(iframe);
}, 50);
});
});
})();
</script>
</apex:page>