Push data into existing documents

Hi there,

I have a number of documents that require data to be filled in (over-write the existing info)…

Four fields that are required to be filled (price1, price2, royalty1, royalty2) - currently they have ‘Not listed’ according to :

@If ( = “”; “None Listed”; )

Form name is ‘parts’

The key field is a part number in a format : ABCD-####-####

The middle four numbers indicate the version number of the part - so there could be a number of docs that could have the same first and middle four characters … All the parts that belong to a particular version have the same price/ royalty …

I want to use an action button that could isolate the docs by comparing ABCD-#### only and then fill the values I specify for part1, part2, royalty1, royalty2 …

How do i code this ?

Many thanks in advance for all your help!

Subject: Push data into existing documents

First you need a view that trims off the last four digits (and the dash). It needs to be sorted by that value…as it is a key.

Now assuming this action is done from a document with a part number on it, it should do something like this:

dim s as new notessession

dim ws as new notesuiworkspace

dim uidoc as notesuidocument

dim doc as notesdocument

dim db as notesdatabase

dim view as notesview

dim dc as notesdocumentcollection

dim key as string

set db = s.currentdatabase

set view = db.getview(“newviewname”)

set uidoc = ws.currentdocument

set doc = uidoc.document

key = Left(doc.keyfieldname(0),9)

set dc = view.getalldocumentsbykey(key, true)

set doc = dc.getfirstdocument

do while not (doc is nothing)

'…do whatever you need to do to each document in here

set doc = dc.getnextdocument

loop

Subject: RE: Push data into existing documents

Matt,

thanks so much for your input!

i’ll try this out …

Subject: Push data into existing documents

Here are some guidelines for creating view actions

To build an action, you can use any of the following:

Simple actions that you select from a list

Formulas

LotusScript

JavaScript

Common JavaScript

When to use actions

Because actions are available in a view or document, use them for any general-purpose task related to a group of documents.

When the automated task is relevant only to a subset of documents.

When users need to see all the available choices in a row at the top of a document.

When the automated task isn’t limited to a particular section of a form.

If formulas are complex and you don’t want to save the formula with each document.

Examples of actions

View actions – Let users create, print, delete, or categorize documents.

Form actions – Process an approval; mail a document; or give Web users, who don’t have access to Notes menus, a way to click to edit, save, or close documents.

General Syntax Rules:

A formula must follow these general syntax rules.

Statement separators

Separate multiple statements with semicolons.

FIELD RegionalManager := AreaManager;

FIELD AreaManager := @DeleteField

Spaces

You can place any number of spaces, including none, between operators, punctuation, and values. However, keywords must be delineated by at least one space, and spaces within text constants are significant.

For example, the following statements are equivalent.

LastName + ", " + FirstName;

LastName+", "+FirstName

In the following statement, at least one space must follow the reserved word SELECT.

SELECT @All

Case

Case is not significant except within text constants. By convention, keywords such as FIELD are uppercase, and @function and @command names such as ProperCase are mixed uppercase and lowercase. You need not follow these conventions when typing, but Domino changes the case to conform to the conventions when saving a formula.

Operators and values

Two values must be separated by at least one operator.

Working With @Functions

All @functions evaluate to a value and can be placed in a formula anywhere a value of that type can be placed. When the formula executes, the value of the formula takes the place of the formula. Some formulas also have side-effects, that is, they cause actions to occur. For example, @Prompt causes a message box to appear.

Most @functions can be used in formulas for any Notes object, but some @functions are restricted in their applicability. The following table lists the @functions that are restricted and lists the Notes objects in which they can be used effectively. In addition, for an @function to return information on the current database, view, document, or field, these objects must be current.

Working With @Commands:

@Commands are special @functions that perform immediate actions in the user interface. Most @commands mimic menu commands. For example, the following formula, if executed from a button, puts the current document in Edit mode and moves the insertion point down twice:

@Command([EditDocument]; “1”);

@Command([EditDown]; “2”)

The syntax for an @command is one of the following:

@Command([command-name]; arg1; arg2; … argn)

@PostedCommand([command-name]; arg1; arg2; … argn)

The name of the @function is @Command or @PostedCommand. The first argument is the name of the @command enclosed in brackets. The remaining arguments are the arguments to the @command.

See @Commands for a list of the available commands.

You can use @commands in formulas for toolbar buttons, agents that do not specify target documents, events, button hotspots, and action hotspots. You cannot use @commands in a formula that does not interact with the user. These include replication, form, selection, column, hide action, window title, section title, section access, insert subform, hidden paragraph, default value, input translation, input validation, computed value, and keyword field formulas, and agents other than those that specify no target documents.

You cannot use most @commands in Web applications, since @commands are based on the Notes workstation user interface. About 30 @commands are supported but some behave differently. See “Programming Domino for Web Applications,” “Formula language.”

You cannot use @commands with LotusScript.

@Command functions execute in sequence with other @functions, with some exceptions. For example, the following formula executes the @command first:

@Command([EditDocument]; “1”);

@Prompt([OK]; “Edit mode”; “The document is now in Edit mode.”)

@PostedCommand functions execute in sequence with each other after all other @functions execute. This emulates the behavior of @Command in Notes R3. For example, the following formula executes the @command last:

@PostedCommand([EditDocument]; “1”);

@Prompt([OK]; “Edit mode”; “The document will go into Edit mode.”)

You can check and respond to the return value of @Command (but not @PostedCommand). The return value is @True if the @command succeeds and @False if it fails. The following toolbar button formula returns if the FileOpenDatabase @command fails.

@If(@Command([FileOpenDatabase]; “NEWSUBJ”); “”; @Return(“”));

@Command([Compose]; “”; “Main Topic”);

@Command([EditGotoField]; “Subject”);

@Command([EditInsertText]; “New subject”);

@Command([EditGotoField]; “Body”)

Try it - its fun!