T I P S & T R I C K S. A Brio Intelligence™ Developer’s JavaScript toolkit David Eastwood, Director Maddox Ford Ltd www.maddoxford.co.uk www.maddoxford.co.uk.

Slides:



Advertisements
Similar presentations
Debugging ACL Scripts.
Advertisements

Welcome! Were Glad Youre Here!. Whats New In Version 5.1b-100 Welcome to The Annual Information & Records Associates, Inc. User Conference May 20, 2009.
Behzad Samin 0 An End-to-End Overview of a RESTful Web Service.
Credit hours: 4 Contact hours: 50 (30 Theory, 20 Lab) Prerequisite: TB143 Introduction to Personal Computers.
Credit hours: 4 Contact hours: 50 (30 Theory, 20 Lab) Prerequisite: TB143 Introduction to Personal Computers.
1 Automating Auto Tuning Jeffrey K. Hollingsworth University of Maryland
Vanderbilt Business Objects Users Group 1 Reporting Techniques & Formatting Beginning & Advanced.
Easy to use Ability to attach policies/procedures to call types Ability to schedule calls in advance Officer safety alerts Robust search capabilities.
COMOS Mobile Solutions 1.0 Simplified global collaboration
Microsoft ® Office Access ® 2007 Training Build a database VI: Create reports for a new Access database ICT Staff Development presents:
Introducing JavaScript
Graphing AWR Data in Excel
Welcome to the Award Winning Easiest to Use & Most Advanced View, Manage, and Control Security, Access Control, Video, Energy & Lighting Systems, & Critical.
Lesson 30: Maintaining a Database. Learning Objectives After studying this lesson, you will be able to:  Change the layout of a table by adjusting column.
T H E B U S I N E S S P E R F O R M A N C E S O F T W A R E C O M P A N Y™ Brio Intelligence 8 Zero-Footprint Mode Without a plug-in, how do I…? Mark Ostroff.
Automating Tasks With Macros
Developing Effective Reports
Background Info The UK Mirror Service provides mirror copies of data and programs from many sources all over the world. This enables users in the UK to.
Quality Assurance CS 615. Mission Statement The Quality Assurance team will provide assurance to stakeholders in CS-615/616 projects that their projects.
Macromedia Dreamweaver 4 Advanced Level Course. Add Rollovers Rollovers or mouseovers are possibly the most popular effects used in designing Web pages.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Introduction to Visual Basic What it is, and a simple program Mike Thelwall University of Wolverhampton, UK.
1 Chapter 1 Tour of Access. 1 Chapter Objectives Start and exit Microsoft Access Open and run an Access application Identify the major elements of the.
Automation Solutions Scott Sandwith Applications Engineer
ADVANCED MICROSOFT POWERPOINT Lesson 6 – Creating Tables and Charts
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Python quick start guide
Preparation and processing of in-session documents.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
Lesson 15 Getting Started with PowerPoint Essentials
Copyright 2007, Information Builders. Slide 1 Maintain & JavaScript: Two Great Tools that Work Great Together Mark Derwin and Mark Rawls Information Builders.
Tutorial 6 Using Form Tools and Creating Custom Forms
SAG INFOTECH PVT. LTD Help Manual For Online HVAT filing SOFT SOLUTION FOR THOSE WHO CAN”T AFFORD TO MAKE ERROR.
Bulk facility SAG INFOTECH PVT. LTD. Service begins here…
© Cheltenham Computer Training 2001 Macromedia Dreamweaver 4 - Slide No 1 Macromedia Dreamweaver 4 Advanced Level Course.
For Version 6.0 and later Lattice3D Reporter Tutorial For Version 6.0 and later LATTICE TECHNOLOGY, INC.
Chapter 11: Introduction to the Visual Basic Environment Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
David Eastwood Maddox Ford Ltd.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Computing and the Web Operating Systems. Overview n What is an Operating System n Booting the Computer n User Interfaces n Files and File Management n.
A framework approach eases support for the iServer Brio Mid-Atlantic User Group 8 th April 2003 Socs Cappas QIQ Solutions.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
Productivity Programs Common Features and Commands.
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
For Version 4.0 and later Lattice3D Reporter Tutorial For Version 4.0 and later LATTICE TECHNOLOGY, INC.
Pasewark & Pasewark 1 Access Lesson 5 Creating and Modifying Reports Microsoft Office 2007: Introductory.
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
® IBM Software Group © 2006 IBM Corporation JSF Progress Bar This Learning Module shows how to integrate EGL/JSF functionality into a run-time progress.
1 MIS309 Database Systems Introduction to Microsoft Access.
© 2010 Pearson Education, Inc. | Publishing as Prentice Hall1 Computer Literacy for IC 3 Unit 2: Using Productivity Software Chapter 1: Starting with Microsoft.
® IBM Software Group © 2006 IBM Corporation Using JSF Mini-Calendar Controls This section describes how to use a JSF Mini-Calendar Control with EGL It.
JavaScript, Fourth Edition
Exploring Microsoft Access Chapter 7 Building Applications: The Switchboard, Macros, and Prototyping.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Pasewark & Pasewark 1 Access Lesson 5 Creating and Modifying Reports Microsoft Office 2007: Introductory.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Oracle Business Intelligence Foundation – Testing and Deploying OBI Repository.
5 Copyright © 2004, Oracle. All rights reserved. PL/SQL Server Pages.
Lawson Mid-America User Group Spring 2016 Meeting.
The New User Interface MEDITECH Training & Education.
Using Macros, Switchboards, PivotTables, and PivotCharts
Adastra v3 Reporting & National Quality Requirements
Microsoft Access Illustrated
Printer Admin Print Job Manager
Conditionally Confirming a Submit
JavaScript CS 4640 Programming Languages for Web Applications
Introducing JavaScript
JavaScript CS 4640 Programming Languages for Web Applications
Presentation transcript:

