Custom Javascript In Planning



Similar documents
JavaScript: Introduction to Scripting Pearson Education, Inc. All rights reserved.

Quest ChangeAuditor 5.1 FOR ACTIVE DIRECTORY. User Guide

HP Operations Manager Software for Windows Integration Guide

ios Team Administration Guide (Legacy)

Dell Unified Communications Command Suite - Diagnostics 8.0. Data Recorder User Guide

Dell NetVault Backup Plug-in for Advanced Encryption 2.2. User s Guide

SpatialWare. Version for Microsoft SQL Server 2008 INSTALLATION GUIDE

FOR WINDOWS FILE SERVERS

HYPERION SYSTEM 9 N-TIER INSTALLATION GUIDE MASTER DATA MANAGEMENT RELEASE 9.2

Microsoft Dynamics GP. SmartList Builder User s Guide With Excel Report Builder

Xcode User Default Reference. (Legacy)

January 23, 2010 McAfee SaaS Continuity User Guide

Improving Performance of Microsoft CRM 3.0 by Using a Dedicated Report Server

Apple Applications > Safari

Standard Client Configuration Requirements

Expense Reports v4.10.1

Microsoft Access 3: Understanding and Creating Queries

Using InstallAware 7. To Patch Software Products. August 2007

New 11g Features in Oracle Developer Tools for Visual Studio. An Oracle White Paper January 2008

Quick Connect Express for Active Directory

Information on Syslog For more information on syslog, see RFC Released: December 2006 Interoperability issues: None. Table 1: Syslog at a Glance

Business Portal for Microsoft Dynamics GP. Key Performance Indicators Release 10.0

Veritas Cluster Server Database Agent for Microsoft SQL Configuration Guide

IBM Unica emessage Version 8 Release 6 February 13, User's Guide

Inquiry Formulas. student guide

CA Nimsoft Monitor. snmptd Guide. v3.0 series

Dell Spotlight on Active Directory Server Health Wizard Configuration Guide

Windows Scheduled Tasks Management Pack Guide for System Center Operations Manager. Published: 07 March 2013

How to test and debug an ASP.NET application

Spotlight on Messaging. Evaluator s Guide

Lab 02 Working with Data Quality Services in SQL Server 2014

Installation Manual UC for Business Unified Messaging for Exchange 2010

Charter Business Phone. Online Control Panel Getting Started Guide. Document Version 1.0

How To Write Tvalue Amortization Software

Primo Online End User Help. Version 4.x

Smart Web. User Guide. Amcom Software, Inc.

P R O V I S I O N I N G O R A C L E H Y P E R I O N F I N A N C I A L M A N A G E M E N T

RIT Installation Instructions

CA Nimsoft Monitor. Probe Guide for E2E Application Response Monitoring. e2e_appmon v2.2 series

Master Data Services. SQL Server 2012 Books Online

FileMaker Server 15. Getting Started Guide

CA Spectrum and CA Service Desk

Empowered by Innovation. Setting Up and Using Fax Mail. P/N July 2006 Printed in U.S.A.

CMG 7.5. Quick Guide InConference. Makes your extension a conference room. Rev A4

CRM Migration Assistant Speeding your migration to CRM 2011

EVENT LOG MANAGEMENT...

SQL Server An Overview

Supermicro Server Monitoring with SuperDoctor 5 and SCOM 2012

CS SoftDent Practice Management Software Installation Guide for Client/Server Configurations

USER MANUAL APPLICATION MONITOR. Version March 2015

Data Tool Platform SQL Development Tools

Dell KACE K1000 System Management Appliance Version 5.4. Service Desk Administrator Guide

Remote Console Installation & Setup Guide. November 2009

Dell Statistica Statistica Enterprise Installation Instructions

How To Load Data Into An Org Database Cloud Service - Multitenant Edition

FUSION Installation Guide

Plug-In for Informatica Guide

StarWind iscsi SAN Software: Installing StarWind on Windows Server 2008 R2 Server Core

The Top 10 Things DBAs Should Know About Toad for IBM DB2

Quick Install Guide. Lumension Endpoint Management and Security Suite 7.1

