Hi,
I am using an activex object to create custom data for my dashboard using sql. It looks like you cannot return an adodb recordset as the data source. Should I be creating JSON from the adodb.recordset? I am assuming that in order to access the data properly and be able to filter the data and parse through it that it will need to be in a JSON format. Is this assumption correct?
I also want to only display this dashboard tab when someone has selected a "SalesOrder" object within M-Files. I'm not quite sure how to do this.
Below is my js code thus far with the connection string replaced with ""
"use strict"; function OnNewShellUI( shellUI ) { // Register to be notified when a new normal shell frame (Event_NewNormalShellFrame) is created. // We use Event_NewNormalShellFrame rather than Event_NewShellFrame as this won't fire for history (etc.) dialogs. shellUI.Events.Register( Event_NewNormalShellFrame, handleNewShellFrame ); } function handleNewShellFrame(shellFrame) { // Register to be notified when the shell frame is started. // This time pass a reference to the function to call when the event is fired. shellFrame.Events.Register( Event_Started, getShellFrameStartedHandler( shellFrame) ); } function getCustomData() { //database connection var connection = new ActiveXObject("ADODB.Connection"); var connectionstring = ""; connection.Open(connectionstring); var rs = new ActiveXObject("ADODB.Recordset"); var results = ''; rs.Open("SELECT top 10 * FROM SalesOrders", connection); rs.MoveFirst; //move through recordset. Create JSON? while (!rs.eof) { results = results + ' ' + rs.fields(0).value.toString(); rs.movenext; } rs.close; connection.close; return results; } function getShellFrameStartedHandler(shellFrame) { /// <summary>Returns a function which handles the OnStarted event for an IShellFrame.</summary> // This is the ID of the dashboard, as declared in the appdef.xml file. var dashboardId = "soDashboard"; var customData = getCustomData() return function() { // The shell frame is now started and can be used. var tab = shellFrame.RightPane.AddTab( "mySalesOrderDashboard", "SO Details", "_last" ); // Load the content into the tab. tab.ShowDashboard( dashboardId, customData ); // Show the tab. tab.visible = true; // Register to be notified when new shell listings are created. shellFrame.Events.Register( Event_NewShellListing, getNewShellListingHandler( shellFrame, tab ) ); // Is there already a listing? If so then we need to hook into it as well. if (null != shellFrame.Listing) { getNewShellListingHandler( shellFrame, tab, dashboardId )( shellFrame.Listing ); } } function getNewShellListingHandler(shellFrame, tab, dashboardId) { /// <summary>Gets a function to handle the NewShellListing event for shell frame.</summary> /// <param name="shellFrame" type="MFiles.ShellFrame">The current shell frame object.</param> /// <returns type="MFiles.Events.OnNewShellListing">The event handler.</returns> // Return the handler function for NewShellListing event. return function(shellListing) { // Listen for selection change events on the listing. shellListing.Events.Register( Event_SelectionChanged, function(selectedItems) { // Sanity. if (false == shellListing.IsActive) { return false; } // Show our dashboard. tab.ShowDashboard(dashboardId, selectedItems); // We succeeded; return true. return true; } ); }; } }