|
Jul 12
2011
|
Viewing the Outside World From Within SalesLogixPOSTED BY: Greg Andorka POSTED IN: MyBlog
TAGGED IN: SalesLogix
|
There are many situations where a user needs, or would like to have, access to web based information that is not stored in SalesLogix. We would like to integrate access to other information from within SalesLogix so the user sees a single, seamless application. A couple of approaches for this will be described that use techniques both dependent, and independent, or SalesLogix framework.
The first, and simplest, approach is to show external data on a tab in one of the main views. We've all seen this demonstrated a thousand times. All you need to do is all the SalesLogix "Dynamic Web Content" control to a form and populate the "Dynamic URL" property.
The "Dynamic URL" property supports a syntax that allows you to dynamically populate a query string on the URL with the current entity's properties in a codeless way. The syntax for referencing an entity's properties is ${.}. Here is an example from the Application Architect help file that displays the location of the current entity on a Google map.
http://maps.google.com/maps?q=${Address.Address1},+${Address.City},+${Address.State}+${Address.PostCode}&sll=37.0625,-95.677068&sspn=23.875,57.630033&hl=en&ie=UTF8&t=h&z=16&iwloc=addr
This works great if there is no variation in the resource or query portions of the URL.
Another approach would be to display the data in a new browser tab or window. There are a number of ways to do this, and we will describe one that uses JavaScript in the client browser to accomplish this task.
Our solution is to add a button to a quick form, and use the onClientClick event of the button to execute a piece of JavaScript to open a new window/tab. This seems straightforward enough. The only tricky part is to inject the JavaScript code onto the page in an ASP/SLX appropriate way. To do this we will add the following code to the form Load Actions.
Sage.Entity.Interfaces.<ISomeEntity> myentity = this.BindingSource.Current as Sage.Entity.Interfaces.<ISomeEntity>;
string sURL =
string.Format("http://www.mycompanywebsite.com.com/DataSite/GetMeInfo?frm={0}&id={1}", FormName, MyEntity.Id.ToString());
<MyButtonControlID>.OnClientClick = "window.open('" + sURL + "', '', 'directories=no,location=no,menubar=no,pageXOffset=0px,pageYOffset=0px,scrollbars=yes,status=no,titlebar=no,toolbar=yes');";
ClientBindingMgr.RegisterSaveButton(<MyButtonControlID>);
This approach has the advantage of showing the URL in a new browser window, and gives us the freedom to build the complete URL in code without the restriction of having a predefined URL template, as in the first example.
The disadvantage of this approach is that it still requires a round trip to the server, and the associated performance hit, just to execute the code. Ugly!
Our third and final approach is to get everything to run in the client browser and still live within the confines of ASP/SLX.
As you might suspect, there are tricks to getting this to work also. The first is to use the non-standard HTML attribute pin="pin" in the script tag in order to get ASP to leave our code on the page. Here is an example. We could have just as easily put our code in an external file, but we would still need the non-standard "pin" attribute in the script tag.
<script pin="pin" type="text/javascript">
function showWin( someURL )
{
// put any preprocessing here
window.open(someURL, '', 'directories=no,location=no,menubar=no,pageXOffset=0px,pageYOffset=0px,scrollbars=yes,status=no,titlebar=no,toolbar=yes');
}
</script>
Next, we need to use a control that will execute our JavaScript function, showWin(), directly without posting to the server first. Our solution to this depends on using a SmartPart, and placing our control on it. For instance, just add a simple anchor tag <a href=”javascript:showWin()” >Show the window</a> to the appropriate place on your page.
These three approaches give varying degrees of flexibility when linking to the outside world. Each has a place in the developers' toolbox to accommodate the variety of situations that may arise.





