Salesforce Integration With Desktop Application
Triggering The Right Tab in The Salesforce Console From The Desktop
- Salesforce is giving bunches of incorporation capacities. The majority of them depend on APIs that you can devour from the program (ex: Chatter API) or from the worker (SOAP or REST API).
- In certain conditions, there could be a need to do program-side combinations.
- Salesforce is as of now giving Canvas Apps, an approach to coordinate 2 applications in the program (Salesforce with an outsider). Be that as it may, imagine a scenario where you need to incorporate in a work area a non-program application with Salesforce?
- We should envision you having a committed CTI customer sent to your work area. It isn't running in the program. Such instruments can be incorporated with the program by calling a Salesforce URL, pushing the setting as boundaries.
- On an approaching call, this will trigger another tab in the program. Each time you have a call, you will add a tab. Incredible to abstain from eradicating a forthcoming work, however on the off chance that you are running Salesforce comfort you will have on various occasions the reassurance. Or on the other hand on the off chance that you focus on a
- Visualforce URL to deal with the record popup depending on the unique situation, how might you convert the new program tab into the correct comfort tab? Also, how to try not to open loads of program tabs?
- The program innovation keeps tabs from shutting themself in the event that it isn't initiated by a client. Attempt to get to a custom URL that hosts a basic content doing window.close(), this won't close the tab.
- The arrangement is to open the URL on the approaching call, consistently in a similar focused on tab. How might you accomplish this ? Envision you are running Internet Explorer. Your CTI customer on the work area could run the accompanying lines of code:
- var url = 'https://yourdomain.my.force.com/apex/yourVisualforcePage?param1=value1&phone=1234567890';
- var shellApplication = new ActiveXObject('Shell.Application');
- var windows = new Enumerator(shellApplication.Windows());
- var w = null;
- while(!windows.atEnd()){w=windows.item();windows.moveNext()};// Retrieve the last window
- if(w)w.Navigate(url, 0, 'CTI');
The URL must be powerfully made to push the setting as URL boundaries. The last line of code will focus on the program tab named 'CTI'.
Don't forget to check out: Introduction of Call Center Computer Telephony Integration | Salesforce Guide
- However, we actually have a leftover specialized tab apparent in the program. Not very easy to understand.
- We can move it into the reassign, inside a named iframe. Rather than opening the tab, the page will be stacked into the iframe. We can have this iframe in a support segment (essential: your application is running as a comfort application).
- The part will consistently be going, regardless of whether it isn't physically open, the page is stacked.
- Presently, how to deal with the screen pop? Utilizing the API comfort. It can run impeccably from the segment, however not from the iframe inside the part. We need to tell the part to begin the popup with the specific circumstance, each time the iframe is stacked.
- You can't utilize window.postMessage() (a html5 highlights permitting to present information on another window) as the iframe window has no reference to another window (and imagine a scenario in which different Salesforce examples are running, how might you broadcast your setting to every one of them).
- Your iframe and your support segment are 2 pages running on a similar space. You can communicate information utilizing capacity occasion (localStorage), this will communicate the setting to all Salesforce open tabs on that space.
- The reassure part will be advised from any change on the capacity, you need to guarantee that the worth is changed for the normal key, and how about we start the popup
Code for the Visualforce page that will be loaded into the iframe named 'CTI' :
<apex:page showHeader="false" standardStylesheets="false" docType="html-5.0" > <script type="text/javascript"> localStorage.setItem('JLA', window.location.search); </script> </apex:page>
This page is just writing the context into the localStorage. This will trigger the storage event on all other pages.
Code for the console component that will host the iframe page and run the popup.
<apex:page> <apex:includeScript value="/support/console/34.0/integration.js"/> <script type="text/javascript" > var handle_storage = function (storageEvent) { /* StorageEvent { key; // name of the property set, changed etc. oldValue; // old value of property before change newValue; // new value of property after change url; // url of page that made the change storageArea; // localStorage or sessionStorage, depending on where the change happened. } */ if(storageEvent.key=='JLA' && storageEvent.newValue!=''){ //prevent triggering other events. IE9 triggers the event with empty value on the same window after removing the item var str = storageEvent.newValue; var objURL = {}; str.replace(new RegExp( "([^?=&]+)(=([^&]*))?", "g" ), function( $0, $1, $2, $3 ){objURL[ $1 ] = decodeURIComponent($3);} ); //If your context is in the 'phone' parameter, use fromobjURL["phone"] in a SOQL query to retrieve the targeted recordID //... imagine the variable 'targetURL' is built based on your soql result (removed from this code to make it shorter) var targetURL='/001g000000ia2Pc'; sforce.console.openPrimaryTab(undefined, targetURL, true, 'the Title'); localStorage.removeItem('JLA');//allow re-issuing same url for testing purpose } }; window.addEventListener("storage", handle_storage, false); </script><iframe name="CTI" width="5" height="5" frameborder="0" ></iframe> </apex:page>
Check out another amazing blog by Pooja here: API Versions in Salesforce - All You Need to Know
- Presently you have a basic, lightweight, program innovation in Salesforce that can respond to work area started occasions.
- You can use it for the basic program-to-program incorporation as well, for example on the off chance that you simply need to popup a support tab from an outer web application.
- A custom weblink will get to that visualforce page, that will trigger in the course all the above rationale. No compelling reason to have any devoted javascript or programming interface or anything like this created in the calling application.
- As you most likely are aware Canvas applications should run over HTTPS. With this innovation, your outer application doesn't need SSL.
Responses