We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
hi Aditya, within the hyperlink javascript I am trying to access the contact object var c = new sforce.SObject("Contact"). But I get the sfoce is not defined exception on the console.
This is happening in the winter 16 version. looks like it works fine in summer 15.
I think the issue is to add within {!REQUIRESCRIPT('/soap/ajax/31.0/connection.js')} within the hyperlink function. Do you know how can we add it?
Hi Sunil,
It is not possible to import another file in the Hyperlink function of formula field. Incase you are referring to the 2nd example in the above post, that would work only in the console app.
However, you can implement your requirement using a Custom button with ExecuteJavascript Action.
Follow this link http://blog.adityanaag.com/...
Aditya, does it work for you in the console? I get the same error, "sforce not defined" when I try it inside the service console.
Hi Thomas,
Pls use HYPERLINK("javascript:srcUp('URL')"), to open URLs.
Coming to the function sforce.console.getEnclosingPrimaryTabId, sforce is a part of integration.js which was imported by default into Salesforce Console until a few releases ago. In the latest release, integration.js is no longer imported, and hence sforce isnt defined.
Integration.js should be explicitly imported for any custom implementations involving sforce.
***** However, if you reverse engineer the updates to the Salesforce Console Internal Javascript files, you will find that the file ServiceDeskViewCTI.js now has the required sforce methods.
For example privateapi.console.openPrimaryTab(); (sforce has changed to privateapi)
**** This code is for Internal Salesforce use only, not be used by developers and subject to change without notice *****
Integration.js is something which is always open to developers to import and develop custom code.
So, to get the ServiceDeskViewCTI component include in the console page we probably need to add a CTI component. I looked around the sources in my non-CTI-extended console app and privateapi isn't defined, nor is ServiceDeskViewCTI.js downloaded.
To hack this, then, I'm going to see if I can add an invisible (disabled) CTI feature and see if the js and privateapi show-up.
If I write any javascript code ,will it run javascript on load or after I edit the record or save it
It will run when the detail page loads.. So it might be after you edit and save or create a new record.
Could Javascript show a value in a formula field without having to be clicked? I was thinking a JS formula field could behave like a Rollup Summary Field.
Salesforce's out-of-box Rollup Summary Field only works with master-detail relationships. Could a JS formula field behave like a Rollup Summary Field for lookup relationships?
No Ezra. You will have to click on the Formula field to cause the Javascript in it to execute. The best way to implement Rollup Summary for lookups is by using an Apex Trigger.
Alternately, check my blog post in which I described on how to execute Javascript on Page Load using Custom buttons.
http://blog.adityanaag.com/...
Its a rather complex process where you will have to use sforce to get the count/sum of the child records, and display it on the detail page, by manipulating the DOM.(Not the best way to do this though)
Thanks for the post Adi.