T I P S & T R I C K S

A Brio Intelligence™ Developer’s JavaScript toolkit David Eastwood, Director Maddox Ford Ltd

3 T I P S & T R I C K S Overview We were consistently needing to supply the same functionality for our Brio EIS development - often the same code was used in several places within the same application This led to the emergence of a function toolkit which has now been used in several major projects over the last 3 years Key samples of code are shown and described Other techniques such as error trapping are also discussed

4 T I P S & T R I C K S Software Versions The code featured has been developed using versions of Brio Intelligence from 6.0 to It works with both Designer and Insight (Client/Server and Plugins) The software has been used for live applications accessing Oracle, DB2 and SQLServer

5 T I P S & T R I C K S Origins of the work We were creating a series of Brio-based reporting applications used by relatively unskilled users to create operational reports and mid-level management reports These included – Shift activity rates in supermarket central depots – Printing delivery sheets for delivery runs – Summarising the status of automated test results in a manufacturing plant – Workflow reports for an insurance broker Some utilities also emerged from conventional dashboard applications

6 T I P S & T R I C K S Requirements Access to multiple databases for one report Multiple queries to create one report Inactivity timeouts from the RDBMS Creating a standardised look and feel for sets of up to 60 reports Automated export to Excel/PowerPoint Keep it simple! – Not too many controls and pictures Quick to build – Start from a template and add the query/reports – Add the EIS to a report - usually about 30 minutes

7 T I P S & T R I C K S Coding and naming conventions In order to speed up development we adhere to a fairly rigid naming convention for EIS objects - this means that scripts can be copied in and used with little or no modification JavaScript coding follows our coding standards to aid maintainability

8 T I P S & T R I C K S Naming conventions used Prefix name with variable type ‘g_’ prefix for globals Further ‘a’ prefix for function arguments

9 T I P S & T R I C K S Global functions Utilities held as a series of global functions – g_fname = fname Defined via a (hidden) button ‘Globals’ on the main EIS page Easy to redefine after code changes OnStartup event will define globals //Declare globals ActiveDocument.Sections["Selector"].Shapes["cbGlobals"].OnClick()

10 T I P S & T R I C K S Error trapping Some utilities are error-trapped Other checks done in code Mostly omitted from these examples to simplify readability Need to use.toString() method – not.name or.message

