Manage Learn to apply best practices and optimize your operations.

An Agent That Allows An Administrator To Change A Field Value

This script can be used as an agent or as a function. It is designed to make
changing field values easy (ie - a hidden, or computed field that has gone
wrong). This will display all the fields available on the form and once a field
has been chosen a prompt for a new value is displayed.

Keep in mind there is no validation so what you enter replaces the current
value. (Can makes for some interesting dates). It will throw an error for rich
text fields.

This is designed as a tool for an administrator only so an appropriate
hide/when would be in order.

The script was written in Australia where day format is dd/mm/yyyy therefore
one message prompt will have to be changed if you use different date formats.
Sub Initialize
Dim workspace As New notesuiworkspace
Dim uidoc As notesuidocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim itemName As String
Dim fieldname As String
Dim noitem As Integer
Dim itemarray() As String
Dim longlist As String
Dim currentitemvalue As Variant
Dim changeitem As Integer
Dim newitemvalue As Variant
Dim message As String
Dim itemtype As Integer


Set uidoc = workspace.currentdocument
Set doc = uidoc.document
uidoc.EditMode = True
noitem = 0
Forall i In doc.Items
noitem = noitem + 1
End Forall
Redim itemarray(noitem)
arrayno% = 1
Forall i In doc.Items
itemarray(arrayno%) = i.name
arrayno% = arrayno% + 1
End Forall
fieldname = workspace.Prompt( PROMPT_OKCANCELLIST,"Field to
change","Please select the field value you want to change",,itemarray)
Set item = doc.GetFirstItem( fieldname )
itemName = item.Name
itemType = item.Type
If itemtype = 1024 Then
Messagestring$ = "This is a date field please enter the value
as dd/mm/yyyy, it will convert any entry to a valid date with unforseen
consequences so be careful"
Elseif itemtype = 768 Then
Messagestring$ = "This is a number field please enter a value
as a valid number, do not enter text of any kind"
Else
Messagestring$ = "Enter the value you wish keeping in mind the
kind of field you are populating"
End If
newitemvalue = Inputbox (Messagestring$, "What value do you want
?" )
If itemtype = 768 Then
Set item = doc.ReplaceItemValue _
(itemname,Cvar(newitemvalue))
Elseif itemtype = 1024 Then
Set item = doc.ReplaceItemValue _
(itemname,Cvar(newitemvalue))
Elseif itemtype = 1 Then
Messagebox "Sorry, this function cannot update or change a rich
text field - you'll have to do it some other way",0,"Sorry, no can do !"
Else
Set item = doc.ReplaceItemValue _
(itemname,Cstr(newitemvalue))
End If
Call doc.save(True,True)
Call UIDoc.Close
End Sub

This was last published in November 2000

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close