Timeless Time and Expense Version 3.0. Copyright MAG Softwrx, Inc.

Getting Started with IntelleView POS Administrator Software

InTouch HMI Scripting and Logic Guide

HP LoadRunner. Software Version: Ajax TruClient Tips & Tricks

HP Quality Center. Upgrade Preparation Guide

WS_FTP Server. User s Guide. Software Version 3.1. Ipswitch, Inc.

Unicenter Patch Management

Contents COMBO SCREEN FOR THEPATRON EDGE ONLINE...1 TICKET/EVENT BUNDLES...11 INDEX...71

Jet Data Manager 2012 User Guide

Nimsoft Monitor. ntevl Guide. v3.6 series

PHP Tutorial From beginner to master

VERITAS NetBackup 6.0

Big Brother Professional Edition Windows Client Getting Started Guide. Version 4.60

Syslog on Polycom Phones

ShoreTel Enterprise Contact Center 8 Using Agent Toolbar

Management Reporter Integration Guide for Microsoft Dynamics AX

Using Network Application Development (NAD) with InTouch

Dell One Identity Quick Connect for Cloud Services 3.6.0

User Guide to the Snare Agent Management Console in Snare Server v7.0

Shavlik Patch for Microsoft System Center

Setting Up ALERE with Client/Server Data

SQL Server Integration Services with Oracle Database 10g

CA Nimsoft Monitor. Probe Guide for NT Event Log Monitor. ntevl v3.8 series

By the Citrix Publications Department. Citrix Systems, Inc.

Config Guide. Gimmal Smart Tiles (SharePoint-Hosted) Software Release 4.4.0

How To Use Query Console

Dell NetVault Backup Plug-in for SQL Server 6.1

Section 1: Preface Introduction... 1 Users... 1 Other Resources... 2 Conventions... 2 Icons... 2 Text... 2

Oracle Enterprise Single Sign-on Logon Manager. Installation and Setup Guide Release E

Business Portal for Microsoft Dynamics GP. Electronic Document Delivery Release 10.0

By the Citrix Publications Department. Citrix Systems, Inc.

Eventia Log Parsing Editor 1.0 Administration Guide

Connectivity Pack for Microsoft Guide

BarTender s ActiveX Automation Interface. The World's Leading Software for Label, Barcode, RFID & Card Printing

SMART Sync Windows operating systems. System administrator s guide

Quest InTrust for Active Directory. Product Overview Version 2.5

StarWind iscsi SAN Software: Using with Citrix XenServer

SnapLogic Tutorials Document Release: October 2013 SnapLogic, Inc. 2 West 5th Ave, Fourth Floor San Mateo, California U.S.A.

Security Analytics Engine 1.0. Help Desk User Guide

Veritas Cluster Server Database Agent for Microsoft SQL Configuration Guide

Transcription:

A Hyperion White Paper Custom Javascript In Planning Creative ways to provide custom Web forms This paper describes several of the methods that can be used to tailor Hyperion Planning Web forms. Hyperion has enabled Custom JavaScript within Hyperion Planning to allow for easy customization and validation of Web forms. This paper also describes tools that can be used, explains some basic JavaScript syntax, and provides some examples. The reader should have a general knowledge of Hyperion Planning and Web development basics. Tools to use A text editor. A good text editor is crucial for writing and debugging JavaScript. There are several freeware and shareware text editors that include syntax highlighting, parentheses matching features, and code completion (see the Resources section at the end of this document for links to text editors). The following code shows the differences between Crimson Editor and Notepad. Crimson Editor: Notepad: In both examples, the code is exactly the same but the display makes the first easier to interpret than the second.

A Web browser. Because Internet Explorer does not have a built-in JavaScript console and FireFox is a bit too sensitive, Mozilla Suite is the recommended Web browser for JavaScript development. When you implement your custom script, you could possibly have errors in your code. Mozilla has a built-in JavaScript console that displays error messages with line numbers. Clicking on an error message takes you to the line of code that is in error. To Launch the JavaScript Console in Mozilla, select Tools > Web Development > JavaScript Console. After the JavaScript Console is launched, you can test your code for errors. In the following example, an error message is displayed that the function validateonsave has not been defined. This message could be the result of a typo or similar error. Double-clicking on the error message launches a source browser and highlights the line that is in error. A good development environment. To test your code, it is often necessary to stop or start the Web server. In a production environment, however, this may be difficult to do. 2

