ChadSmiley Blog
Things about family, life, coding, and more
Links
Domino Tools
:
BlogSphere
:
Domiclipse
:
LotusScript.doc
LS as HTML
ScriptBrowser
Set Template Version
Smiley Tools
Copy Docs to DB
Document Locking Class
Domino Extended
Edit Document Fields
Format Formula as HTML
One Teamstudio Icon
Open Audit
Quick Elementer
Reference Lookup
Refresh Word Fields
Sites I Read
Toolbar Functions
Latest Downloads
Reference Lookup Library 1.2.0
Set Template Version
Design Information
Reference Lookup Library 1.1.0
Rational Rose Add-in for Lotus Domino Download
Format Formula 2 HTML Download
Reference Lookup 1.0.0
Twitter
follow me on Twitter
Search
Albums
Auto
Family
Fun
Home
Ads by Google
Category
BlogSphere
Cycling
Domino
Family
General
Home School
Microsoft
News
PDA
Proverb
Rational Rose
SnT Thursday
Teamstudio
MiscLinks
Archive
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
Full Archive
Googles
reference
download open audit
popsicle stick house
reference
reference
reference
reference
reference
reference
word macro refresh fields
02/28/2006
Edit Document Fields 4.1.0 Code
Bookmark :
Edit Document Fields 4.1.0 Code
Select All
REM {Edit Document Fields 4.1.0 by Chad Schelfhout.}; REM {Visit http://www.chadsmiley.com/EditDocumentFields for the latest updates}; REM {Get a listing of all the fields on the current document}; List := @Sort( @DocFields ); REM {Reusable title.}; PromptTitle := @DbTitle + " - " + @ViewTitle; REM {Possible data types to choose from.}; REM {I called Number Integer because use keyboard to select what you want with keyboard quicker.}; DataTypes := @Explode( "Text,Date,Integer,Password,Name,Common Name,Abbreviate Name,Remove Field,Text Multi Value,Date Multi Value,Integer Multi Value,Name Multi Value,Common Name Multi Value,Abbreviate Name Multi Value,Upper Case Text,Lower Case Text,Proper Case Text,Upper Case Text Multi Value,Lower Case Text Multi Value,Proper Case Text Multi Value,+ Append Values,Sort Ascending,Sort Descending,Replace,Replace Substring,Unique,Implode,Explode" ; "," ); REM {Prompt for which field needs to be updated.}; @DoWhile( EditField := @Prompt( [OkCancelEditCombo] ; PromptTitle ; "Select the field you wish to alter:" ; @Environment( "edfLastField" ) ; List ); EditField = "" ); @Environment( "edfLastField"; EditField ); REM {Based on the field that was selected determine the current field type using the GetField function.}; DefaultDataType := @If( @IsNumber( @GetField( EditField ) ) ; @If( @Count( @GetField( EditField ) ) > 1 ; "Integer Multi Value"; "Integer" ) ; @IsTime( @GetField( EditField ) ) ; @If( @Count( @GetField( EditField ) ) > 1 ; "Date Multi Value"; "Date" ) ; @If( @Count( @GetField( EditField ) ) > 1 ; "Text Multi Value"; "Text" ) ); REM {If the data type is a type of error then select the data type of text}; DefaultDataType := @IfError( DefaultDataType ; "Text" ); REM {Prompt for which data type you would like the data to be}; REM {This needs to be done before value prompt to determine if the Picklist or any prompting needs to be used.}; DataType := @Prompt( [OkCancelList] ; EditField + " - " + PromptTitle; "Please select the correct data type or action for field: " + EditField + "."; DefaultDataType ; DataTypes ); REM {Format the original value as text because the @Prompt command requires text.}; OriginalValue := @If( @Contains( DefaultDataType ; "Multi Value" ) ; @Implode( @Text( @GetField( EditField ) ) ; ";" ); @Text( @GetField( EditField ) ) ); EditField := @If( DataType = "Replace Substring" | DataType = "Replace" ; @Prompt( [OkCancelListMult] ; PromptTitle ; "Select any addtional fields you wish to alter:" ; EditField ; List ); EditField ); REM {Determine the string that they are searching for.}; FromRawValue := @If( DataType = "Replace Substring" | DataType = "Replace" ; @Prompt( [OkCancelEdit] ; EditField + " - " + PromptTitle ; "Please enter the text to search for in: " + @Implode( EditField ; ", " ) + "." ; "" ) ; "" ) ; ReplaceFailure := @False; Separator := @If( DataType = "Implode" | DataType = "Explode" ; @Prompt( [OkCancelEdit] ; PromptTitle ; "Enter the " + @If( DataType = "Implode" ; "separator" ; "separators" ) + ":" ; "" ); ";" ); REM {Based on what type of data is being entered different prompts will happen if any at all.}; REM {Use the GetField function instead of using Abstract which always returned text and did not convert non text data.}; RawValue := @If( @Contains( DataType ; "Name Multi Value" ); @PickList( [Name] ); @Contains( DataType ; "Name" ) ; @PickList( [Name] : [Single] ); DataType = ( "Remove Field":"Unique":"Sort Ascending":"Sort Descending":"Implode":"Explode") ; "" ; @Contains( DataType ; "Multi Value" ); @Prompt( [OkCancelEdit] ; EditField + " - " + PromptTitle; "Please enter the new desired value for: " + @Implode( EditField ; ", " ) + "." + @Char(13) + @Char(13) + "Seperated with ; for each value." ; OriginalValue ) ; @Contains( DataType ; "+ Append Values" ); @Prompt( [OkCancelEdit] ; EditField + " - " + PromptTitle; "Please enter values to append: " + @Implode( EditField ; ", " ) + "." + @Char(13) + @Char(13) + "Seperated with ; for each value." ; "" ) ; DataType = ("Replace Substring":"Replace") ; @Prompt( [OkCancelEdit] ; EditField + " - " + PromptTitle ; "Please enter the text to repalce with in: " + EditField + "." ; "" ) ; @Prompt( [OkCancelEdit] ; EditField + " - " + PromptTitle ; "Please enter the new desired value for: " + EditField + "." ; OriginalValue ) ); REM {Add each document's UNID to a growing list, check each doc against the list as }; REM {we navigate through selected docs; Once a duplicate is found all should be processed, end loop}; REM {The values entered above will be applied to all selected docs ...}; REM {If data conversion doesn't work then don't set field.}; UNID:=""; @While(! @Contains(UNID;@Text(@DocumentUniqueID) + ":" ); UNID:= UNID + ":" + @Text(@DocumentUniqueID); @For( ef := 1; ef <= @Elements(EditField); ef := ef + 1; FieldDataType := @If( @IsNumber( @GetField( EditField[ef] ) ) ; @If( @Count( @GetField( EditField[ef]) ) > 1 ; "Integer Multi Value"; "Integer" ) ; @IsTime( @GetField( EditField[ef] ) ) ; @If( @Count( @GetField( EditField[ef]) ) > 1 ; "Date Multi Value"; "Date" ) ; @If( @Count( @GetField( EditField[ef]) ) > 1 ; "Text Multi Value"; "Text" ) ); FieldDataType := @IfError( DefaultDataType ; "Text" ); @If( DataType = "Date" ; @If( @IsError( @ToTime( RawValue ) ) ; "" ; @SetField( EditField[ef] ; @ToTime( RawValue ) ) ); DataType = "Integer" ; @If( @IsError( @TextToNumber( RawValue ) ) ; "" ; @SetField( EditField[ef] ; @TextToNumber( RawValue ) ) ) ; DataType = "Common Name" ; @SetField( EditField[ef] ; @Name( [CN]; RawValue ) ) ; DataType = "Abbreviate Name" ; @SetField( EditField[ef] ; @Name( [Abbreviate]; RawValue ) ) ; DataType = "Password" ; @SetField( EditField[ef] ; @Password( RawValue ) ) ; DataType = "Remove Field" ; @SetField( EditField[ef] ; @DeleteField ) ; DataType = "Text Multi Value" ; @SetField( EditField[ef] ; @Explode( RawValue ; ";" ) ) ; DataType = "+ Append Values" ; @If( @Contains(DefaultDataType; "Date"); @If( @IsError( @ToTime( RawValue ) ) ; "" ; @SetField( EditField[ef] ; @GetField(EditField[ef]) : @TextToTime( @Explode( RawValue ; ";" ) ) ) ) ; @Contains(DefaultDataType; "Integer"); @If( @IsError( @TextToNumber( @Explode( RawValue ; ";" ) ) ) ; "" ; @SetField( EditField[ef] ; @GetField(EditField[ef]) : @TextToNumber( @Explode( RawValue ; ";" ) ) ) ) ; @SetField( EditField[ef] ; @GetField(EditField[ef]) : @Explode( RawValue ; ";" ) ) ); DataType = "Date Multi Value" ; @If( @IsError( @ToTime( RawValue ) ) ; "" ; @SetField( EditField[ef] ; @TextToTime( @Explode( RawValue ; ";" ) ) ) ) ; DataType = "Integer Multi Value" ; @If( @IsError( @TextToNumber( @Explode( RawValue ; ";" ) ) ) ; "" ; @SetField( EditField[ef] ; @TextToNumber( @Explode( RawValue ; ";" ) ) ) ) ; DataType = "Name Multi Value" ; @SetField( EditField[ef] ; @Explode( RawValue ; ":" ) ) ; DataType = "Common Name Multi Value" ; @SetField( EditField[ef] ; @Name( [CN]; @Explode( RawValue ; ":" ) ) ); DataType = "Abbreviate Name Multi Value" ; @SetField( EditField[ef] ; @Name( [Abbreviate]; @Explode( RawValue ; ":" ) ) ); DataType = "Upper Case Text" ; @If( @Contains( DefaultDataType ; "Text" ) ; @SetField( EditField[ef] ; @UpperCase( RawValue ) ) ; "" ); DataType = "Lower Case Text" ; @If( @Contains( DefaultDataType ; "Text" ) ; @SetField( EditField[ef] ; @LowerCase( RawValue ) ); "" ); DataType = "Proper Case Text" ; @If( @Contains( DefaultDataType ; "Text" ) ; @SetField( EditField[ef] ; @ProperCase( RawValue ) ); "" ); DataType = "Upper Case Text Multi Value" ; @If( @Contains( DefaultDataType ; "Text" ) ; @SetField( EditField[ef] ; @UpperCase( @Explode( RawValue ; ";" ) ) ); "" ); DataType = "Lower Case Text Multi Value" ; @If( @Contains( DefaultDataType ; "Text" ) ; @SetField( EditField[ef] ; @LowerCase( @Explode( RawValue ; ";" ) ) ); "" ); DataType = "Proper Case Text Multi Value" ; @If( @Contains( DefaultDataType ; "Text" ) ; @SetField( EditField[ef] ; @ProperCase( @Explode( RawValue ; ";" ) ) ); "" ); DataType = "Unique" ; @SetField( EditField[ef] ; @Unique( @GetField( EditField[ef] ) ) ); DataType = "Implode" ; @SetField( EditField[ef] ; @Implode( @GetField( EditField[ef] ) ; Separator ) ); DataType = "Explode" ; @SetField( EditField[ef] ; @Explode( @GetField( EditField[ef] ) ; Separator ) ); DataType = "Sort Ascending" ; @SetField( EditField[ef] ; @Sort( @GetField( EditField[ef] ) ; [Ascending] ) ); DataType = "Sort Descending" ; @SetField( EditField[ef] ; @Sort( @GetField( EditField[ef] ) ; [Descending] ) ); DataType = "Replace Substring" ; @If( @Contains( FieldDataType ; "Text" ) ; @SetField( EditField[ef] ; @ReplaceSubstring( @GetField( EditField[ef] ) ; FromRawValue ; RawValue ) ) ; ReplaceFailure := @True ) ; DataType = "Replace" ; @If( @Contains( FieldDataType ; "Text" ) ; @SetField( EditField[ef] ; @Explode( @Replace( @GetField( EditField[ef] ) ; FromRawValue ; RawValue ) ; ";" ) ) ; ReplaceFailure := @True ); @SetField( EditField[ef] ; RawValue ) ) ); @Command([NavNextSelected]); @UpdateFormulaContext); @If( ReplaceFailure ; @Prompt( [Ok] ; "Unable to Replace" ; "Unable to replace some or all because the original value is not text.") ; "" ); ""; @StatusBar( "Peformed '" + DataType + "' for '" + @Implode( EditField ; ", " ) + "' field" + @If( @Elements( EditField ) > 1; "s " ; " " ) + "on " + @Text( @Elements( @Explode(UNID ; ";" ; @False ) ) ) + " document" + @If( @Elements( @Explode(UNID ; ";" ; @False ) ) > 1 ; "s" ; "" ) + "." );
Permalink
|
Comments (0)
|
TrackBacks (0)
| Category