11 T I P S & T R I C K S Utilities described: Purpose and features Arguments used Code sample

12 T I P S & T R I C K S Hiding the sections and toolbars g_showDeveloperView – standard function to show/hide toolbars etc. – will also hide query sections from end-users – usually placed behind a logo to switch modes arguments – abShow : true/false switch

13 T I P S & T R I C K S g_showDeveloperView function showDeveloperView(abShow){ var nSecNum;//Number of Sections var nSecCount;//Section count ShowCatalog = abShow; ShowMenuBar = abShow; // note sometimes omit this command ShowStatusBar = abShow; Toolbars["Sections"].Visible = abShow; Toolbars["Formatting"].Visible = abShow; Toolbars["Standard"].Visible = abShow; //Loop turning section properties on/off //This version only lets user see EIS & Report sections - adjust as required nSecNum = ActiveDocument.Sections.Count; for (nSecCount = 1; nSecCount <= nSecNum; nSecCount++){ if ( (ActiveDocument.Sections[nSecCount].Type != bqEIS) && (ActiveDocument.Sections[nSecCount].Type != bqReport) ) { ActiveDocument.Sections[nSecCount].Visible = abShow; } } //end for }//end of showDeveloperView definition

14 T I P S & T R I C K S Logon functions The g_reconnect function is used We also often reconnect before processing – some database connections have inactivity timeouts – also catches other database errors //Disconnect from Queries and then Reconnect - in case of timeout if( g_reconnect( "Query", g_sPkMSId, g_sPkMSPassword ) ){ ActiveDocument.Sections["Query"].Process() Console.Writeln("Query Processed") }

15 T I P S & T R I C K S g_reconnect /* Function:reconnect -- Result:boolean true if connected, else false -- Parameters:asQuery- Section Name --asId- Userid --asPw- Password Disconnect and reconnect query to database */

16 T I P S & T R I C K S g_reconnect function reconnect( asQuery, asId, asPw) { var sOCEName = ActiveDocument. Sections[asQuery].DataModel.Connection.Filename // open OCE ActiveDocument. Sections[ asQuery ].DataModel.Connection.Open(sOCEName) //Disconnect from database ActiveDocument.Sections[ asQuery ].DataModel.Connection.Disconnect(); // Set Query connection parameters ActiveDocument.Sections[ asQuery ].DataModel.Connection.Username = asId; ActiveDocument.Sections[ asQuery ].DataModel.Connection.SetPassword( asPw ); // Log Query on to database try{ ActiveDocument.Sections[ asQuery ].DataModel.Connection.Connect(); } catch(errConnect) { Alert('Database connection error: '+errConnect.toString()) return false; } // Connected OK return true; } // End of reconnect definition

17 T I P S & T R I C K S Controlling limits When driving a query from an EIS page, you can either enter limit values on the EIS page or use the standard Limit dialogs We often customise Limit dialogs and allow the user to see variable limits - involves less code than setting limits on the EIS page Limits often need to be preset with sensible defaults On multi-query reports, we need to copy limits

18 T I P S & T R I C K S Setting limits Limit values 1. Set values on EIS Page 2. Copy variable limit values Limit Lim_1 Limit Lim_1 Limit Lim_1 Limit Lim_1(v1) 3. Process 1. Process Query 1 Limit Lim_1 Limit Lim_1 3. Process remaining queries 2. Copy limit values

19 T I P S & T R I C K S Setting date limits Set a limit to cover yesterday – 00:00:00 to 23:59:59 Set a limit to cover the previous week One sample shown, many variants for other date/time intervals

20 T I P S & T R I C K S g_setLimitByDay - example g_setLimitByDay("Query","Full Date",5) Example written on 7 October /10/02 in UK format!!

21 T I P S & T R I C K S g_setLimitByDay (1) Usage: g_setLimitByDay("Query","Full Date",1) Syntax: /* Function:setLimitByDay -- Parameters:asQueryName, asLimitName, adOffset Set custom limit on in section -- to between 00:00:00 days ago -- and 23:59:59 yesterday */

22 T I P S & T R I C K S g_setLimitByDay (2) function setLimitByDay(asQueryName, asLimitName, adOffset) { var dStart = new Date() - adOffset ; var dEnd = new Date() - 1; // i.e. yesterday var oLimit = ActiveDocument.Sections[asQueryName].Limits[asLimitName]; dStart.setHours(0); dStart.setMinutes(0); dStart.setSeconds(0); dEnd.setHours(23); //End datetime is 1 second to midnight dEnd.setMinutes(59); dEnd.setSeconds(59); oLimit.Operator =bqLimitOperatorBetween oLimit.SelectedValues.RemoveAll(); oLimit.CustomValues.RemoveAll(); oLimit.CustomValues.Add(dStart); oLimit.CustomValues.Add(dEnd); oLimit.SelectedValues.Add(dStart); oLimit.SelectedValues.Add(dEnd); }

23 T I P S & T R I C K S Copying limits Main purpose is to stop asking the user to enter the same limit twice – Apply the same limits to queries against different databases – Multiple queries against the same database – Union queries

24 T I P S & T R I C K S g_copyLimit Usage: g_copyLimit( "Query",'Create Date Time',"VRDT Query",'Create Date Time') Syntax: /* Function:copyLimit -- Parameters:asSourceSection, asSourceLimitName, -- asDestSection,asDestLimitName Copies the selected CUSTOM values from one limit to another -- duplicates other settings (Ignore, Operator, Nulls etc) -- NOTE we can't seem to set limit values where the limit is set on a computed column - we get an internal error */

25 T I P S & T R I C K S g_copylimit (1) function copyLimit(asSourceSection, asSourceLimitName, asDestSection,asDestLimitName) { var oSourceObj = ActiveDocument.Sections[asSourceSection].Limits[asSourceLimitName] var oDestObj = ActiveDocument.Sections[asDestSection].Limits[asDestLimitName] // read source limit settings var bIgnore = oSourceObj.Ignore var bIncludeNulls= oSourceObj.IncludeNulls var nNegate= oSourceObj.Negate var nOperator= oSourceObj.Operator var nSelectedValuesCount= oSourceObj.SelectedValues.Count var nSelVal //… continue next slide

26 T I P S & T R I C K S g_copylimit (2) //… continue from previous slide // set the limits on the second query if (bIgnore) { oDestObj.Ignore= true // not much point copying the rest! } else { oDestObj.Ignore=bIgnore // set Ignore state to match source oDestObj.IncludeNulls = bIncludeNulls oDestObj.Negate=nNegate oDestObj.Operator = nOperator oDestObj.SelectedValues.RemoveAll() oDestObj.CustomValues.RemoveAll() for (var i=1; i<=nSelectedValuesCount; i++) { nSelVal=(oSourceObj.SelectedValues[i]) oDestObj.CustomValues.Add(nSelVal) oDestObj.SelectedValues.Add(nSelVal) } // end for all limit values } // end else } // end function copyLimit

27 T I P S & T R I C K S Manipulation of EIS controls Functions to fill controls on an EIS page – Limit values in a Down, List Box etc – Show available sections in a Drop Down Functions to read values Selection controls, i.e Radio Buttons, Drop Downs etc, should be passive - they should not run processes. Control buttons should be used to actually run a process.

28 T I P S & T R I C K S Copying values to controls Only a few lines of code - we don’t generally write cover functions // Populate List Box var oProdLimit = ActiveDocument.Sections["Query"].Limits[”Prods"] var nProds = oProdLimit.AvailableValues.Count; lbProductList.RemoveAll(); for (i = 1 ; i <= nProds; i++) { lbProductList.Add(oProdLimit.AvailableValues[i]); }

29 T I P S & T R I C K S Dashboard functions Traffic lights Formatting numbers in JavaScript – When writing data values on an EIS page, the underlying number is shown - not the formatted version seen in the source section – No formatting functions in JavaScript Writing EIS settings to reports – Indicate values of user selection

30 T I P S & T R I C K S Sample dashboards (1)

31 T I P S & T R I C K S Sample dashboards (2)

32 T I P S & T R I C K S Sample dashboards (3)

33 T I P S & T R I C K S Traffic lights Simple manipulation of coloured objects Vary visible property

34 T I P S & T R I C K S g_format Usage: txtSales.Text = g_format({anumber},2) Syntax: /* Function:format -- Parameters:anum,anDP Returns text string with number formatted to places */

35 T I P S & T R I C K S g_format function format(anum,anDP){ // round to right number of decimal places // eliminate fractional part for now anum = Math.round(anum*Math.pow(10,anDP)); anum = anum.toString() if (anDP != 0) { // need to stick a decimal place into the string anum = anum.slice(0,(anum.length - anDP)) + '.' + anum.slice(anum.length - anDP) } return anum } // end format

36 T I P S & T R I C K S g_formatCurrency(1) Usage: txtSales.Text = g_formatCurrency({anumber},2) Syntax: /* Function:format -- Parameters:anum Returns text string with number formatted to places -- (usually 2 or 0), with separators every third place -- with a currency symbol prefixed */

37 T I P S & T R I C K S g_formatCurrency(2) function formatCurrency(anum,anDP){ var sCurrencySymbol = '£'; // edit to suit var sSeparator = ',' ; var nPoint; var sOutput = ''; //blank // round to right number of decimal places // eliminate fractional part for now anum = Math.round(anum*Math.pow(10,anDP)); anum = anum.toString() if (anDP != 0) { // need to stick a decimal place into the string anum = anum.slice(0,(anum.length - anDP)) + '.' + anum.slice(anum.length - anDP) } // standard format function to here, now add the Separators & Currency // continue next slide

38 T I P S & T R I C K S g_formatCurrency(3) // continue from previous slide nPoint = anum.indexOf('.') if (nPoint == -1) { nPoint = anum.length } for (var i=0 ; i < nPoint; i++) { if (((nPoint - i)%3 == 0)&&( i!=0)) { sOutput += sSeparator }// end if add separator sOutput += anum.substr(i,1) }// end for sOutput += anum.substr(nPoint); // fails gracefully for 0 DP return sCurrencySymbol + sOutput } // end format

39 T I P S & T R I C K S Writing EIS settings to reports Set a global variable Use this in the report expression Global Variable

40 T I P S & T R I C K S Exporting to Excel(1) Covered in depth in my paper at Brio 2001 Simple export via Clipboard or Export Fully automated via JOOLEObject – uses OLE Automation – some tricks needed All Excel methods can be called

41 T I P S & T R I C K S Exporting to Excel(2) oExcel = new JOOLEObject("Excel.Application"); oExcel.Visible = true; oExcel.Workbooks.Add; ActiveDocument.Sections[”mysectionname"].Copy() oExcel.Sheets.Item(1).Paste

42 T I P S & T R I C K S JOOLEObject pitfalls When calling methods with multiple arguments you need to supply the arguments in the reverse order to that shown in Microsoft documentation Brio: Slide.Tags.Add( " Value ", " TAG LABEL " ); Microsoft: Slide.Tags.Add( " TAG LABEL ", " Value " ) When selecting Items in a collection, use the.Item(n) method not [n]

43 T I P S & T R I C K S Development aids (1) Use the Brio Console window Don’t forget the Execution Window Copious use of Alerts and writeln

44 T I P S & T R I C K S Development aids (2) External JavaScript editor can be helpful with large scripts

45 T I P S & T R I C K S Development aids (3) Get a good JavaScript reference book Try to follow good JavaScript coding conventions – MUCH easier to read code (even your own) – Be disciplined about where you put the code

46 T I P S & T R I C K S Reference Material and Acknowledgements ‘JavaScript – The Definitive Guide’ David Flanagan, O’Reilly Maddox Ford Brio Development Standards Available from Platypus JavaScript editor Thanks to my colleagues for their input – especially Aelred Tobin

47 T I P S & T R I C K S Sample code Sample code available at the conference Download from Maddox Ford website – to David Eastwood at Maddox Ford –

T I P S & T R I C K S The end