SampleValidateData.js and ValidateData.js (located in the Custom directory of your Web application server). These files contain the full suite of available functions and samples. You need to put all of your custom code in ValidateData.js so Planning to read it. Devlopment procedures The first step in developing custom JavaScript is to determine what you are trying to do and when it should happen. The samples provided with Planning include the following events that you can capture: Loading a form Clicking save Selecting a cell Leaving a cell The samples also include variations on those events as well as additional helper functions that you can call during those events. An optional second step is to use the native alert function in JavaScript, which displays a message box. The syntax is displayed in the following example: alert( Test Message ); This displays a message box with the text Test Message. Adding this code where you want your custom code to execute enables you to see the timing and frequency of your customization. The message also provides notification that your code is working. If the message box is not displayed, then your code may not be configured correctly or you may need to stop and restart the Web server. After you have determined that your test message displays correctly and with the correct frequency, you can develop your code further. Javascript basics For those new to JavaScript, there are many tutorials and examples available on the Web (see the Resources section for links to online resources), which you can use while developing your code. However, this section provides a few basic principles. Building Blocks JavaScript is organized into objects, properties, methods, functions, and events. Objects are the building blocks of JavaScript. A Web page is an object, commonly referred to as a document. In Planning, objects include forms, grids, columns, rows, and cells. Properties are the values associated with an object. In Planning, a common property is cell.value, where cell is the object, and value is the property. Methods are the actions that you can perform on objects. For example, document.writeln combines the method writeln with the object document, and tells the Web browser to insert content into the Web page followed with a carriage return. The following sample is from SampleValidateData.js: document.writeln('<table cellspacing=0 cellpadding=0 border=0><tr><td>'); 1 Events trigger a function. For example, when a user clicks the Save button, that event calls the function validateform. Functions do the work that you are trying to accomplish. Functions have the following syntax: function MyFunction (Variable) { commands; In the preceding example, the function MyFunction takes the parameter of Variable. A variable is not required, although the parentheses are. The following examples are from Planning: function customcellvalidatepost(row, col, cell) { return; function customsaveformpost() { return(true); The function customcellvalidatepost takes the parameters (or variables) of row, column, and cell. The function customsaveformpost does not have any parameters. All functions begin and end with braces {. 3

Conditional Logic JavaScript includes an If statement for conditional tests. The syntax for If statements is fairly straightforward, although it can become complex when there are nested conditions and many sets of parentheses and braces. The following example shows the basic syntax for an If test: If (a question that returns true or false) {Do something for True Else {Do something for False The following is an example of a Planning-related If statement: if (equalsignorecase(formname,"labor")) {valid = validateonsave(); The preceding example calls the function equalsignorecase as a conditional test. If the current form name is Labor or the form name is labor," then the function validateonsave is executed. This example does not have an else case. The next example shows an If statement with multiple commands: if (val < 0) { alert("negative values are not allowed."); validated = false; canceldrag(); selectlocation(row,col); The preceding example does several things when a user enters a value less than zero. First, a message box provides an alert that the value is incorrect. Second, a variable called validated is set to False, alerting the calling function ValidateOnSave that the validation has failed. Next, the function canceldrag is executed (a built-in Planning function that deselects the range of cells the user has selected). Last, the offending cell is selected. Operators If statements can contain mathematical comparisons. The available comparison operators are <, >,!=, ==, <=, >=, to represent less than, greater than, not equal to, equal to, less or equal to, and greater or equal to. When testing for an exact value, it is important that you use the == or double equal operator. A single operator is an assignment. For example, Val=1 sets the variable Val equal to one, but Val==1 tests to see if the variable Val is equal to one. Using a double plus sign (++) allows for incrementing, as in the following example: for (r=startrow; r<numbergridrows; r++) { The variable r is set to the number of the starting row of a grid (zero in this example), and while r is less than the total number of rows in the grid, r will be incremented by one. This example is part of a for loop statement that enables you to execute code against each row of the grid from start to end. A for loop is a set of commands to execute one or more times. In the preceding example, the code is executed from the starting row until it reaches the number of rows in the grid. The initial variable r is set to the value of the starting row (1, for example) and is incremented by one until it no longer meets the condition of being less than the number of rows in the grid. You can use a single plus sign (+) to concatenate values and strings. For example, you can cause a message to display that includes the value less than zero that a user entered in a Web form: if (val < 0) { alert("negative values are not allowed. You entered: + val); When the code in the preceding example is executed, a warning message is displayed that notifies the user of an invalid entry and displays the invalid data. Putting it all together The following example demonstrates validating a form. The purpose of this block of code is to check that a user has accurately entered data across all (approximately 30) input cells. Section 1: Validating the Form function validateform() { var valid = true; if (equalsignorecase(formname,"labor1") equalsignorecase(formname,"labor2")) { valid = validatevariance(); return valid; 4

The function validateform() is a native Planning function, and this section of code is executed after the user clicks Save but before the data is actually sent to the database. This code is capable of canceling the Save operation. The first step in this section is to create a variable called valid and assign to it a value of true. This creates a default value and will remain true unless set to a different value. Next, the code tests to see if the form name is either Labor1 or Labor2 the double pipe characters indicate or. If the test is true, that is, the form is named Labor1 or Labor2, then it calls the function validatevariance and checks for its value, reassigning the value of validatevariance to the variable valid. Last, it returns the value of valid to Planning. If the value of valid is true, the save continues (along with business rules set to run on save). If the value of valid is false and then the save is canceled the data will not be saved to the database unless it is valid. Section 2: Checking the Grid The validateform code calls the function validatevariance, which is where the real work is done, to validate the data entered by the user. You can name this function anything that makes logical sense. For example, you might choose to name it validatetotal, or something similarly descriptive. function validatevariance() { var validated = true; var cellvalid = 0; for (r=startrow; r<numbergridrows; r++) { for (c=startcol; c<numbergridcols; c++) { var cell = getcellval(r,c); if (isfinite(parsefloat(cell))) { cellvalid = limitprecision(cellvalid + getcellval(r,c),3); if (cellvalid!=1) { validated = false; cellvalid = limitprecision(cellvalid * 100,2); alert("the numbers you have entered do not equal 100% \nyour Total Percentage is: " + cellvalid + " %"); return(validated); This section of code begins with setting a new variable, validated, to true and initializing the numeric value cellvalid. Next, it begins two for loops to iterate through each column and row in the grid. Then, it assigns the value from the current data cell in the grid to the variable cell. The next step is to find out if the cell contains a data value if it s null or missing, it shouldn t be included in the total. This test is performed with the JavaScript function isfinite() 2, which determines if the value is a finite number. A null value won t pass here. Next, we increment our initialized value cellvalid with the contents of the finite number. This process also calls a follow-on function (LimitPrecision) that only takes the first three significant digits of the number, because there are times when including many digits of precision can produce undesirable results with JavaScript. Finally, after looping through every cell on the grid and adding all of the numbers together, the code tests the results. In this instance, the code checks if the variable cellvalid is not equal to a value of one, which would indicate data was over- or under-allocated. If cellvalid is not equal to a value of one, then the variable validated is set to false. Additionally, a message is displayed to the user that the input is not valid and indicates their total entry amount. 3 Finally, the value of false is passed all the way back through each of the functions until it is returned to validateonsave, which cancels the Save. No further actions are taken. Section 3: Limiting Precision The last part of the code relates to limiting the precision of the numbers used in the calculation. function limitprecision(value, limit) { if ((value == null) (value.length == 0) (value == missing)) { return(value); else { return((math.round(value * Math.pow(10,limit)))/Math.pow(10,limit)); 5

This example uses the limitprecision function, which takes the parameters value and limit. Value is the value to be limited and limit is the number of significant digits to store. The full code example uses both two and three digits for different reasons. Two native JavaScript math functions, round and pow,are used to round the requested value to the requested limit. The pow function is used in this example to raise 10 to the power specified as the limit (10 2 or 10 3 100 and 1000 respectively), which allows for the rounding to occur with less precision. For example: Math.round(121.5 * 100) / 100 moves the decimal point prior to rounding, and then moves it back. 6

Section 4: All of the Code All of the code is put together and ready for implementation. function validateform() { var valid = true; if (equalsignorecase(formname,"labor1") equalsignorecase(formname,"labor2")) { valid = validatevariance(); return valid; function validatevariance() { var validated = true; var cellvalid = 0; for (r=startrow; r<numbergridrows; r++) { for (c=startcol; c<numbergridcols; c++) { var cell = getcellval(r,c); if (isfinite(parsefloat(cell))) { cellvalid = limitprecision(cellvalid + getcellval(r,c),3); if (cellvalid!=1) { validated = false; cellvalid = limitprecision(cellvalid * 100,2); alert("the numbers you have entered do not equal 100% \nyour Total Percentage is: " + cellvalid + " %"); return(validated); function limitprecision(value, limit) { if ((value == null) (value.length == 0) (value == missing)) { return(value); else { return((math.round(value * Math.pow(10,limit)))/Math.pow(10,limit)); 7

Tips Ensure that you read the entire Appendix A of the Hyperion Planning Administrator s Guide it contains useful tips, hints, and warnings. When you perform a Planning upgrade, you should back up your custom JavaScript, and then re-insert it in ValidateData.js after the upgrade is complete. JavaScript can be very frustrating to the experienced programmer because there is no compiler, which means that the language cannot be tested prior to its execution. The debugging and writing of JavaScript is best accomplished using some of the tools listed in the Resources section of this document. You can use any function in the Planning library (for example, EnterData.js), however, those functions are subject to change and their compatibility with future versions is not ensured. If you are going to use an existing Planning function from one of the Planning libraries, it is recommended to copy the function and all of its dependent functions into your custom JavaScript, rename them, and use the renamed functions so that you are better protected against upgrades. If you use any custom JavaScript, it is important that you use all of the custom JavaScript functions contained in ValidateData.js. Add your custom code where necessary and leave the existing functions and their return calls in place. When ValidateData.js is active, Planning looks for all of the functions contained within and if some are missing, errors may occur. Resources The Hyperion Planning Administrator s Guide, specifically Appendix A, which includes all of the JavaScript samples and documentation. Mozilla Web Browser: http://www.mozilla.org/ download.html - the version referenced in this document is Mozilla 1.7.12, which is the full Mozilla suite. Crimson Editor: http://www.crimsoneditor.com/ - a free, comprehensive text editor. CPad: http://zantii.net/ - another free text editor. TextPad: http://www.textpad.com/ - a powerful text editor (not free but well worth it). The JavaScript Source - http://javascript.internet.com/ - a Web repository of JavaScript code along with tutorials, documentation, and sample code. Endnotes 1 This code is used to draw a table within the form. 2 There are a number of ways to test for a number. isfinite() is just one of them. 3 The \n in the alert causes a new line to be displayed in the message box. Hyperion Solutions Corporation Worldwide Headquarters 5450 Great America Parkway, Santa Clara, CA 95054 voice 1.408.588.8000 / fax 1.408.588.8500 / www.hyperion.com product information voice 1.800.286.8000 (U.S. only) consulting services e-mail northamerican_consulting@hyperion.com / voice 1.203.703.3000 education services e-mail education@hyperion.com / voice 1.203.703.3535 worldwide support e-mail worldwide_support@hyperion.com Please contact us at www.hyperion.com/contactus for more information. Copyright 2006 Hyperion Solutions Corporation. All rights reserved. Hyperion, the Hyperion logo and Hyperion s product names are trademarks of Hyperion. References to other companies and their products use trademarks owned by the respective companies and are for reference purpose only. No portion hereof may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or information storage and retrieval systems, for any purpose other than the recipient s personal use, without the express written permission of Hyperion. The information contained herein is subject to change without notice. Hyperion shall not be liable for errors contained herein or consequential damages in connection with furnishing, performance, or use hereof. Any Hyperion software described herein is licensed exclusively subject to the conditions set forth in the Hyperion license agreement. 5970_0506