Learning to love the Formula Language Try it, you’ll like it! Steve Kern, CLP.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Introducing JavaScript
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
The Web Warrior Guide to Web Design Technologies
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Guide To UNIX Using Linux Third Edition
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Using the Select Case Statement and the MsgBox Function (Unit 8)
Enhancing User Interaction Through Programming
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
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.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
ITCS373: Internet Technology Lecture 5: More HTML.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
IMS 3253: Subroutines 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Procedures Subroutines Parameters –By Value.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
XP Tutorial 8 Adding Interactivity with ActionScript.
JavaScript, Fourth Edition
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Lotus Domino Designer 6 Overview Maureen LelandSoftware Architect IBM Lotus.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
PestPac Software. Leads The Leads Module allows you to track all of your pending sales for your company from the first contact to the close. By the end.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Tutorial 11 1 JavaScript Operators and Expressions.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Perfecto Mobile Automation
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Variables, Expressions, and IO
Introduction to Scripting
WEB PROGRAMMING JavaScript.
PHP.
JavaScript: Introduction to Scripting
PHP an introduction.
Presentation transcript:

Learning to love the Formula Language Try it, you’ll like it! Steve Kern, CLP

Topics Formula Language Basics Comparisons to LotusScript ND6 Advances Typical Uses of the Formula Language List Processing Agent construction using the Formula Language

Formula Language Basics Definition of a formula: –A collection of statements that take an action or evaluate to a result –Formulas can contain constants, fields, and variables It’s really just one formula that executes as a single line of code (that’s why it’s fast!) –Regardless of length or complexity –Regardless of what appear to be multiple lines Three primary Keywords

Basic Most return a value and many have side effects –Side effects include retrieving a list of values, and launching a prompt box or a dialog box Numerous types including: –Arithmetic, String –Document information –Logical, Branching and Iterative –List processing –…

Basic arguments) Work only in the User Interface Do not return a value Provide access to menu commands, such as File, Import Many do not work with a Web browser

Basics: Keywords There are five keywords –DEFAULT and FIELD set field values –ENVIRONMENT reads and writes values to the Notes preferences file (notes.ini) –REM adds comments for Formulas –SELECT selects documents Except for FIELD, keywords must be listed first on a line

Basics: Operators Arithmetic: +, -, *, / Assignment: := Comparisons: =, >, <, != Logical: &, !, | List concatenation and subscripting: :, [#] Unary: +, -

Basics: Syntax Rules Semicolons must separate each statement Order of operations can be set using parentheses Very few formatting rules Spaces are required after keywords Formulas are not case sensitive, BUT by convention: –All caps are used for keywords (FIELD, DEFAULT) –Mixed case

Basics: Limitations Scope is limited to the current formula Complex logic can be difficult to code Cannot pass parameters or call with parameters One formula cannot call another No ability to repeatedly loop through documents No subroutines Some events don’t accept Formulas No debugger

Comparisons to LotusScript In general, the Formula Language executes more quickly than LotusScript Coding with the Formula Language is usually much simpler and requires less code Three examples: –Setting field values –Handling of Notes Names –Retrieving external data

Comparison: Setting Field Values Formula “Some Value”) LotusScript Sub Initialize ' No comments to save space Dim ws As New NotesUIWorkspace Dim db As NotesDatabase Dim docUI As NotesUIDocument Dim doc As NotesDocument Set docUI =ws.CurrentDocument Set doc = docUI.Document doc.myField = "Some Value" Call doc.Save(True,True) End Sub

Comparison: Handling Notes Names Formula "The Common LotusScript %INCLUDE "LSCONST.LSS“ Sub Initialize ' No comments to save space Dim sn As New NotesSession Dim nmUser As NotesName Dim jcCommon As String Dim jnBoxStyle As Long Dim jnAnswer As Integer Set nmUser = sn.CreateName(sn.UserName) jcCommon = nmUser.Common jnBoxStyle = MB_OK + MB_ICONINFORMATION jnAnswer = Messagebox(jcCommon, jnBoxStyle,"The Common Name is...") End Sub

Comparison: Retrieving External Data with the Formula Language REM "Use fields in Profile doc"; jcODBCSource "cODBCSource"); jcODBCSourceID "cODBCSourceID"); jpODBCPassword "pODBCPassword"); jcODBCTable "cODBCTable"); jcKey := "Key"; REM "Here’s the lookup itself:"; jcValue "ODBC" : "NoCache" ; jcODBCSource ; jcODBCSourceID ; jpODBCPassword ; jcODBCTable ; "SomeFld" : "null" ; "KeyFld" ; jcKey );

Comparison: Retrieving External Data with LotusScript Option Public Option Declare Uselsx "*LSXODBC" Sub Initialize ' Not functional - example only ' Limited comments Dim session As New NotesSession Dim db As NotesDatabase Dim docGPF As NotesDocument Dim conSQL As New ODBCConnection Dim qrySQL As New ODBCQuery Dim rsltSQL As New ODBCResultSet Dim jcODBCSource As String Dim jcODBCSourceID As String Dim jcpODBCPassword As String Dim jcODBCTable As String Dim jcQuery As String Set db = session.CurrentDatabase Set docGPF = db.GetProfileDocument("GPF") jcODBCSource = docGPF.cODBCSource(0) jcODBCSourceID = docGPF.cODBCSourceID(0) jcpODBCPassword = docGPF.pODBCPassword(0) jcODBCTable = docGPF.cODBCTable(0) jcQuery = "SELECT mySQL.SomeFld where keyfield=key" ' Create the ODBC Connection If Not conSQL.ConnectTo( jcODBCSource, jcODBCSourceID, jcpODBCPassword) Then Messagebox "Could not connect to source" Exit Sub End If Set qrySQL.Connection = conSQL Set rsltSQL.Query = qrySQL qrySQL.SQL = jcQuery rsltSQL.Execute If rsltSQL.IsResultSetAvailable Then ' Do some processing stuff End If ' Clean up - close the connection If conSQL.IsConnected Then conSQL.Disconnect End Sub

ND6 Advances Autocomplete functionality Order of execution Iterative functionality (well, sort of) Nested Assignments and Reassignment of variables As always,

ND6: Autocomplete A VERY welcome addition! –Works for the Formula Language, and –For Scripting languages As you begin typing, a window moves through matching commands; selects Autocomplete also displays syntax – particularly useful for

ND6: Order of Execution always execute last, especially in prior releases Some examples of –Deleting documents: executes in executes last –Running Agents? executes in executes last

ND6: Iterative Statements ND6 added three new @DoWhile execute a block of statements while a condition you set is executes a block of statements and increments a counter against an exit condition

ND6: Assignments The FIELD keyword can now be nested –No longer has to be the first item in a statement FIELD myCN (FIELD "The Common Name is..."; myCN); Variables can be reassigned jcMyName jcMyName "The Common Name is..."; jcMyName)

Typical Uses of the Formula Language Agents Field Events –Default Value –Input Translation –Input Validation Getting user input Keyword Fields List Processing View Selection Conditions View Column Formulas

List Processing Lists are collections of like data items Lists are similar to arrays Lists can contain numbers, text, time-dates, Notes names, etc. Unlike a list, arrays can contain only scalar values – no time-date values or Notes names

List Processing: @Unique()

List Processing: Working with Lists Retrieve specific elements –Retrieves the last element in the -1) Replace specific elements –Replaces “Second” with “2” jcList := "First" : "Second" : "Third" : "Last"; jcList "Second"; "2") Combine (concatenate) lists –This code prepends “First” to the list jcList := "Second" : "Third" : "Last"; jcList2 := "First" : jcList Perform math –Sums the total sales in the list jnTotalSales

Using the Formula Language to Coding an Agent Objectives of this exercise: –Build a simple agent to automate workflow for an approval form –Send mail to the approver with a link to the document to be approved –Send daily reminders –Log actions of the agent on each document

Agent Coding: Fields of Interest cDocStatus: The status of the document, i.e., New, Approved, Denied nmApprover: The Notes name of the approver cDocHistory: List of actions on the document cAgentHistory: List of agents run dAgentHistory: Dates of agents nReminders: The number of notifications

Agent Coding: How it Works The Agent runs on the server Schedule: daily, and not on weekends The Agent runs on all approval documents with a status of “New” It sends an with a doclink to the approver and increments the nReminder counter

Agent Coding: Chunk #1 REM {Send notification to the Approver}; SELECT Form = "FRQ" & cDocStatus = "New"; REM {Set reminder counter - used for escalations}; jnReminders := nReminders + 1; 1) jnReminders) ; REM {Add document history}; jcDocHistory := "Notification #" + + " sent to " nmApprover) + " on " + cDocHistory : jcDocHistory) ;

Agent Coding: Chunk #2 REM {Add agent history} ; REM {First, make sure the fields exist}; FIELD dAgentHistory := dAgentHistory ; FIELD cLastAgent := = dAgentHistory jcLastAgent := = ""; jcLastAgent; cAgentHistory : jcLastAgent));

Agent Coding: Chunk #3 REM {Send the notification}; jcSendTo nmApprover); jcSendTo := jcCC := "" ; jcSubject := "Requisition for " nmRequester) ; jcBody := "Please review the Requisition for " nmRequester) + ". Click the doclink at the bottom of this message!" jcCC; jcBCC; jcSubject; jcBody; ""; [IncludeDoclink])

Wrapping it up In this short time, we have: –Covered the basics –Compared the Formula Language to LotusScript –Learned about new features in ND6 –Learned about List Processing –Wrote an Agent using the Formula Language

Questions? Submit your questions now by clicking on the “Ask a Question” button in the bottom left corner of your presentation screen. Thank you! You can send additional questions to Steve Kern via